final ParsedURL u = new ParsedURL(svgDocument.getURL());
final JFrame fr = new JFrame(u.toString());
fr.setSize(resources.getInteger("ViewSource.width"),
resources.getInteger("ViewSource.height"));
final XMLTextEditor ta = new XMLTextEditor();
// ta.setLineWrap(true);
ta.setFont(new Font("monospaced", Font.PLAIN, 12));
JScrollPane scroll = new JScrollPane();
scroll.getViewport().add(ta);
scroll.setVerticalScrollBarPolicy
(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
fr.getContentPane().add(scroll, BorderLayout.CENTER);
new Thread() {
public void run() {
char [] buffer = new char[4096];
try {
Document doc = new XMLDocument();
ParsedURL purl = new ParsedURL(svgDocument.getURL());
InputStream is
= u.openStream(getInputHandler(purl).
getHandledMimeTypes());
// u.openStream(MimeTypeConstants.MIME_TYPES_SVG);
Reader in = XMLUtilities.createXMLDocumentReader(is);
int len;
while ((len=in.read(buffer, 0, buffer.length)) != -1) {
doc.insertString(doc.getLength(),
new String(buffer, 0, len), null);
}
ta.setDocument(doc);
ta.setEditable(false);
// ta.setBackground(Color.white);
fr.setVisible(true);
} catch (Exception ex) {
userAgent.displayError(ex);
}