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

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...