Package kiyut.sketsa.canvas.text

## Class DefaultTextDocument

- java.lang.Object
- - kiyut.sketsa.canvas.text.TextDocument
  - - kiyut.sketsa.canvas.text.DefaultTextDocument

-     public class DefaultTextDocument
      extends TextDocument

  Author:
    tonny

- - ### Field Summary

    - ### Fields inherited from class kiyut.sketsa.canvas.text.TextDocument

      `canvas, element, listenerList, TEXT_COMPOUND_ID`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultTextDocument()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected Text` | `getTextNode​(AttributedCharacterIterator aci, int offset)` |
    `void` | `insertNewLine​(int offset)` |
    `void` | `insertString​(int offset, String str)` | Insert String at the specified offset
    `void` | `remove​(int offset, int len)` | Removes a portion of the content of the document.
    `void` | `replace​(int offset, int len, String str)` | It is a simple call to `remove(int, int)` then `insertString(int,String)`
    `void` | `setCharacterAttributes​(int offset, int length, Map<String,​String> attrMap)` | It just simply delegate to setCharacterAttributesImpl(int, int, Map)
    `protected void` | `setCharacterAttributesImpl​(int offset, int length, Map<String,​String> attrMap)` | Changes the content element attributes used for the given range of existing content in the document.

    - ### Methods inherited from class kiyut.sketsa.canvas.text.TextDocument

      `addTextListener, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, getLength, getSVGElement, getSVGTextElement, removeTextListener, setSVGTextElement, setVectorCanvas`

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

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

- - ### Constructor Detail

    - #### DefaultTextDocument

          public DefaultTextDocument()

  - ### Method Detail

    - #### getTextNode

          protected Text getTextNode​(AttributedCharacterIterator aci,
                                     int offset)
                              throws BadLocationException

      Throws:
        `BadLocationException`

    - #### insertString

          public void insertString​(int offset,
                                   String str)
                            throws BadLocationException

      Insert String at the specified offset
      Specified by:
        `insertString` in class `TextDocument`
      Parameters:
        `offset` - the starting offset >= 0
        `str` - String Value
      Throws:
        `BadLocationException` - if offset was not a valid part of the document

    - #### remove

          public void remove​(int offset,
                             int len)
                      throws BadLocationException

      Removes a portion of the content of the document.
      Specified by:
        `remove` in class `TextDocument`
      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 void replace​(int offset,
                              int len,
                              String str)
                       throws BadLocationException

      It is a simple call to `remove(int, int)` then `insertString(int,String)`
      Specified by:
        `replace` in class `TextDocument`
      Parameters:
        `offset` - the offset
        `len` - the len
        `str` - the String
      Throws:
        `BadLocationException` - if offset is not valid

    - #### insertNewLine

          public void insertNewLine​(int offset)
                             throws BadLocationException

      Specified by:
        `insertNewLine` in class `TextDocument`
      Throws:
        `BadLocationException`

    - #### setCharacterAttributes

          public void setCharacterAttributes​(int offset,
                                             int length,
                                             Map<String,​String> attrMap)
                                      throws BadLocationException

      It just simply delegate to setCharacterAttributesImpl(int, int, Map)
      Specified by:
        `setCharacterAttributes` in class `TextDocument`
      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 is not valid
      See Also:
        `setCharacterAttributesImpl(int, int, Map)`

    - #### setCharacterAttributesImpl

          protected void setCharacterAttributesImpl​(int offset,
                                                    int length,
                                                    Map<String,​String> attrMap)
                                             throws BadLocationException

      Changes the content element attributes used for the given range of existing content in the document. All of the attributes defined in the given Attributes argument are applied to the given range. This method can be used to completely remove all content level attributes for the given range by giving an Attributes argument that has no attributes defined and setting replace to true.
      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 is not valid