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 VectorCanvascanvasprotected org.w3c.dom.svg.SVGTextElementelementprotected EventListenerListlistenerListstatic AttributedCharacterIterator.AttributeTEXT_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 voidaddTextListener(TextListener listener)protected voidfireChangedUpdate(TextEvent e)Notifies all listeners that have registered interest for notification on this event type.protected voidfireInsertUpdate(TextEvent e)Notifies all listeners that have registered interest for notification on this event type.protected voidfireRemoveUpdate(TextEvent e)Notifies all listeners that have registered interest for notification on this event type.intgetLength()Returns number of characters of content currently in the document.org.w3c.dom.svg.SVGElementgetSVGElement(int offset)ReturnSVGElementfor the particular offsetorg.w3c.dom.svg.SVGTextElementgetSVGTextElement()abstract voidinsertNewLine(int offset)abstract voidinsertString(int offset, String str)Insert String at the specified offsetabstract voidremove(int offset, int len)Removes a portion of the content of the document.voidremoveTextListener(TextListener listener)abstract voidreplace(int offset, int len, String str)abstract voidsetCharacterAttributes(int offset, int length, Map<String,String> attrMap)It just simply delegate to setCharacterAttributesImpl(int, int, Map)voidsetSVGTextElement(org.w3c.dom.svg.SVGTextElement element)voidsetVectorCanvas(VectorCanvas canvas)
-
-
-
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
-
-
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)
ReturnSVGElementfor the particular offset- Parameters:
offset- The offset from the beginning >= 0- Returns:
SVGElementfor the particular offset
-
insertString
public abstract void insertString(int offset, String str) throws BadLocationExceptionInsert String at the specified offset- Parameters:
offset- the starting offset >= 0str- String Value- Throws:
BadLocationException- if offset was not a valid part of the document
-
remove
public abstract void remove(int offset, int len) throws BadLocationExceptionRemoves a portion of the content of the document.- 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 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 BadLocationExceptionIt just simply delegate to setCharacterAttributesImpl(int, int, Map)- 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 was not a valid part of the document
-
-