Methods Summary |
---|
public java.lang.Object | clone()Creates a copy of the editor kit.
StyledEditorKit o = (StyledEditorKit)super.clone();
o.currentRun = o.currentParagraph = null;
o.createInputAttributeUpdated();
o.createInputAttributes();
return o;
|
public javax.swing.text.Document | createDefaultDocument()Creates an uninitialized text storage model
that is appropriate for this type of editor.
return new DefaultStyledDocument();
|
private void | createInputAttributeUpdated()Creates a new AttributeTracker .
inputAttributeUpdater = new AttributeTracker();
|
private void | createInputAttributes()Creates the AttributeSet used for the selection.
inputAttributes = new SimpleAttributeSet() {
public AttributeSet getResolveParent() {
return (currentParagraph != null) ?
currentParagraph.getAttributes() : null;
}
public Object clone() {
return new SimpleAttributeSet(this);
}
};
|
protected void | createInputAttributes(javax.swing.text.Element element, javax.swing.text.MutableAttributeSet set)Copies the key/values in element s 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.
if (element.getAttributes().getAttributeCount() > 0
|| element.getEndOffset() - element.getStartOffset() > 1
|| element.getEndOffset() < element.getDocument().getLength()) {
set.removeAttributes(set);
set.addAttributes(element.getAttributes());
set.removeAttribute(StyleConstants.ComponentAttribute);
set.removeAttribute(StyleConstants.IconAttribute);
set.removeAttribute(AbstractDocument.ElementNameAttribute);
set.removeAttribute(StyleConstants.ComposedTextAttribute);
}
|
public void | deinstall(javax.swing.JEditorPane c)Called when the kit is being removed from the
JEditorPane. This is used to unregister any
listeners that were attached.
c.removeCaretListener(inputAttributeUpdater);
c.removePropertyChangeListener(inputAttributeUpdater);
// remove references to current document so it can be collected.
currentRun = null;
currentParagraph = null;
|
public javax.swing.Action[] | getActions()Fetches the command list for the editor. This is
the list of commands supported by the superclass
augmented by the collection of commands defined
locally for style operations.
return TextAction.augmentList(super.getActions(), this.defaultActions);
|
public javax.swing.text.Element | getCharacterAttributeRun()Fetches the element representing the current
run of character attributes for the caret.
return currentRun;
|
public javax.swing.text.MutableAttributeSet | getInputAttributes()Gets the input attributes for the pane. When
the caret moves and there is no selection, the
input attributes are automatically mutated to
reflect the character attributes of the current
caret location. The styled editing actions
use the input attributes to carry out their
actions.
return inputAttributes;
|
public javax.swing.text.ViewFactory | getViewFactory()Fetches a factory that is suitable for producing
views of any models that are produced by this
kit. This is implemented to return View implementations
for the following kinds of elements:
- AbstractDocument.ContentElementName
- AbstractDocument.ParagraphElementName
- AbstractDocument.SectionElementName
- StyleConstants.ComponentElementName
- StyleConstants.IconElementName
return defaultFactory;
|
public void | install(javax.swing.JEditorPane c)Called when the kit is being installed into
a JEditorPane.
c.addCaretListener(inputAttributeUpdater);
c.addPropertyChangeListener(inputAttributeUpdater);
Caret caret = c.getCaret();
if (caret != null) {
inputAttributeUpdater.updateInputAttributes
(caret.getDot(), caret.getMark(), c);
}
|