Package com.inet.html

Class InetHtmlEditorKit

All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
BaseEditor.SetPageEditorKit

public class InetHtmlEditorKit extends 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:
  • Field Details

    • PARAGRAPH_INDENT_LEFT

      public static final String PARAGRAPH_INDENT_LEFT
      Action key for the change paragraph indent action
      See Also:
    • PARAGRAPH_INDENT_RIGHT

      public static final String PARAGRAPH_INDENT_RIGHT
      Action key for the change paragraph indent action
      See Also:
    • TAB_KEY_ACTION

      public static final String TAB_KEY_ACTION
      Action key for the insert tabulator action
      See Also:
    • TAB_KEY_SHIFT_ACTION

      public static final String TAB_KEY_SHIFT_ACTION
      Action key for the remove tabulator action
      See Also:
    • BULLET_LIST_ACTION

      public static final String BULLET_LIST_ACTION
      Action key for the insert/toggle bullet list action
      See Also:
    • NUMBERED_LIST_ACTION

      public static final String NUMBERED_LIST_ACTION
      Action key for the insert/toggle numbered list action
      See Also:
    • PASTE_PLAIN_ACTION

      public static final String PASTE_PLAIN_ACTION
      Action key for the switch HTML/plain action
      See Also:
    • COPY_PLAIN_ACTION

      public static final String COPY_PLAIN_ACTION
      Action key for the copy action
      See Also:
    • SEARCH_INIT_ACTION

      public static final String SEARCH_INIT_ACTION
      Action key for the initialize search action
      See Also:
    • SEARCH_NEXT_ACTION

      public static final String SEARCH_NEXT_ACTION
      Action key for the highlight next search hit action
      See Also:
    • SEARCH_PREVIOUS_ACTION

      public static final String SEARCH_PREVIOUS_ACTION
      Action key for the highlight previous search hit action
      See Also:
    • SEARCH_CLEAR_ACTION

      public static final String SEARCH_CLEAR_ACTION
      Action key for the clear search action
      See Also:
    • SHORTCUT_KEY_MASK

      public static final int SHORTCUT_KEY_MASK
  • Constructor Details

    • InetHtmlEditorKit

      public InetHtmlEditorKit()
      Creates the editor kit with defaults: no font scaling, anti-alias activated
      Since:
      1.0
    • 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
      Since:
      1.05
  • Method Details

    • setFontScale

      public void setFontScale(float scale)
      Sets the scale factor. This factor will be applied to all calculated font sizes when displaying the content.
      Parameters:
      scale - a value between 0.1 and 10
      Since:
      1.05
    • 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
      Since:
      1.05
    • createDefaultDocument

      public InetHtmlDocument createDefaultDocument()
      Overrides:
      createDefaultDocument in class StyledEditorKit
    • getViewFactory

      public ViewFactory getViewFactory()
      Overrides:
      getViewFactory in class 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
      Since:
      1.05
    • read

      public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
      Overrides:
      read in class DefaultEditorKit
      Throws:
      IOException
      BadLocationException
    • write

      public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
      Overrides:
      write in class DefaultEditorKit
      Throws:
      IOException
      BadLocationException
    • getActions

      public Action[] getActions()
      Overrides:
      getActions in class StyledEditorKit
    • getContentType

      public String getContentType()
      Overrides:
      getContentType in class DefaultEditorKit
    • install

      public void install(JEditorPane c)
      Overrides:
      install in class StyledEditorKit
    • deinstall

      public void deinstall(JEditorPane c)
      Overrides:
      deinstall in class StyledEditorKit
    • getCurrentCustomActions

      public List<Action> getCurrentCustomActions()
      Returns a list of actions for the elements at the current mouse position
      Returns:
      a list of actions for the elements at the current mouse position, never null
      Since:
      2.0
    • createInputAttributes

      protected void createInputAttributes(Element element, MutableAttributeSet set)
      Overrides:
      createInputAttributes in class StyledEditorKit
    • createInputAttributes

      protected void createInputAttributes(Element dotElement, Element markElement, MutableAttributeSet set)
      Creates the input attributes for a range of element. The resulting set will be a unification of the attribute sets of all elements found. Some attributes like font or font size will be cleared if there is more than one
      Parameters:
      dotElement - the top element at the dot position
      markElement - the top element at the mark position
      set - the attribute set to fill
      Since:
      1.05
    • getInputAttributes

      public 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 StyledEditorKit
      Returns:
      the attribute set
      Since:
      1.05
    • forceUpdateInputAttributes

      public void forceUpdateInputAttributes(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.
      Since:
      1.05
    • getDefaultCursor

      public Cursor getDefaultCursor()
      Returns the default cursor of the view area
      Returns:
      the default cursor
      Since:
      1.05
    • setDefaultCursor

      public void setDefaultCursor(Cursor defaultCursor)
      Sets the default cursor for the view area
      Parameters:
      defaultCursor - the cursor, must not be null
      Since:
      1.05
    • getLinkCursor

      public Cursor getLinkCursor()
      Returns the cursor which should be displayed when hovering links
      Returns:
      the cursor which should be displayed when hovering links
      Since:
      1.05
    • setLinkCursor

      public void setLinkCursor(Cursor linkCursor)
      Sets the link hover cursor, must not be null
      Parameters:
      linkCursor - the link hover cursor, must not be null
      Since:
      1.05
    • clone

      public Object clone()
      Overrides:
      clone in class StyledEditorKit
    • setRenderingMode

      public static void setRenderingMode(InetHtmlEditorKit.RENDER_MODE mode)
      Sets the rendering mode to be used for newly created InetHtmlFactorys and HtmlRootView.
      The rendering mode defines the type of RenderingHints.KEY_TEXT_ANTIALIASING to be used and additional optimizations depending of the anti alias type. Please see the InetHtmlEditorKit.RENDER_MODE enum values for details.
      Note: This value will directly affect current views and thus may invalidate there rendering. It's highly recommend to set this value ahead of any rendering process.
      Parameters:
      mode - the rendering mode to be set, null will default to InetHtmlEditorKit.RENDER_MODE.java_custom
      Since:
      1.11
    • getRenderingMode

      public static InetHtmlEditorKit.RENDER_MODE getRenderingMode()
      Returns the currently selected rendering mode
      Returns:
      the currently selected rendering mode
      Since:
      1.11