com.inet.html
Class InetHtmlEditorKit

java.lang.Object
  extended by javax.swing.text.EditorKit
      extended by javax.swing.text.DefaultEditorKit
          extended by javax.swing.text.StyledEditorKit
              extended by com.inet.html.InetHtmlEditorKit
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class InetHtmlEditorKit
extends javax.swing.text.StyledEditorKit

The JWebEngine implementation of the EditorKit.
This editor kit defines a custom set of actions which are not compatible with the default styled document. If you change the type of document in a JEditorPane please make sure to set the correct editor kit as well.

See Also:
Serialized Form

Nested Class Summary
static class InetHtmlEditorKit.ExtendedHyperlinkEvent
          An extended hyperlink event to support link targets
static class InetHtmlEditorKit.LinkController
          Class to watch the associated component and fire hyperlink events on it when appropriate.
 
Nested classes/interfaces 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/interfaces 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
static java.lang.String BULLET_LIST_ACTION
           
static java.lang.String NUMBERED_LIST_ACTION
           
static java.lang.String PARAGRAPH_INDENT_LEFT
           
static java.lang.String PARAGRAPH_INDENT_RIGHT
           
static java.lang.String PASTE_PLAIN_ACTION
           
static int SHORTCUT_KEY_MASK
           
static java.lang.String TAB_KEY_ACTION
           
static java.lang.String TAB_KEY_SHIFT_ACTION
           
 
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
 
Constructor Summary
InetHtmlEditorKit()
          Required to update the input attributes only on relevant caret changes
InetHtmlEditorKit(boolean useTextAntiAlias)
          Creates an editor kit with optional text anti alias
 
Method Summary
 java.lang.Object clone()
          
 javax.swing.text.Document createDefaultDocument()
          
 void deinstall(javax.swing.JEditorPane c)
          
 void forceUpdateInputAttributes(javax.swing.JEditorPane editor)
          Forces the editor kit to update it's input attributes.
 javax.swing.Action[] getActions()
          
 java.lang.String getContentType()
          
 java.awt.Cursor getDefaultCursor()
          Returns the default cursor
 javax.swing.text.MutableAttributeSet getInputAttributes()
          Gets the input attributes for the pane.
 java.awt.Cursor getLinkCursor()
          Returns the cursor which should be displayed when hovering links
 javax.swing.text.ViewFactory getViewFactory()
          
 void install(javax.swing.JEditorPane c)
          
 void read(java.io.Reader in, javax.swing.text.Document doc, int pos)
          
 void setDefaultConfig(InetHtmlConfiguration defaultConfig)
          Sets the default configuration of the documents created by this editor kit
 void setDefaultCursor(java.awt.Cursor defaultCursor)
          Sets the default cursor
 void setFontScale(float scale)
          Sets the scale factor
 void setLinkCursor(java.awt.Cursor linkCursor)
          Sets the link hover cursor, must not be null
 void setParserTimeout(long timeout)
          Sets the parser timeout in ms.
 void write(java.io.Writer out, javax.swing.text.Document doc, int pos, int len)
          
 
Methods inherited from class javax.swing.text.StyledEditorKit
getCharacterAttributeRun
 
Methods inherited from class javax.swing.text.DefaultEditorKit
createCaret, read, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAGRAPH_INDENT_LEFT

public static final java.lang.String PARAGRAPH_INDENT_LEFT
See Also:
Constant Field Values

PARAGRAPH_INDENT_RIGHT

public static final java.lang.String PARAGRAPH_INDENT_RIGHT
See Also:
Constant Field Values

TAB_KEY_ACTION

public static final java.lang.String TAB_KEY_ACTION
See Also:
Constant Field Values

TAB_KEY_SHIFT_ACTION

public static final java.lang.String TAB_KEY_SHIFT_ACTION
See Also:
Constant Field Values

BULLET_LIST_ACTION

public static final java.lang.String BULLET_LIST_ACTION
See Also:
Constant Field Values

NUMBERED_LIST_ACTION

public static final java.lang.String NUMBERED_LIST_ACTION
See Also:
Constant Field Values

PASTE_PLAIN_ACTION

public static final java.lang.String PASTE_PLAIN_ACTION
See Also:
Constant Field Values

SHORTCUT_KEY_MASK

public static final int SHORTCUT_KEY_MASK
Constructor Detail

InetHtmlEditorKit

public InetHtmlEditorKit()
Required to update the input attributes only on relevant caret changes


InetHtmlEditorKit

public InetHtmlEditorKit(boolean useTextAntiAlias)
Creates an editor kit with optional text anti alias

Parameters:
useTextAntiAlias - true, to use anti alias, false to disable the feature
Method Detail

setFontScale

public void setFontScale(float scale)
Sets the scale factor

Parameters:
scale - a value between 0.1 and 10

setParserTimeout

public void setParserTimeout(long timeout)
Sets the parser timeout in ms. Any parser created or invoked by this factory will interrupt after approximatly this timeout and return with the document parsed up until this moment. If the timeout is too short or the connection is slow, the parser may have not reached the body part after the timeout. Furthermore, this timeout does not stop the layout and rendering.

Parameters:
timeout - the timeout for the parser in millisecondsany value equal or below zero disables the timeout

createDefaultDocument

public javax.swing.text.Document createDefaultDocument()

Overrides:
createDefaultDocument in class javax.swing.text.StyledEditorKit

getViewFactory

public javax.swing.text.ViewFactory getViewFactory()

Overrides:
getViewFactory in class javax.swing.text.StyledEditorKit

setDefaultConfig

public void setDefaultConfig(InetHtmlConfiguration defaultConfig)
Sets the default configuration of the documents created by this editor kit

Parameters:
defaultConfig - the new config, null will be ignored

read

public void read(java.io.Reader in,
                 javax.swing.text.Document doc,
                 int pos)
          throws java.io.IOException,
                 javax.swing.text.BadLocationException

Overrides:
read in class javax.swing.text.DefaultEditorKit
Throws:
java.io.IOException
javax.swing.text.BadLocationException

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

Overrides:
write in class javax.swing.text.DefaultEditorKit
Throws:
java.io.IOException
javax.swing.text.BadLocationException

getActions

public javax.swing.Action[] getActions()

Overrides:
getActions in class javax.swing.text.StyledEditorKit

getContentType

public java.lang.String getContentType()

Overrides:
getContentType in class javax.swing.text.DefaultEditorKit

install

public void install(javax.swing.JEditorPane c)

Overrides:
install in class javax.swing.text.StyledEditorKit

deinstall

public void deinstall(javax.swing.JEditorPane c)

Overrides:
deinstall in class javax.swing.text.StyledEditorKit

getInputAttributes

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.

Overrides:
getInputAttributes in class javax.swing.text.StyledEditorKit
Returns:
the attribute set

forceUpdateInputAttributes

public void forceUpdateInputAttributes(javax.swing.JEditorPane editor)
Forces the editor kit to update it's input attributes. This method work's even if neither the caret position nor the underlying element changed.

Parameters:
editor - The editor to read the attributes from.

getDefaultCursor

public java.awt.Cursor getDefaultCursor()
Returns the default cursor

Returns:
the default cursor

setDefaultCursor

public void setDefaultCursor(java.awt.Cursor defaultCursor)
Sets the default cursor

Parameters:
defaultCursor - the cursor, must not be null

getLinkCursor

public java.awt.Cursor getLinkCursor()
Returns the cursor which should be displayed when hovering links

Returns:
the cursor which should be displayed when hovering links

setLinkCursor

public void setLinkCursor(java.awt.Cursor linkCursor)
Sets the link hover cursor, must not be null

Parameters:
linkCursor - the link hover cursor, must not be null

clone

public java.lang.Object clone()

Overrides:
clone in class javax.swing.text.StyledEditorKit