Jump to content

I want you to be my code-slave!

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites



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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...