Jump to content
View in the app

A better way to browse. Learn more.

Obsidian Forum Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

So i'm doing a java application to view text files (HTML, Plain, rtf ,doc, pdf whatever)

I haven't got to the part when i will need it, but i've already noticed that memory mapped abstractdocument don't exist in swing. So no 20 open files at the same time. (Actually 1 large open file gives problems because of swing retarded views so i allready have to do paging between the model -in memory- and the view ).

 

Before comming seppuku with swing's viewtomodel methods (don't work) that i'm trying to use to discover the first and last visible text in the application, i'm wondering if anybody allready tried to make make a document that reads from file instead of memory.

 

I bet you didn't. But i'll try anyway. Because i'm lazy and incompetent.

Perhaps you might have a better response from the Developer's forum?

 

Reading from a file is pretty standard stuff in Java, btw. And any language, come to think of it.

OBSCVRVM PER OBSCVRIVS ET IGNOTVM PER IGNOTIVS

ingsoc.gif

OPVS ARTIFICEM PROBAT

Moving to the proper forum.

2010spaceships.jpg

Hades was the life of the party. RIP You'll be missed.

  • Author

Its not a question of reading from a file. Its reading on demand from a file, while obeying the AbstractDocument interface from swing, on all charsets, not just ASCII, figure out a element tree (ie: this text is BOLD), and the text just isn't contigous in most situations(HTML, RTF,pdf). This last problem is somewhat solvable in swing, since i can parse directly. What i have to do is a class that figures out the charset, parses the positions of the paragraphs in the text acording to the charset, and stores the complete element tree, and when text is directly asked go to the file and extract it.

  • Author

Sucess!

 

Well sorta. I am now able to index the text in the view (the V in MVC) of swing to the paged document exactly. It involved subclassing the viewfactory and the ParagraphView. The viewFactory (obviously) to return my modified ParagraphView

and the ParagraphView to remember the StartOffset of the first line and the EndOffset of the last.

The difference is the value of the length of displayed text in the Document (being that it different than the length of displayed text in the view).

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.