Class TextDocument

  • Direct Known Subclasses:
    DefaultTextDocument

    public abstract class TextDocument
    extends Object
    The TextDocument is a container for SVGTextElement that serves as the model for VectorCanvas text editing capability.
    Author:
    Kiyut
    • Constructor Detail

      • TextDocument

        public TextDocument()
        Creates a new instance of TextDocument
    • Method Detail

      • setSVGTextElement

        public void setSVGTextElement​(org.w3c.dom.svg.SVGTextElement element)
      • setVectorCanvas

        public void setVectorCanvas​(VectorCanvas canvas)
      • getSVGTextElement

        public org.w3c.dom.svg.SVGTextElement getSVGTextElement()
      • addTextListener

        public void addTextListener​(TextListener listener)
      • removeTextListener

        public void removeTextListener​(TextListener listener)
      • fireInsertUpdate

        protected void fireInsertUpdate​(TextEvent e)
        Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
        Parameters:
        e - the event
        See Also:
        EventListenerList
      • fireChangedUpdate

        protected void fireChangedUpdate​(TextEvent e)
        Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
        Parameters:
        e - the event
        See Also:
        EventListenerList
      • fireRemoveUpdate

        protected void fireRemoveUpdate​(TextEvent e)
        Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
        Parameters:
        e - the event
        See Also:
        EventListenerList
      • getLength

        public int getLength()
        Returns number of characters of content currently in the document.
        Returns:
        number of characters of content currently in the document.
      • getSVGElement

        public org.w3c.dom.svg.SVGElement getSVGElement​(int offset)
        Return SVGElement for the particular offset
        Parameters:
        offset - The offset from the beginning >= 0
        Returns:
        SVGElement for the particular offset
      • insertString

        public abstract void insertString​(int offset,
                                          String str)
                                   throws BadLocationException
        Insert String at the specified offset
        Parameters:
        offset - the starting offset >= 0
        str - String Value
        Throws:
        BadLocationException - if offset was not a valid part of the document
      • remove

        public abstract void remove​(int offset,
                                    int len)
                             throws BadLocationException
        Removes a portion of the content of the document.
        Parameters:
        offset - The offset from the beginning >= 0
        len - The number of characters to remove >= 0
        Throws:
        BadLocationException - if offset was not a valid part of the document
      • setCharacterAttributes

        public abstract void setCharacterAttributes​(int offset,
                                                    int length,
                                                    Map<String,​String> attrMap)
                                             throws BadLocationException
        It just simply delegate to setCharacterAttributesImpl(int, int, Map)
        Parameters:
        offset - the start of the change >= 0, inclusive
        length - the length of the change >= 0, exclusive
        attrMap - the non-null attributes to change to. Any attributes defined will be applied to the text for the given range.
        Throws:
        BadLocationException - if offset was not a valid part of the document