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 TextgetTextNode(AttributedCharacterIterator aci, int offset)voidinsertNewLine(int offset)voidinsertString(int offset, String str)Insert String at the specified offsetvoidremove(int offset, int len)Removes a portion of the content of the document.voidreplace(int offset, int len, String str)It is a simple call toremove(int, int)theninsertString(int,String)voidsetCharacterAttributes(int offset, int length, Map<String,String> attrMap)It just simply delegate to setCharacterAttributesImpl(int, int, Map)protected voidsetCharacterAttributesImpl(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
-
-
-
-
Method Detail
-
getTextNode
protected Text getTextNode(AttributedCharacterIterator aci, int offset) throws BadLocationException
- Throws:
BadLocationException
-
insertString
public void insertString(int offset, String str) throws BadLocationExceptionInsert String at the specified offset- Specified by:
insertStringin classTextDocument- Parameters:
offset- the starting offset >= 0str- String Value- Throws:
BadLocationException- if offset was not a valid part of the document
-
remove
public void remove(int offset, int len) throws BadLocationExceptionRemoves a portion of the content of the document.- Specified by:
removein classTextDocument- Parameters:
offset- The offset from the beginning >= 0len- 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 BadLocationExceptionIt is a simple call toremove(int, int)theninsertString(int,String)- Specified by:
replacein classTextDocument- Parameters:
offset- the offsetlen- the lenstr- the String- Throws:
BadLocationException- if offset is not valid
-
insertNewLine
public void insertNewLine(int offset) throws BadLocationException- Specified by:
insertNewLinein classTextDocument- Throws:
BadLocationException
-
setCharacterAttributes
public void setCharacterAttributes(int offset, int length, Map<String,String> attrMap) throws BadLocationExceptionIt just simply delegate to setCharacterAttributesImpl(int, int, Map)- Specified by:
setCharacterAttributesin classTextDocument- Parameters:
offset- the start of the change >= 0, inclusivelength- the length of the change >= 0, exclusiveattrMap- 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 BadLocationExceptionChanges 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, inclusivelength- the length of the change >= 0, exclusiveattrMap- 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
-
-