|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.nexttext.Book
public class Book
The container for the NextText for Processing data and window.
The PApplet which uses NextText uses this as its primary point of entry into the NextText data. Most importantly, it contains the TextObjects which hold the core text data, and the TextRenderer and window to actually draw the stuff.
The Book has its own step(), draw(), and stepAndDraw() methods which replace the Simulator loop found in regular NextText applications.
Any updates to the TextObject tree must be synchronized on the Book.
Field Summary | |
---|---|
static KeyboardDefault |
keyboard
|
static MouseDefault |
mouse
|
static TextObjectBuilder |
toBuilder
|
Constructor Summary | |
---|---|
Book(processing.core.PApplet p)
Instantiates the Book with a default renderer. |
|
Book(processing.core.PApplet p,
processing.core.PGraphics g)
Instatiates the Book with specific PGraphics object. |
|
Book(processing.core.PApplet p,
processing.core.PGraphics g,
java.lang.String rendererType)
Instantiates the Book. |
|
Book(processing.core.PApplet p,
java.lang.String rendererType)
Instantiates the Book with a specific renderer. |
Method Summary | |
---|---|
void |
addBehaviour(AbstractBehaviour b)
Adds a Behaviour to the Book. |
Behaviour |
addGlyphBehaviour(AbstractAction action)
Adds the given Action to the list of Behaviours applied to new TextObjectGlyphs. |
void |
addGlyphBehaviour(AbstractBehaviour b)
Adds the given Behaviour to the list of Behaviours applied to new TextObjectGlyphs. |
Behaviour |
addGroupBehaviour(AbstractAction action)
Adds the given Action to the list of Behaviours applied to new TextObjectGroups. |
void |
addGroupBehaviour(AbstractBehaviour b)
Adds the given Behaviour to the list of Behaviours applied to new TextObjectGroups. |
TextPage |
addPage(java.lang.String pageName)
Create and add a named TextPage to the Book |
TextPage |
addPage(java.lang.String name,
TextPage p)
Add a named page to the book |
TextPage |
addPage(TextPage p)
Add a page to the book without specifying a name. |
TextObjectGroup |
addText(java.lang.String text,
int x,
int y)
Builds a tree of TextObjects from the given string, at the specified location, using the stroke and fill colors set in the PApplet. |
TextObjectGroup |
addText(java.lang.String text,
int x,
int y,
int lineLength)
Builds a tree of TextObjects from the given string, at the specified location, using the stroke and fill colors set in the PApplet. |
TextObjectGroup |
addText(java.lang.String text,
int x,
int y,
int lineLength,
java.lang.String pageName)
Builds a tree of TextObjects on the given Page from the given string, at the specified location, using the stroke and fill colors set in the PApplet. |
TextObjectGroup |
addText(java.lang.String text,
int x,
int y,
java.lang.String pageName)
Builds a tree of TextObjects on the given Page from the given string, at the specified location, using the stroke and fill colors set in the PApplet. |
Behaviour |
addWordBehaviour(AbstractAction action)
Adds the given Action to the list of Behaviours applied to new words. |
void |
addWordBehaviour(AbstractBehaviour b)
Adds the given Behaviour to the list of Behaviours applied to new words. |
void |
attachText(TextObject to)
|
void |
attachText(TextObject to,
java.lang.String pageName)
|
void |
clear()
Removes all the TextObjects from all the TextPages in the Book, except for all the TextObjectRoots. |
void |
clearPage(java.lang.String pageName)
Removes all the TextObjects from the given TextPage, except for the TextObjectRoot. |
void |
draw()
Renders a frame. |
void |
drawPage(java.lang.String pageName)
Renders the given page for this frame. |
java.util.List<AbstractBehaviour> |
getBehaviourList()
Returns the BehaviourList |
long |
getFrameCount()
The frame number, incremented each frame by the Simulator. |
int |
getIndent()
Get paragraph indentation. |
int |
getIndentStyle()
Get the paragraph indentation style. |
InputManager |
getInputs()
Returns the Input Manager |
float |
getLineHeight()
Deprecated. |
int |
getLineSpacing()
Get the line spacing of the text. |
TextPage |
getPage(java.lang.String name)
Get a named page from the book |
java.util.Collection<TextPage> |
getPages()
Returns the page set |
TextPageRenderer |
getRenderer()
Returns the page renderer |
int |
getSpaceOffset()
Get the space offset. |
SpatialList |
getSpatialList()
Returns the Spatial List |
TextObjectRoot |
getTextRoot()
Get the root of the TextObject hierarchy. |
int |
getTracking()
Get the tracking of the text. |
float |
getTrackingOffset()
Deprecated. |
void |
incrementFrameCount()
The frame number, incremented each frame by the Simulator. |
static java.awt.Font |
loadFontFromPFont(processing.core.PFont pf)
|
void |
log(java.lang.String message)
Log a message. |
void |
log(java.lang.String message,
java.lang.Throwable t)
|
void |
removeAllGlyphBehaviours()
Removes all Behaviours from the list of Behaviours applied to new TextObjectGlyphs. |
void |
removeAllGroupBehaviours()
Removes all Behaviours from the list of Behaviours applied to new TextObjectGroups. |
void |
removeAllWordBehaviours()
Removes all Behaviours from the list of Behaviours applied to new word. |
void |
removeBehaviour(AbstractBehaviour b)
Removes a Behaviour from the Book. |
void |
removeChildren(TextObjectGroup to)
Removes the children of this textObject from the book |
void |
removeGlyphBehaviour(AbstractBehaviour b)
Removes the given Behaviour from the list of Behaviours applied to new TextObjectGlyphs. |
void |
removeGroupBehaviour(AbstractBehaviour b)
Removes the given Behaviour from the list of Behaviours applied to new TextObjectGroups. |
void |
removeObject(TextObject to)
Remove a text object and any children from the tree. |
void |
removeQueuedObjects()
Removes all objects that have been marked for deletion. |
void |
removeWordBehaviour(AbstractBehaviour b)
Removes the given Behaviour from the list of Behaviours applied to new words. |
void |
setIndent(int indent)
Set the paragraph indentation using normal style. |
void |
setIndent(int indent,
int style)
Set the paragraph indentation. |
void |
setLineHeight(float d)
Deprecated. |
void |
setLineSpacing(int spacing)
Set the line spacing of the text. |
void |
setLogger(java.io.PrintWriter pw)
Specify a PrintWriter to which all log messages will be written. |
void |
setSpaceOffset(int space)
Set the space offset. |
void |
setTracking(int d)
Set the tracking of the text. |
void |
setTrackingOffset(float d)
Deprecated. |
void |
step()
Applies all active behaviours. |
void |
stepAndDraw()
Goes through a full iteration of the Book loop, i.e. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static TextObjectBuilder toBuilder
public static MouseDefault mouse
public static KeyboardDefault keyboard
Constructor Detail |
---|
public Book(processing.core.PApplet p)
p
- the parent PAppletpublic Book(processing.core.PApplet p, java.lang.String rendererType)
p
- the parent PAppletrendererType
- the type of renderer to use, can be JAVA2D or OPENGLpublic Book(processing.core.PApplet p, processing.core.PGraphics g)
p
- the parent PAppletg
- the PGraphics object to render topublic Book(processing.core.PApplet p, processing.core.PGraphics g, java.lang.String rendererType)
p
- the parent PAppletrendererType
- the type of renderer to use, can be JAVA2D or OPENGLMethod Detail |
---|
public long getFrameCount()
public void incrementFrameCount()
public void removeObject(TextObject to)
This method will:
The object is not removed immediately, it is removed prior to starting the next simulator run. This means that behaviours can safely call this method without worrying that the object will disappear and mess up other behaviours in the chain.
public void removeQueuedObjects()
Do not call this method while iterating over the TextObjectRoot for synchronization reasons.
public void step()
This code is adapted from Simulator.run().
public void draw()
public void drawPage(java.lang.String pageName)
pageName
- the name of the Page to renderpublic void stepAndDraw()
public static java.awt.Font loadFontFromPFont(processing.core.PFont pf)
public TextObjectGroup addText(java.lang.String text, int x, int y)
text
- the String to create the TextObjectGroup fromx
- the x-coordinate of the created TextObjectGroupy
- the y-coordinate of the created TextObjectGroup
public TextObjectGroup addText(java.lang.String text, int x, int y, java.lang.String pageName)
text
- the String to create the TextObjectGroup fromx
- the x-coordinate of the created TextObjectGroupy
- the y-coordinate of the created TextObjectGrouppageName
- the name of the Page to build on
public TextObjectGroup addText(java.lang.String text, int x, int y, int lineLength)
text
- the String to create the TextObjectGroup fromx
- the x-coordinate of the created TextObjectGroupy
- the y-coordinate of the created TextObjectGrouplineLength
- the max number of characters per line
public TextObjectGroup addText(java.lang.String text, int x, int y, int lineLength, java.lang.String pageName)
text
- the String to create the TextObjectGroup fromx
- the x-coordinate of the created TextObjectGroupy
- the y-coordinate of the created TextObjectGrouplineLength
- the max number of characters per linepageName
- the name of the Page to build on
public void attachText(TextObject to)
public void attachText(TextObject to, java.lang.String pageName)
public void addGlyphBehaviour(AbstractBehaviour b)
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
b
- the Behaviour to addpublic Behaviour addGlyphBehaviour(AbstractAction action)
The Action is converted into a Behaviour automatically.
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
The Behaviour is returned to allow calling removeGlyphBehaviour with the correct object.
action
- the AbstractAction to convert and add as a behaviour
public void removeGlyphBehaviour(AbstractBehaviour b)
The Behaviour will not be added to TextObjects created after this method is called.
b
- the Behaviour to removepublic void removeAllGlyphBehaviours()
public void addWordBehaviour(AbstractBehaviour b)
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
b
- the Behaviour to addpublic Behaviour addWordBehaviour(AbstractAction action)
The Action is converted into a Behaviour automatically.
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
The Behaviour is returned to allow calling removeWordBehaviour with the correct object.
action
- the AbstractAction to convert and add as a behaviour
public void removeWordBehaviour(AbstractBehaviour b)
The Behaviour will not be added to TextObjects created after this method is called.
b
- the Behaviour to removepublic void removeAllWordBehaviours()
public void addGroupBehaviour(AbstractBehaviour b)
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
b
- the Behaviour to addpublic Behaviour addGroupBehaviour(AbstractAction action)
The Action is converted into a Behaviour automatically.
The Behaviour will only be added to TextObjects created after this method is called.
The Behaviour is automatically added to the NTPBook.
The Behaviour is returned to allow calling removeGlyphBehaviour with the correct object.
action
- the AbstractAction to convert and add as a behaviour
public void removeGroupBehaviour(AbstractBehaviour b)
The Behaviour will not be added to TextObjects created after this method is called.
b
- the Behaviour to removepublic void removeAllGroupBehaviours()
public TextPageRenderer getRenderer()
public java.util.Collection<TextPage> getPages()
public java.util.List<AbstractBehaviour> getBehaviourList()
public TextObjectRoot getTextRoot()
public InputManager getInputs()
public SpatialList getSpatialList()
public TextPage addPage(TextPage p)
The page will be named "layerN" where N = 0,1,2,3...
public TextPage addPage(java.lang.String name, TextPage p)
public TextPage addPage(java.lang.String pageName)
pageName
- the name of the TextPage to add
public TextPage getPage(java.lang.String name)
public void addBehaviour(AbstractBehaviour b)
public void removeBehaviour(AbstractBehaviour b)
public void removeChildren(TextObjectGroup to)
to
- public void clear()
public void clearPage(java.lang.String pageName)
pageName
- the name of the TextPage to clearpublic void setLineHeight(float d)
d
- height of a line in pixel using the current fontpublic float getLineHeight()
public void setTrackingOffset(float d)
d
- tracking in pixelpublic float getTrackingOffset()
public void setTracking(int d)
d
- tracking in pixelpublic int getTracking()
public void setSpaceOffset(int space)
space
- space offset in pixelpublic int getSpaceOffset()
public void setLineSpacing(int spacing)
spacing
- line spacing in pixelpublic int getLineSpacing()
public void setIndent(int indent)
indent
- indent in pixelpublic void setIndent(int indent, int style)
indent
- indent in pixelstyle
- indent style (INDENT_NORMAL or INDENT_HANGING)public int getIndent()
public int getIndentStyle()
public void setLogger(java.io.PrintWriter pw)
NextText generated messages are written to this PrintWriter.
public void log(java.lang.String message)
The message will go to standard output, as well as a log file if one has been specified with setLogFile(). A newline will be appended to the message.
public void log(java.lang.String message, java.lang.Throwable t)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |