...
- #Check out TextualDisplay from CVS.
- #Build TextualDisplay and run an example application.
- #Serialize your exemplary object to XML.
- #Write an XSLT style sheet that transforms your XML to HTML.
- Display your HTML in a web browser.
- Display your object in the TextDispViewer that comes with TextualDisplay.
- #Use TextDispViewer to look at the result of your XSLT transformation.
- #Integrate Integrate TextualDisplay into your application.
Check out TextualDisplay from CVS
...
Of course, you can always ask an XSLT expert (i.e. me) to write you a style sheet...
Use TextDispViewer to look at the result of your XSLT transformation
Copy Once you have your style sheet , copy in to the directory of your test class and add this code to your test class:
...
Tweak your XSLT, until you're satisfied with what you see.
Integrate TextualDisplay into your application
Below are some things to consider when integrating TextualDisplay into your application.
HTMLScrollPane
To get the maximum support available in Swing, you should display your HTML only on the edu.stanford.slac.util.textdisp.ui.HTMLScrollPane widget, which is a subclass of javax.swing.JScrollPane and wraps the Flying Saucer web browser. Also, you might want to turn off the logging messages:
Code Block |
---|
System.setProperty("xr.util-logging.java.util.logging.ConsoleHandler.level", "OFF"); //do this ASAP
HTMLScrollPane htmlScrollPane = new HTMLScrollPane();
Container myContainer = ...;
... //do layout
myContainer.add(htmlScrollPane, ...); /
String html = ...;
htmlScrollPane.setStyledData(html);
|
You have access to the wrapped browser widget:
Code Block |
---|
HTMLScrollPane htmlScrollPane = ...;
htmlScrollPane.xhtmlPanel.incrementFontSize();
|
Note: TextDispViewer uses HTMLScrollPane.
Upload XSLT style sheets to a web server
When the infrastructure is ready, you might want to upload your XSLT style sheets to a web server. You can easily construct a URL in such case:
Code Block |
---|
URL url = new URL("http://...");
|
We recommend that you externalize all your URLs (or any strings, for that matter).