This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games and have Dana Pylayeva on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

HTMLEditorKit & Performance

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I develop a java reporting tool which generates outputs in several formats(HTML,TXT,RTF...)
This component is accessible either a Client/Server Application written with Swing library , either a web-application.
When we use the swing application, a JEditorPane is used to retrieve the reports, associated with a correspondant EditorKit.
Even if the report is small (20 Ko), it takes time to display it in HTML..... and if you relaunch it many times, the application hangs up (memory leak ?)
With TXT, it is good and with the web-application too.
I suppose (and i'm sure with JBuilder !) that the problem is due to the read method called with HTMLEditorLit.read(inputstream,doc,pos)....
Thanks for your help.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by emmanuel soyeux:
it takes time to display it in HTML..... and if you relaunch it many times, the application hangs up (memory leak ?)



hmmm. relaunch it many times? not in a hurry i hope:-)


just fishin' in the dark but have you tried apache's httpclient?

they have a nice sample that will write output to a JEditorPane, so you could do a litmus test:

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/ClientApp.java?rev=1.11&only_with_tag=HTTPCLIENT_2_0_BRANCH&view=markup


i mention this because i've seen prev complaints about hangs because java doesn't support setting http connection timeout. this may or may not be related to your issue, but it might be interesting to see if this helps to isolate the problem (in the editor kit or otherwise)

good luck - let us know how it comes out!
 
emmanuel soyeux
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The previous code from Apache is quite similar to my own one.
To be short,the problem occurs in these lines
JeditorPane editorPane; // already defined
InputStreamReader reader; // already defined
HTMLDocument doc = new HTMLDocument();
editorPane.read(reader, doc); => problem !!!

This takes a long time and the VM increases strongly!!
Same behaviour with using HTMLEditorKit, ......

What's wrong ?
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i gave this a quick try and ... it wasn't so quick. however, performance was not horrible - especially for smaller or less complex documents.

just some ideas from a 10k ft view:

possible places to look(?) -

(1) Format of the HTML report(s) you're reading

JEditorpane - from what i can see - has about 15 html handling bugs being fixed in 1.5, including an important-looking META tag support bug.

API gives current HTML support at 3.2 (if in doubt, report
compliance could be verified w tool like jtidy also see last item below)


(2) issues related to _read (vs. using constructor or _setPage)

(a) *non* asynch vs asynch performance; (b) existence of
relative path refs (determination of basedir), (c) content type, etc.

(3) content itself
can be set/checked before/after instantiation.
any possibility of charset issues? is doc editable?


finally, there's a jeditorpane-based simple browser (platespiller ) out there that you could use as a baseline - to see if these reports display ok using that browser, and to check the rendering integrity and performance deltas


hth - good luck!
 
emmanuel soyeux
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For all projects regarding a java browser for HTML Document, they always use JeditorPane with read or setPage method......

My own code concerning the HTML viewver of the application seems to the following lines :

JEditorPane editorPane= new JEditorPane();
editorPane.setEditable(false);
editorPane.setContentType("text/html; charset=ISO-8859-1");
HTMLEditorKit htmlKit = new HTMLEditorKit();
editorPane.setEditorKit(htmlKit);
Document doc = htmlKit.createDefaultDocument();
//To have the focus on this dialogBox...
JWindow wnd = new JWindow();
wnd.setContentPane(editorPane);
wnd.pack();
wnd.setVisible(true);
wnd.toFront();
editorPane.validate();

//Loading data...
try {
editorPane.read(in,doc);

} catch (Exception e) {
System.out.println(e); // => The second run fails !
}

JScrollPane editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setPreferredSize(new Dimension(500, 500));
editorScrollPane.setMinimumSize(new Dimension(100, 100));
editorScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

setLayout(new GridBagLayout()); //The general panel which embedds the editorPane
addToGridBag....


The problem is awalys in the read method......
I have the feeling that some static objects associated to the editorkit, htmldocument...... are not properly cleaned
but when i close the window, all the objects are reset to null (and as they are locally, java can remove them from memory thanks to garbage collector..... but we can help this process.....)
 
You have to be odd to be #1 - Seuss. An odd little ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic