java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
javax.swing.text.StyledEditorKit
javax.swing.text.html.HTMLEditorKit
com.hexidec.ekit.component.ExtendedHTMLEditorKit
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.lang.Cloneable, java.io.Serializable
- public class ExtendedHTMLEditorKit
- extends javax.swing.text.html.HTMLEditorKit
This class extends HTMLEditorKit so that it can provide other renderer classes
instead of the defaults. Most important is the part which renders relative
image paths.
- Version:
- 1.0
| Nested classes inherited from class javax.swing.text.html.HTMLEditorKit |
javax.swing.text.html.HTMLEditorKit.HTMLFactory, javax.swing.text.html.HTMLEditorKit.HTMLTextAction, javax.swing.text.html.HTMLEditorKit.InsertHTMLTextAction, javax.swing.text.html.HTMLEditorKit.LinkController, javax.swing.text.html.HTMLEditorKit.Parser, javax.swing.text.html.HTMLEditorKit.ParserCallback |
| Nested classes inherited from class javax.swing.text.StyledEditorKit |
javax.swing.text.StyledEditorKit.AlignmentAction, javax.swing.text.StyledEditorKit.BoldAction, javax.swing.text.StyledEditorKit.FontFamilyAction, javax.swing.text.StyledEditorKit.FontSizeAction, javax.swing.text.StyledEditorKit.ForegroundAction, javax.swing.text.StyledEditorKit.ItalicAction, javax.swing.text.StyledEditorKit.StyledTextAction, javax.swing.text.StyledEditorKit.UnderlineAction |
| Nested classes inherited from class javax.swing.text.DefaultEditorKit |
javax.swing.text.DefaultEditorKit.BeepAction, javax.swing.text.DefaultEditorKit.CopyAction, javax.swing.text.DefaultEditorKit.CutAction, javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction, javax.swing.text.DefaultEditorKit.InsertBreakAction, javax.swing.text.DefaultEditorKit.InsertContentAction, javax.swing.text.DefaultEditorKit.InsertTabAction, javax.swing.text.DefaultEditorKit.PasteAction |
|
Field Summary |
private static javax.swing.text.html.HTMLEditorKit.Parser |
defaultParser
|
| Fields inherited from class javax.swing.text.html.HTMLEditorKit |
BOLD_ACTION, COLOR_ACTION, DEFAULT_CSS, FONT_CHANGE_BIGGER, FONT_CHANGE_SMALLER, IMG_ALIGN_BOTTOM, IMG_ALIGN_MIDDLE, IMG_ALIGN_TOP, IMG_BORDER, ITALIC_ACTION, LOGICAL_STYLE_ACTION, PARA_INDENT_LEFT, PARA_INDENT_RIGHT |
| Fields inherited from class javax.swing.text.DefaultEditorKit |
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction |
|
Method Summary |
java.lang.Object |
clone()
Creates a copy of the editor kit. |
javax.swing.text.Document |
createDefaultDocument()
Create a text storage model for this type of editor. |
void |
createInputAttributes(javax.swing.text.Element element,
javax.swing.text.MutableAttributeSet set)
Copies the key/values in elements AttributeSet into
set. |
javax.swing.text.html.HTMLEditorKit.Parser |
getParser()
Get the parser that this editor kit uses for reading HTML streams. |
javax.swing.text.ViewFactory |
getViewFactory()
Method for returning a ViewFactory which handles the image rendering. |
void |
read(java.io.Reader in,
javax.swing.text.Document doc,
int pos)
Inserts content from the given stream. |
void |
write(java.io.Writer out,
javax.swing.text.Document doc,
int pos,
int len)
public void insertHTML(HTMLDocument doc, int offset, String html,
int popDepth, int pushDepth,
HTML.Tag insertTag) throws
BadLocationException, IOException {
Parser p = getParser();
if (p == null) {
throw new IOException("Can't load parser");
}
if (offset > doc.getLength()) {
throw new BadLocationException("Invalid location", offset);
}
ParserCallback receiver = doc.getReader(offset, popDepth, pushDepth,
insertTag);
Boolean ignoreCharset = (Boolean)doc.getProperty
("IgnoreCharsetDirective");
p.parse(new StringReader(html), receiver, (ignoreCharset == null) ?
false : ignoreCharset.booleanValue());
receiver.flush();
}
/**
Write content from a document to the given stream
in a format appropriate for this kind of content handler. |
| Methods inherited from class javax.swing.text.html.HTMLEditorKit |
deinstall, getAccessibleContext, getActions, getContentType, getDefaultCursor, getInputAttributes, getLinkCursor, getStyleSheet, insertHTML, install, setDefaultCursor, setLinkCursor, setStyleSheet |
defaultParser
private static javax.swing.text.html.HTMLEditorKit.Parser defaultParser
ExtendedHTMLEditorKit
public ExtendedHTMLEditorKit()
- Constructor
getParser
public javax.swing.text.html.HTMLEditorKit.Parser getParser()
- Description copied from class:
javax.swing.text.html.HTMLEditorKit
- Get the parser that this editor kit uses for reading HTML streams. This
method can be overridden to use the alternative parser.
getViewFactory
public javax.swing.text.ViewFactory getViewFactory()
- Method for returning a ViewFactory which handles the image rendering.
createDefaultDocument
public javax.swing.text.Document createDefaultDocument()
- Description copied from class:
javax.swing.text.html.HTMLEditorKit
- Create a text storage model for this type of editor.
read
public void read(java.io.Reader in,
javax.swing.text.Document doc,
int pos)
throws java.io.IOException,
javax.swing.text.BadLocationException
- Inserts content from the given stream. If
doc is
an instance of HTMLDocument, this will read
HTML 3.2 text. Inserting HTML into a non-empty document must be inside
the body Element, if you do not insert into the body an exception will
be thrown. When inserting into a non-empty document all tags outside
of the body (head, title) will be dropped.
write
public void write(java.io.Writer out,
javax.swing.text.Document doc,
int pos,
int len)
throws java.io.IOException,
javax.swing.text.BadLocationException
- public void insertHTML(HTMLDocument doc, int offset, String html,
int popDepth, int pushDepth,
HTML.Tag insertTag) throws
BadLocationException, IOException {
Parser p = getParser();
if (p == null) {
throw new IOException("Can't load parser");
}
if (offset > doc.getLength()) {
throw new BadLocationException("Invalid location", offset);
}
ParserCallback receiver = doc.getReader(offset, popDepth, pushDepth,
insertTag);
Boolean ignoreCharset = (Boolean)doc.getProperty
("IgnoreCharsetDirective");
p.parse(new StringReader(html), receiver, (ignoreCharset == null) ?
false : ignoreCharset.booleanValue());
receiver.flush();
}
/**
Write content from a document to the given stream
in a format appropriate for this kind of content handler.
createInputAttributes
public void createInputAttributes(javax.swing.text.Element element,
javax.swing.text.MutableAttributeSet set)
- Copies the key/values in
elements AttributeSet into
set. This does not copy component, icon, or element
names attributes. Subclasses may wish to refine what is and what
isn't copied here. But be sure to first remove all the attributes that
are in set.
This is called anytime the caret moves over a different location.
clone
public java.lang.Object clone()
- Creates a copy of the editor kit.