Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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.

Posted

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

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