Package com.inet.html

Class InetHtmlDocument

All Implemented Interfaces:
CssDocument, Serializable, Document, StyledDocument

public class InetHtmlDocument extends HTMLDocument implements CssDocument
The document is the controller component of the JWebEngine model. It provides access to the element tree and the text content and provides updates to the view in case the model gets modified.
Another purpose of the document is to store additional information about the current content an how to process this content. Since the model of the JEditorPane prevents a direct access to the current parser, writer and view any property has to be set in the current document instance.
See Also:
  • Field Details

    • MAJOR_VERSION

      public static final int MAJOR_VERSION
      The major version of i-net JWebEngine
      See Also:
    • FLAG_INIT

      public static final Object FLAG_INIT
      An Element-Attribute key. If an attribute with this name is present, the temporary style informations for this element are supposed to be set and valid. If it is not set, it is recommended to call fillAttributes on this element before reading it's styles.
    • DOCTYPE_UNKNOWN

      @Deprecated public static final int DOCTYPE_UNKNOWN
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • DOCTYPE_HTML

      @Deprecated public static final int DOCTYPE_HTML
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • DOCTYPE_XHTML

      @Deprecated public static final int DOCTYPE_XHTML
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • DOCTYPE_STRICT

      @Deprecated public static final int DOCTYPE_STRICT
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • DOCTYPE_TRANSIENT

      @Deprecated public static final int DOCTYPE_TRANSIENT
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • DOCTYPE_FRAMESET

      @Deprecated public static final int DOCTYPE_FRAMESET
      Deprecated.
      As of JWebEngine 1.05, use getDocType() instead
      Return value of getHtmlVersion()
      See Also:
    • PROPERTY_INDENT_SPACE

      public static final Object PROPERTY_INDENT_SPACE
      A Document property key. The value must be an java.lang.Integer. On writting the document it specify how many spaces an indent maps to. When indentation takes place, the indent level is multiplied by this mapping. The default is 2. With a value of 0 also no formatting newlines are added.
    • PROPERTY_WRITE_HIERARCHY

      public static final Object PROPERTY_WRITE_HIERARCHY
      A Document property key. The value must be an java.lang.Boolean. On writting the partial document it specify if the hierachy around the mark document is written. The default is false.
    • PROPERTY_CONFIGURATION

      public static final Object PROPERTY_CONFIGURATION
      A Document property key, expected Type: com.inet.html.InetHtmlConfiguration, the Document configuration
    • PROPERTY_DEFAULT_FONT

      public static final Object PROPERTY_DEFAULT_FONT
      A Document property key, expected Type: java.awt.Font, the default font for empty documents
    • PROPERTY_DROP_UNKNOWN_STYLES

      public static final Object PROPERTY_DROP_UNKNOWN_STYLES
      A Document property key, expected Type: Boolean, if true unknown styles will not be stored in the document
    • PROPERTY_MEDIA

      public static final Object PROPERTY_MEDIA
      Sets the type of media, this document will render to. Any 'editable' media like the screen will tend to use threaded resource loading. Print media will cause the renderer to load all resources before the rendering will take place. Currently supported are 'screen' and 'print'.
      See Also:
    • MEDIA_SCREEN

      public static final String MEDIA_SCREEN
      The media target 'screen'. Renders like a normal web browser, enables lazy-loading of images.
      See Also:
    • MEDIA_PRINT

      public static final String MEDIA_PRINT
      The media target 'print'. Print media is treated differently in case of overflow for instance. Since print media cannot scroll and has a fixed clip, the content may be broken within words to always fit to boxes.
      NOTE: Print Media rendering causes a single threaded layout/paint flow
      See Also:
    • PROPERTY_PERSISTENT_STYLES

      public static final Object PROPERTY_PERSISTENT_STYLES
      A Document property key, expected Type: Styles, these style information will be used as default styles whenever the document is created or cleared. Unlike the default or user agent styles, these styles will be printed to the document!
      NOTE: Changing this property has only an effect on the next clear of the document!
    • PROPERTY_DEFAULT_STYLE_CLASS

      public static final Object PROPERTY_DEFAULT_STYLE_CLASS
      A Document property key, expected Type: String If set, this string will be set as style class for all elements created by jWebEngine, except BR. This can be used combined with the default styles to create a unique styling for all elements created by the user.
    • PROPERTY_IGNORE_NAMESPACES

      public static final Object PROPERTY_IGNORE_NAMESPACES
      Some applications define their own namespace to add additional informations to an XHTML document. Since we cannot display or interpret these elements, the document parser will drop them. To prevent the parser from doing so, set this property to Boolean.FALSE
    • PROPERTY_TIMEOUT

      public static final Object PROPERTY_TIMEOUT
      Defines the timeout for the renderer. If paint is called, this timeout can be used to interrupt the process after the given time has passed. Please note, that the timeout cannot be guaranteed it's only an approximation.
      Required Value: Number(fractions will be ignored), Unit: milliseconds
    • PROPERTY_TAB_WIDTH

      public static final Object PROPERTY_TAB_WIDTH
      If this property is set and has an integer value greater zero, tab stops will be enabled. Tab stops are always relative to the current line start! Please keep in mind, that the line justification is performed after the tabs had been sized. So any text-align will move the tab positions as well. If you want to achieve a table structure use a table instead! This value is in PX.
    • PROPERTY_BREAK_MODE

      public static final Object PROPERTY_BREAK_MODE
      This is a hint for the rendering device how to handle words which are wider than their block
    • BREAK_MODE_OVERFLOW

      public static final Object BREAK_MODE_OVERFLOW
      This mode is standard for HTML, it will never break within a word
    • BREAK_MODE_WORDBREAK

      public static final Object BREAK_MODE_WORDBREAK
      This mode allows words to be broken, if they are wider than their block. The word will start on a new line
    • BREAK_MODE_WORDBREAKINLINE

      public static final Object BREAK_MODE_WORDBREAKINLINE
      This mode allows words to be broken, if they are wider than their block. The word will start at it's current location
    • PROPERTY_USE_FONT_FALLBACK

      public static final Object PROPERTY_USE_FONT_FALLBACK
      If there are characters which cannot be displayed with a certain font, which has been set to and element, JWebEngine can use a fallback and search all known font for one, which can display the character. To disable this fallback, set this property to Boolean.FALSE. By default it is active.
    • PROPERTY_CONNECTION_TIMEOUT

      public static final Object PROPERTY_CONNECTION_TIMEOUT
      This property sets the connection timeout (in milliseconds) for all connections of a document. So it primarily affects the referenced style sheets, since these are read during the parser cycle. Images are loaded asynchronously by the image cache, so their loading does not effect the time until the document is displayed. For images the value is only relevant when printing.
      Allowed value types are numeric String, Number or InetHtmlDocument.TimeoutProvider
      In case of numeric values:
      • values > 0 - will be used as timeout in milliseconds
      • value == 0 - will set an infinite timeout
      • value == null or value == VALUE_CONNECTION_TIMEOUT_DEFAULT - do no set any timeout, use connection default
      • values < 0 - will DISABLE all connections
      Since:
      1.10
    • VALUE_CONNECTION_TIMEOUT_DEFAULT

      public static final int VALUE_CONNECTION_TIMEOUT_DEFAULT
      The value for PROPERTY_CONNECTION_TIMEOUT to indicate that the default timeout has to be used
      See Also:
  • Constructor Details

    • InetHtmlDocument

      public InetHtmlDocument()
      Creates an empty document and creates the default empty structure of an HTML Document
      Since:
      1.05
  • Method Details

    • isReady

      public static final boolean isReady()
      Checks for external preconditions
      Returns:
      true, if the preconditions are fulfilled
      Since:
      1.05
    • getStyleResolver

      public com.inet.html.css.StyleResolver getStyleResolver()
      Returns the style resolver, which is bound to this document to resolve the CSS styles
      Specified by:
      getStyleResolver in interface CssDocument
      Returns:
      the style resolver of this document
    • isLocked

      public boolean isLocked()
      Check if there is a write lock. This means the parsing is in process.
      Returns:
      true if there is a write lock
      Since:
      1.05
    • parse

      public void parse(Reader in, int pos) throws IOException, BadLocationException
      Parses the content read from in and stores the generated model into the the document doc starting at position pos
      Parameters:
      in - The HTML input
      pos - The position within the document to start inserting the elements
      Throws:
      IOException - Thrown the the input reader
      BadLocationException - Will be thrown if pos is not within the content range
      Since:
      1.05
    • getContentImpl

      protected final AbstractDocument.Content getContentImpl()
      Redirect the call of getContent().
      Returns:
      the content implementation of this document
      Since:
      1.05
    • getForeground

      public Color getForeground(Element elem)
      Returns the foreground color of an element
      Parameters:
      elem - the element to check
      Returns:
      the foreground color of an element
      Since:
      1.05
    • getBackground

      public Color getBackground(Element elem)
      Returns the background color of an element
      Parameters:
      elem - the element to check
      Returns:
      the background color of an element
      Since:
      1.05
    • getFontSize

      public static float getFontSize(Element elem)
      Returns the font size of an element
      Parameters:
      elem - The element to query
      Returns:
      The font size for elem in pixel
      Since:
      1.05
    • getFont

      public static Font getFont(Element elem)
      Returns the font of an element
      NOTE: This function is for model-purpose ONLY! If the returned font is to be used in some render context, use the functions of the HtmlRootView instead!
      Parameters:
      elem - The element to query
      Returns:
      The font object for elem
      Since:
      1.05
    • getFont

      public static Font getFont(Element elem, float size)
      Returns the font of an element.
      NOTE: This function is for model-purpose ONLY! If the returned font is to be used in some render context, use the functions of the HtmlRootView instead!
      Parameters:
      elem - The element to query
      size - The font size of this element
      Returns:
      The font object for elem
      Since:
      1.05
    • createBranchElement

      protected com.inet.html.InetHtmlDocument.BoxElement createBranchElement(Element parent, AttributeSet a)
      Overrides:
      createBranchElement in class HTMLDocument
    • createBranchElement

      protected com.inet.html.InetHtmlDocument.BoxElement createBranchElement(Element parent, Object name) throws IllegalArgumentException
      Create a branch element of the given type
      Parameters:
      parent - the parent element of the created element
      name - the HTML Tag of the element
      Returns:
      a fresh, new branch element
      Throws:
      IllegalArgumentException - Thrown in case there is no parent and the element to generate does not have the name HTML.Tag.HTML
      Since:
      1.05
    • createLeafElement

      protected com.inet.html.InetHtmlDocument.ContentElement createLeafElement(Element parent, AttributeSet a, int startOffs, int endOffs)
      Overrides:
      createLeafElement in class HTMLDocument
    • createLeafElement

      protected com.inet.html.InetHtmlDocument.ContentElement createLeafElement(Element parent, Object name, int startOffs, int endOffs)
      Creates a leaf InetHtmlDocument.ContentElement
      Parameters:
      parent - the parent element, must not be null
      name - the name of the element, recommended to be an HTML.Tag
      startOffs - the start offset
      endOffs - the end offset, must be > startOffs
      Returns:
      the element, never null
      Throws:
      IllegalArgumentException - in case the parent is null AND the name is not HTML in that case
      Since:
      1.09
    • createAnnonymousElement

      public AbstractDocument.BranchElement createAnnonymousElement(Element parent)
      Creates a implied paragraph element.
      NOTE: Does not change the document model and doesn't need a write lock
      Specified by:
      createAnnonymousElement in interface CssDocument
      Parameters:
      parent - the parent for the generated element
      Returns:
      a new anonymous branch element
    • insertAfterEnd

      public void insertAfterEnd(Element elem, String htmlText) throws BadLocationException, IOException
      Overrides:
      insertAfterEnd in class HTMLDocument
      Throws:
      BadLocationException
      IOException
    • insertHTML

      public void insertHTML(String html, int position)
      Insert the content of a HTML formated string at the given position
      Parameters:
      html - The content to insert
      position - insert offset
      Since:
      1.05
    • pasteHTML

      public void pasteHTML(String html, int start, int end)
      Paste a HTML content into a given selection range. This algorithm tries to find the common paragraph of the start and end position and pastes the HTML to this paragraph. Any content in between will be replaced. If start equals end, this is an insert.
      Parameters:
      html - the content to insert
      start - the start offset
      end - the end offset
      Since:
      1.05
    • pasteHTML

      public void pasteHTML(String html, int start, int end, Object sourceID)
      Paste a HTML content into a given selection range. This algorithm tries to find the common paragraph of the start and end position and pastes the HTML to this paragraph. Any content in between will be replaced. If start equals end, this is an insert.
      Parameters:
      html - the content to insert
      start - the start offset
      end - the end offset
      sourceID - the sourceID can be any object or null. The sourceID will be used to relate the content with it's global CSS. So, if there are several paste from the same source, it's global CSS can be reused. If this parameter is null, the inserted HTML will be regarded as document internal - in that case no additional edit-line will be inserted after the last block element of the insert.
      Since:
      1.05
    • insertAfterStart

      public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException
      Overrides:
      insertAfterStart in class HTMLDocument
      Throws:
      BadLocationException
      IOException
    • insertBeforeEnd

      public void insertBeforeEnd(Element elem, String htmlText) throws BadLocationException, IOException
      Overrides:
      insertBeforeEnd in class HTMLDocument
      Throws:
      BadLocationException
      IOException
    • insertBeforeStart

      public void insertBeforeStart(Element elem, String htmlText) throws BadLocationException, IOException
      Overrides:
      insertBeforeStart in class HTMLDocument
      Throws:
      BadLocationException
      IOException
    • insertString

      public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
      Specified by:
      insertString in interface Document
      Overrides:
      insertString in class AbstractDocument
      Throws:
      BadLocationException
    • performParagraphBreak

      public void performParagraphBreak(int pos)
      This function does what is in most cases expected if you press return. It starts new paragraphs or list items or splits these elements if required.
      This does obviously not work within table cells!
      Parameters:
      pos - the position to use for this split action
      Since:
      1.05
    • insertHRule

      public void insertHRule(int pos)
      A horizontal rule is a very special object. It is a monolithic block element, which splits the surrounding paragraph. If there is no paragraph, the content at this position has to be wrapped into a P.
      Parameters:
      pos - the position, to insert the HR
      Since:
      1.05
    • getLowerContentBoundary

      public int getLowerContentBoundary(int pos, Element topLevelParagraph)
      Find the next paragraph change in negative direction. A change is where getParagraph() would return another element or where the current paragraph ends.
      Parameters:
      pos - Start offset
      topLevelParagraph - the paragraph at the start position
      Returns:
      the position of the next paragraph change
      Since:
      1.05
    • getUpperContentBoundary

      public int getUpperContentBoundary(int pos, Element topLevelParagraph)
      Find the next paragraph change in positive direction. A change is where getParagraph() would return another element or where the current paragraph ends.
      Parameters:
      pos - Start offset
      topLevelParagraph - the paragraph at the start position
      Returns:
      the position of the next paragraph change
      Since:
      1.05
    • createCopy

      protected Element createCopy(Element from, int limitLeft, int limitRight, Element newParent)
      Copies all children from from which match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.
      NOTE: This function requires an enclosing write lock!
      Parameters:
      from - Element to copy from
      limitLeft - the lower positon limit for children
      limitRight - the upper position limit for children
      newParent - The parent of the newly created element(cannot be changed later on!)
      Returns:
      returns the copy of the element
      Since:
      1.05
    • createCopy

      protected Element createCopy(Element from, Element to, int limitLeft, int limitRight)
      Copies all children from from to to which match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.
      Parameters:
      from - Element to copy from
      to - Element to copy to
      limitLeft - the lower positon limit for children
      limitRight - the upper position limit for children
      Returns:
      returns the to element to support inline create&copy
      Since:
      1.05
    • createCopy

      protected Element createCopy(Element from, Element to, int limitLeft, int limitRight, int insertIndex)
      Copies all children from from to to which match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.
      NOTE: This function also works for exisiting to elements with children. The copied elements will be inserted at the specified index.
      This function does not change the content! The indices of the copied elements will still be the same!
      Parameters:
      from - Element to copy from
      to - Element to copy to
      limitLeft - the lower positon limit for children
      limitRight - the upper position limit for children
      insertIndex - The index where to insert the copied elements.
      Returns:
      returns the to element to support inline create&copy
      Since:
      1.05
    • remove

      public void remove(int offs, int len) throws BadLocationException
      Specified by:
      remove in interface Document
      Overrides:
      remove in class AbstractDocument
      Throws:
      BadLocationException
    • removeImpl

      public void removeImpl(int offs, int len, com.inet.html.InetHtmlDocument.EventList list) throws BadLocationException
      Implementation of remove, holds no WriteLock, fires no events, just doe's it's job
      Parameters:
      offs - start offset of the removal
      len - length of the removal
      list - the event list to register the changes
      Throws:
      BadLocationException - thrown if the range leaves the content range
      Since:
      1.05
    • getCharacterElement

      public Element getCharacterElement(int pos)
      Specified by:
      getCharacterElement in interface StyledDocument
      Overrides:
      getCharacterElement in class DefaultStyledDocument
    • getLength

      public int getLength()
      Returns the last possible offset in this document
      Specified by:
      getLength in interface Document
      Overrides:
      getLength in class AbstractDocument
      Returns:
      Returns the last possible offset in this document
      Since:
      1.05
    • getModelLength

      public int getModelLength()
      This is the length spanned by the model. It's 1 more than the getLength value and one less than the content.getLength value
      Returns:
      the length of the model
      Since:
      1.05
    • removeElement

      public void removeElement(AttributeSet selector, int start, int end, boolean keepStyles)
      Removes the first element found in the tree which matches the selector attributes. All children of this element will be moved one level up(to the parent of the element)
      Parameters:
      selector - the attributes which have to be matched
      start - start offset of the remove area
      end - end offset of the remove area
      keepStyles - if set to true, the document will try to keep all font-formatting styles, which are attached directly the remove element. Every special attribute will be dropped like HREF or NAME for instance.
      NOTE: May have unexpected side effects, if combined with an element, which spans a block
      Since:
      1.05
    • replace

      public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException
      Overrides:
      replace in class AbstractDocument
      Throws:
      BadLocationException
    • createDefaultRoot

      protected AbstractDocument.AbstractElement createDefaultRoot()
      Overrides:
      createDefaultRoot in class HTMLDocument
    • setBase

      public void setBase(URL base)
      Overrides:
      setBase in class HTMLDocument
    • getBase

      public URL getBase()
      Overrides:
      getBase in class HTMLDocument
    • fillAttributes

      protected void fillAttributes(Element root)
      Recursive descending function to get all attributes. This function is public so it may be called by the views to fill generated/splitted content-elements as well
      Parameters:
      root - The root element to get the attributes
      Since:
      1.05
    • checkInit

      public void checkInit(Element elem)
      Checks whether the attributes for this view already were set and if not, sets them. The Problem is setContentType create Views and elements without any content or parser action.
      Parameters:
      elem - The element to check.
      Since:
      1.05
    • addAttribute

      public void addAttribute(AttributeSet attrs, Object name, Object value)
      Adds the value to the attribute set if the value is not null.
      NOTE: This method does not fire document events. Thats why it shouldn't be called on documents which are currently displayed in an editor since the changes will not be reflected by the GUI.
      Parameters:
      attrs - The attribute set to modify
      name - The name of the attribute
      value - The value of the attribute
      Since:
      1.05
    • setDocType

      @Deprecated public void setDocType(int docType)
      Deprecated.
      As of JWebEngine 1.05 - Use getDocType() and the methods if DocType instead
      Set the document type (Version/type constant)
      Parameters:
      docType - document type (Version/type constant)
      Since:
      1.0
    • setDocVersion

      @Deprecated public void setDocVersion(float docVersion)
      Deprecated.
      As of JWebEngine 1.05 - Use getDocType() and the methods if DocType instead
      Sets the document version, typically 3.2 or 4.01
      Parameters:
      docVersion - the version and sub version
      Since:
      1.0
    • setDocVariant

      @Deprecated public void setDocVariant(int docVariant)
      Deprecated.
      As of JWebEngine 1.05 - Use getDocType() and the methods if DocType instead
      Sets the variant of this document
      Parameters:
      docVariant - the variant constant
      Since:
      1.0
      See Also:
    • getHtmlVersion

      @Deprecated public float getHtmlVersion()
      Deprecated.
      As of JWebEngine 1.05 - Use getDocType() and the methods if DocType instead
      Returns the HTML version of this document depending on the defined version and variant
      Returns:
      the html version and sub version
      Since:
      1.0
    • getDocType

      public com.inet.html.parser.DocType getDocType()
      Returns the document type definition for the current document
      Returns:
      the document type definition for the current document, never null
      Since:
      1.05
    • getParagraphElement

      public Element getParagraphElement(int pos, Element root, boolean deepSearch)
      Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf. This method will search for the deepest paragraph element in the model tree!
      Parameters:
      pos - the starting offset >= 0
      root - The element to start from
      deepSearch - if true the deepest block element will be returned, hence the first
      Returns:
      the element
      Since:
      1.05
    • getNextParagraphElement

      public Element getNextParagraphElement(int pos, Element root)
      Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf. This method will search for the next deeper paragraph in the model tree
      Parameters:
      pos - the starting offset >= 0
      root - The element to start from
      Returns:
      the next paragraph or null, if there isn't any paragraph below root
      Since:
      1.05
    • getParagraphElement

      public Element getParagraphElement(int pos)
      Specified by:
      getParagraphElement in interface StyledDocument
      Overrides:
      getParagraphElement in class DefaultStyledDocument
    • getBlockStart

      public int getBlockStart(int pos)
      Returns the position where the content block at this position starts. This can be the start of the implied at this position as well.
      Parameters:
      pos - the offset to start searching
      Returns:
      the start offset of the current content parts
      Since:
      1.05
    • setCharacterAttributes

      public void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)
      Sets the attributes for characters.
      This function tries to set the attributes, which influence the inline content. For a HTML 4 conform type of document, this may result in a mix of inserting spans an changing attributes.
      Specified by:
      setCharacterAttributes in interface StyledDocument
      Overrides:
      setCharacterAttributes in class DefaultStyledDocument
      Parameters:
      offset - Where to start changing the attributes
      length - Length of the area where to change
      s - A set of attributes which should be applied to the content
      replace - If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY within the range of the change(to avoid side effects)
      Since:
      1.05
    • setCharacterAttributes

      public void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace, boolean forceStacking)
      Sets the attributes for characters.
      This function tries to set the attributes, which influence the inline content. For a HTML 4 conform type of document, this may result in a mix of inserting spans an changing attributes.
      Parameters:
      offset - Where to start changing the attributes
      length - Length of the area where to change
      s - A set of attributes which should be applied to the content
      replace - If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY within the range of the change(to avoid side effects)
      forceStacking - if set to true, it overrides the inlineCompatibleMode and forces the method to create new inline elements on top of the existing ones instead of re-using elements. This may break inline-Boxes but is an efficient way to create new, unstyled inline elements.
      Since:
      1.05
    • findNextBlank

      public int findNextBlank(int startOffset, boolean directionForward)
      Tries to find the next space or line break in the specified direction
      Parameters:
      startOffset - where to start
      directionForward - true to search forward, false to search backwards
      Returns:
      the offset of the next blank
      Since:
      1.05
    • setParagraphAttributes

      public void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
      Sets attributes for a paragraph.
      Unless the original implementation this method tries to applie the new attributes too the deepest paragraph element in the document structure. If there are nested paragraphs at a given position this will apply to the nested ones!
      Specified by:
      setParagraphAttributes in interface StyledDocument
      Overrides:
      setParagraphAttributes in class HTMLDocument
      Parameters:
      offset - the offset into the paragraph (must be at least 0)
      length - the number of characters affected (must be at least 0)
      s - the attributes
      replace - whether to replace existing attributes, or merge them
      Since:
      1.05
    • setElementAttributes

      public void setElementAttributes(Element elem, AttributeSet attributes, boolean replace)
      Directly modifies the attributes of an element an fires the required event for the views
      Parameters:
      elem - the element to be modified
      attributes - the attributes to set
      replace - if true, the old attributes will be removed
      Since:
      1.05
    • changeIndent

      public void changeIndent(int step, int offset, int length, boolean increase)
      Modifies the indent of a paragraph or list item. For normal blocks this will modify the margin-left setting. List items will be moved to another list level, if possible.
      NOTE: This method will operate on all block which intersect the area from offset to offset+length.
      Parameters:
      step - The step size by which the margin-left will be modified
      offset - The start position of the modification
      length - The length of the modification
      increase - true, if the indent is to be increased, false otherwise (required for lists)
      Since:
      1.05
    • changeListStatus

      public void changeListStatus(int offset, int length, boolean numberedList) throws BadLocationException
      This functions performs, what on may expect when clicking on a list button. It's behavior depends on the selection. If there is a normal paragraph, it will be changed to a list. If there is a list item of the specified type, it will be changed to a normal paragraph. If there is a List item of a different Type, it will be changed to the current type. This method works for selections as well.
      Parameters:
      offset - Start offset
      length - Length of the selection, may be 0
      numberedList - Set to true, if a numbered list should be generated, false if a unordered list is to be generated.
      Throws:
      BadLocationException - possibly thrown on model errors
      Since:
      1.05
    • getEmbeddedImages

      public EmbeddedImage[] getEmbeddedImages()
      Returns a list with the reference to all images used in IMG-Tags in this document. Every embedded image will come with url=null on the first call, every linked image will have an URL set, but no image object.
      NOTE: This method does not find background images!
      Returns:
      A list of all images used in this document of null, if none were used.
      Since:
      1.05
    • insertImage

      public void insertImage(Image image, int pos, File location)
      Inserts an image, without requiring an URL.
      Parameters:
      image - The image to insert
      pos - the position, to insert the image.
      location - the file location of the image (OPTIONAL)
      Since:
      1.05
    • insertImage

      public void insertImage(Image image, int pos, String alt, File location)
      Inserts an image, without requiring an URL.
      Parameters:
      image - The image to insert
      pos - the position, to insert the image.
      alt - the ALT-Text, if any
      location - the file location of the image, if any (OPTIONAL)
      Since:
      1.05
    • fireChangedUpdate

      protected void fireChangedUpdate(DocumentEvent e)
      Overrides:
      fireChangedUpdate in class HTMLDocument
    • fireInsertUpdate

      protected void fireInsertUpdate(DocumentEvent e)
      Overrides:
      fireInsertUpdate in class AbstractDocument
    • fireRemoveUpdate

      protected void fireRemoveUpdate(DocumentEvent e)
      Overrides:
      fireRemoveUpdate in class AbstractDocument
    • setAllowInternalImages

      public void setAllowInternalImages(boolean allowInternalImages)
      Set to false to block pasted images.
      Parameters:
      allowInternalImages - true to allow pasted images, false otherwise
      Since:
      1.05
    • isAllowInternalImages

      public boolean isAllowInternalImages()
      Returns whether pasted images will be accepted
      Returns:
      true if pasted images will be displayed, false otherwise
      Since:
      1.05
    • getDocumentProperties

      public Dictionary<Object,Object> getDocumentProperties()
      Overrides:
      getDocumentProperties in class AbstractDocument
    • setDocumentProperties

      public void setDocumentProperties(Dictionary<Object,Object> x)
      Overrides:
      setDocumentProperties in class AbstractDocument
    • setDocumentProperty

      public void setDocumentProperty(Object key, Object value)
      Adds or sets a document property
      Parameters:
      key - the key object
      value - the value for this key
      Since:
      1.05
    • getConfiguration

      public InetHtmlConfiguration getConfiguration()
      Returns the currently used configuration.
      Returns:
      Returns the currently used configuration.
      Since:
      1.05
    • getCachedString

      public static String getCachedString(String value)
      This function guarantees to return always the same object for a string.
      May be used to hash class or id values
      Parameters:
      value - the string to find
      Returns:
      an object which is always the same for lexicaly equal strings
      Since:
      1.05
    • getStyleNames

      public Enumeration<?> getStyleNames()
      Fetches a list of the currently used styles. There are upt to three logical style-table names in use:
      DEFAULT for the editors default values USERAGENT for the current user agent styles(which may override the defaults) INLINE for any style information described or linked by the current page
      Overrides:
      getStyleNames in class DefaultStyledDocument
      Returns:
      a list with the names of all used style tables
      Since:
      1.0
    • getStyleSheet

      public com.inet.html.css.Styles getStyleSheet(String nm)
      Returns the style with the given name. The name is the logical name of the styles table, not the name of any linked stylesheet.
      NOTE: It is recommended not to change the DEFAULT-Table! Use USERAGENT instead.
      Parameters:
      nm - the name to find
      Returns:
      a styles table or null
      Since:
      1.05
    • getSiteCount

      public int getSiteCount()
      The site counter is increased every time the model is cleared. This happens, if a new page is set or the complete content has been replaced.
      Required, if model changes and layout/painting will run in different threads!
      Specified by:
      getSiteCount in interface CssDocument
      Returns:
      the current site number
    • getRevision

      public int getRevision()
      The revision increases with every change, that causes an update event.
      Required, if model changes and layout/painting will run in different threads!
      Specified by:
      getRevision in interface CssDocument
      Returns:
      the current revision number
    • getIterator

      public HTMLDocument.Iterator getIterator(HTML.Tag t)
      Overrides:
      getIterator in class HTMLDocument
    • getURLwithReferrer

      public URL getURLwithReferrer(URL url)
      Returns an URL with the referrer set. This is relevant for some website that block direct access to resource
      Parameters:
      url - the source URL
      Returns:
      an equal URL with an additional referrer header field
      Since:
      1.05
    • readStylesOfVirtualTags

      public boolean readStylesOfVirtualTags()
      This flag modifies the the behavior of the default StyleResolver.
      If it returns true, the StyleResolver will read the styles of the virtual elements CONTENT and IMPLIED as well. If false is returned, the styles of these elements will be ignored and it's parents will be searched.
      NOTE: This is important for document structures, which set the styles by the tree structure(like HTML) rather than by the leaf elements(like Javas StyledDocument)
      Specified by:
      readStylesOfVirtualTags in interface CssDocument
      Returns:
      true, if the styles of CONTENT and IMPLIED will be respected, if false they will be ignored
    • getEncoding

      public static String getEncoding(ChangedCharSetException charSetEx)
      Tries to find the charset name in a html header field. You need to IgnoreCharsetDirective to prevent this exception doc.putProperty( "IgnoreCharsetDirective", Boolean.TRUE );
      Parameters:
      charSetEx - exception that occur on parse(Reader)
      Returns:
      the charset name
      Since:
      1.09
    • getTimeoutProvider

      public InetHtmlDocument.TimeoutProvider getTimeoutProvider()
      Returns the timeout provider to be used for outgoing connections of this document.
      Returns:
      the timeout provider to be used or null if there is no timeout defined.
      Since:
      JWebEngine 1.12
    • getConnectionTimeout

      @Deprecated public int getConnectionTimeout(URL url)
      Deprecated.
      as of JWebEngine 1.12 - use
      Returns the timeout to be used when connecting to an URL destination.
      Parameters:
      url - the URL to connect to
      Returns:
      • values > 0 -> the timeout in milliseconds
      • value == 0 -> infinite timeout
      • value == null or value == VALUE_CONNECTION_TIMEOUT_DEFAULT -> do no set any timeout, use connection default
      • values < 0 -> DO NOT CONNECT