Package kiyut.sketsa.canvas.text

## Class TextDocument

- java.lang.Object
- - kiyut.sketsa.canvas.text.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

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected VectorCanvas` | `canvas` |
    `protected org.w3c.dom.svg.SVGTextElement` | `element` |
    `protected EventListenerList` | `listenerList` |
    `static AttributedCharacterIterator.Attribute` | `TEXT_COMPOUND_ID` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TextDocument()` | Creates a new instance of TextDocument

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addTextListener​(TextListener listener)` |
    `protected void` | `fireChangedUpdate​(TextEvent e)` | Notifies all listeners that have registered interest for notification on this event type.
    `protected void` | `fireInsertUpdate​(TextEvent e)` | Notifies all listeners that have registered interest for notification on this event type.
    `protected void` | `fireRemoveUpdate​(TextEvent e)` | Notifies all listeners that have registered interest for notification on this event type.
    `int` | `getLength()` | Returns number of characters of content currently in the document.
    `org.w3c.dom.svg.SVGElement` | `getSVGElement​(int offset)` | Return `SVGElement` for the particular offset
    `org.w3c.dom.svg.SVGTextElement` | `getSVGTextElement()` |
    `abstract void` | `insertNewLine​(int offset)` |
    `abstract void` | `insertString​(int offset, String str)` | Insert String at the specified offset
    `abstract void` | `remove​(int offset, int len)` | Removes a portion of the content of the document.
    `void` | `removeTextListener​(TextListener listener)` |
    `abstract void` | `replace​(int offset, int len, String str)` |
    `abstract void` | `setCharacterAttributes​(int offset, int length, Map<String,​String> attrMap)` | It just simply delegate to setCharacterAttributesImpl(int, int, Map)
    `void` | `setSVGTextElement​(org.w3c.dom.svg.SVGTextElement element)` |
    `void` | `setVectorCanvas​(VectorCanvas canvas)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TEXT_COMPOUND_ID

          public static final AttributedCharacterIterator.Attribute TEXT_COMPOUND_ID

    - #### canvas

          protected VectorCanvas canvas

    - #### element

          protected org.w3c.dom.svg.SVGTextElement element

    - #### listenerList

          protected EventListenerList listenerList

  - ### 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

    - #### replace

          public abstract void replace​(int offset,
                                       int len,
                                       String str)
                                throws BadLocationException

      Throws:
        `BadLocationException`

    - #### insertNewLine

          public abstract void insertNewLine​(int offset)
                                      throws BadLocationException

      Throws:
        `BadLocationException`

    - #### 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