public abstract class TextWorld
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
TextWorld.TextItem
Represents the "current item" as String, and includes a representation of
the beginning and ending of the item in the main text.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<java.lang.String> |
tokenDictionary
Set of a strings that can be coupled to via scalar couplings.
|
Constructor and Description |
---|
TextWorld()
Constructs an instance of TextWorld.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(TextListener listener)
Add a listener.
|
void |
addText(java.lang.String newText)
Add a text to the end of the underling text object.
|
void |
addWordToTokenDictionary(java.lang.String word)
Add a word to the dictionary.
|
void |
fireCurrentItemChanged(TextWorld.TextItem newItem)
Notify listeners that the caret position has changed.
|
void |
fireDictionaryChangedEvent()
Notify listeners that the dictionary has changed.
|
void |
firePositionChangedEvent()
Notify listeners that the caret position has changed.
|
void |
firePrefsChangedEvent()
Notify listeners that preferences have changed.
|
void |
fireTextChangedEvent()
Notify listeners that the text has changed.
|
TextWorld.TextItem |
getCurrentItem() |
java.awt.Color |
getHighlightColor() |
int |
getLastPosition() |
int |
getPosition() |
java.lang.String |
getText() |
java.util.Set<java.lang.String> |
getTokenDictionary() |
(package private) static com.thoughtworks.xstream.XStream |
getXStream()
Returns a properly initialized xstream object.
|
void |
loadTokenDictionary(java.lang.String[][] newDict)
Reset the dictionary (e.g.
|
java.lang.String |
previewNextChar()
Returns a "preview" of the next character in the world.
|
protected java.lang.Object |
readResolve()
Standard method call made to objects after they are deserialized.
|
void |
removeListener(TextListener listener)
Remove a listener.
|
void |
setCurrentItem(TextWorld.TextItem currentItem) |
void |
setHighlightColor(java.awt.Color highlightColor) |
void |
setPosition(int newPosition) |
void |
setPosition(int newPosition,
boolean fireEvent)
Set position.
|
void |
setText(java.lang.String text) |
void |
setText(java.lang.String text,
boolean fireEvent)
Set text, and fire an event if the fireEvent flag is set.
|
abstract void |
update()
Advance the position in the text, and update the current item.
|
protected java.util.Set<java.lang.String> tokenDictionary
public abstract void update()
public void addText(java.lang.String newText)
newText
- the text to addpublic void addListener(TextListener listener)
listener
- the listener to addpublic void removeListener(TextListener listener)
listener
- the listener to removepublic java.awt.Color getHighlightColor()
public void setHighlightColor(java.awt.Color highlightColor)
highlightColor
- the highlightColor to setpublic void fireTextChangedEvent()
public void fireDictionaryChangedEvent()
public void firePrefsChangedEvent()
public void firePositionChangedEvent()
public void fireCurrentItemChanged(TextWorld.TextItem newItem)
newItem
- public java.lang.String getText()
public void setText(java.lang.String text)
text
- the text to setpublic void setText(java.lang.String text, boolean fireEvent)
text
- the text to setfireEvent
- whether or not to fire an eventpublic int getPosition()
public void setPosition(int newPosition)
newPosition
- the position to setpublic void setPosition(int newPosition, boolean fireEvent)
newPosition
- new position to setfireEvent
- whether to fire eventpublic int getLastPosition()
public TextWorld.TextItem getCurrentItem()
public void setCurrentItem(TextWorld.TextItem currentItem)
currentItem
- the currentItem to setpublic java.lang.String previewNextChar()
public void loadTokenDictionary(java.lang.String[][] newDict)
newDict
- the new dictionary entriespublic java.util.Set<java.lang.String> getTokenDictionary()
public void addWordToTokenDictionary(java.lang.String word)
word
- the word to addstatic com.thoughtworks.xstream.XStream getXStream()
protected java.lang.Object readResolve()