bb2b14a8f42d1c84252e57853098d617a3e1d951
2 GNU Lesser General Public License
5 Copyright (C) 2001-2002 Frits Jalvingh & Howard Kistler
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 package com
.hexidec
.ekit
.component
;
24 import javax
.swing
.text
.Element
;
25 import javax
.swing
.text
.StyleConstants
;
26 import javax
.swing
.text
.View
;
27 import javax
.swing
.text
.ViewFactory
;
28 import javax
.swing
.text
.html
.HTML
;
29 import javax
.swing
.text
.html
.HTMLEditorKit
;
31 /* WACKY GERMAN CODE */
32 import com
.hexidec
.ekit
.component
.ExtendedHTMLDocument
;
33 import javax
.swing
.text
.html
.StyleSheet
;
34 import javax
.swing
.text
.Document
;
37 * This class extends HTMLEditorKit so that it can provide other renderer classes
38 * instead of the defaults. Most important is the part which renders relative
41 * @author <a href="mailto:jal@grimor.com">Frits Jalvingh</a>
45 public class ExtendedHTMLEditorKit
extends HTMLEditorKit
49 public ExtendedHTMLEditorKit()
53 /** Method for returning a ViewFactory which handles the image rendering.
55 public ViewFactory
getViewFactory()
57 return new HTMLFactoryExtended();
60 /* WACKY GERMAN CODE */
61 public Document
createDefaultDocument() {
62 StyleSheet styles
= getStyleSheet();
63 StyleSheet ss
= new StyleSheet();
64 ss
.addStyleSheet(styles
);
65 ExtendedHTMLDocument doc
= new ExtendedHTMLDocument(ss
);
66 doc
.setParser(getParser());
67 doc
.setAsynchronousLoadPriority(4);
68 doc
.setTokenThreshold(100);
72 /* Inner Classes --------------------------------------------- */
74 /** Class that replaces the default ViewFactory and supports
75 * the proper rendering of both URL-based and local images.
77 public static class HTMLFactoryExtended
extends HTMLFactory
implements ViewFactory
81 public HTMLFactoryExtended()
85 /** Method to handle IMG tags and
86 * invoke the image loader.
88 public View
create(Element elem
)
90 Object obj
= elem
.getAttributes().getAttribute(StyleConstants
.NameAttribute
);
91 if(obj
instanceof HTML
.Tag
)
93 HTML
.Tag tagType
= (HTML
.Tag
)obj
;
94 if(tagType
== HTML
.Tag
.IMG
)
96 return new RelativeImageView(elem
);
99 return super.create(elem
);