net.nexttext
Class TextObjectGroup

java.lang.Object
  extended by net.nexttext.TextObject
      extended by net.nexttext.TextObjectGroup
All Implemented Interfaces:
Locatable
Direct Known Subclasses:
TextObjectRoot

public class TextObjectGroup
extends TextObject

TextObjectGroup is a TextObject which is made up of other TextObjects.

The meaning of the grouping can be defined by the application, but it is typically something like glyphs being grouped into a word. It is a non-terminal node in the TextObject tree. It differs from a regular TextObject only in that it has children.


Constructor Summary
TextObjectGroup()
          Default Constructor.
TextObjectGroup(java.util.Map<java.lang.String,Property> props, processing.core.PVector pos)
          Creates a new TextObjectGroup at the specified position, and with extra properties.
TextObjectGroup(processing.core.PVector pos)
          Creates a new TextObjectGroup at the specified position.
 
Method Summary
 void attachChild(TextObject newChild)
          Attach a child to the end of the list of children.
 void attachChild(TextObject newChild, int location)
          Attach a child at the given location.
 int getHeight()
          Get the greatest number of layers between this TextObject and the leaves of the tree.
 TextObject getLeftMostChild()
          Get the left most Child, or null if there isn't one.
 java.awt.Polygon getLocalBoundingPolygon()
          See TextObject's getLocalBoundingPolygon() description for details.
 int getNumChildren()
          Get the number of children.
 TextObject getRightMostChild()
          Get the right most Child, or null if there isn't one.
 java.lang.String getString()
          Returns the string representation of a group
 TextObjectGlyphIterator glyphIterator()
          Get an iterator over all the descendant glyphs of this group.
 TextObjectIterator iterator()
          Get an iterator over this group and all of its descendants.
 java.lang.String toString()
           
 
Methods inherited from class net.nexttext.TextObject
attachToLeft, attachToRight, detach, getAbsoluteCoordinateSystem, getBook, getBoundingPolygon, getBounds, getCenter, getColor, getColorAbsolute, getLeftSibling, getLocation, getParent, getPosition, getPositionAbsolute, getProperty, getPropertyNames, getRelativeBoundingPolygon, getRelativeCoordinateSystem, getRightSibling, getRotation, getStroke, getStrokeAbsolute, getStrokeColor, getStrokeColorAbsolute, init, initProperties, invalidateLocalBoundingPolygon, isFilled, isStroked
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextObjectGroup

public TextObjectGroup()
Default Constructor. Creates a new TextObjectGroup at Position (0,0,0)


TextObjectGroup

public TextObjectGroup(processing.core.PVector pos)
Creates a new TextObjectGroup at the specified position.


TextObjectGroup

public TextObjectGroup(java.util.Map<java.lang.String,Property> props,
                       processing.core.PVector pos)
Creates a new TextObjectGroup at the specified position, and with extra properties.

Method Detail

getLeftMostChild

public TextObject getLeftMostChild()
Get the left most Child, or null if there isn't one.


getRightMostChild

public TextObject getRightMostChild()
Get the right most Child, or null if there isn't one.


getNumChildren

public int getNumChildren()
Get the number of children.


attachChild

public void attachChild(TextObject newChild)
Attach a child to the end of the list of children.


attachChild

public void attachChild(TextObject newChild,
                        int location)
Attach a child at the given location. Location must be between 1 and numChildren + 1, inclusive. The provided TextObject is attached so it is at that location in the list, counting from the left most child to the right most child.


iterator

public TextObjectIterator iterator()
Get an iterator over this group and all of its descendants.


glyphIterator

public TextObjectGlyphIterator glyphIterator()
Get an iterator over all the descendant glyphs of this group.


getHeight

public int getHeight()
Get the greatest number of layers between this TextObject and the leaves of the tree.

Specified by:
getHeight in class TextObject
Returns:
0 if this node is a leaf of the tree, 1 + the greatest depth of its children otherwise.


getString

public java.lang.String getString()
Returns the string representation of a group


getLocalBoundingPolygon

public java.awt.Polygon getLocalBoundingPolygon()
See TextObject's getLocalBoundingPolygon() description for details.

Do not modify the returned Polygon, because it may be cached.

XXXBUG: This method always returns a rectangle unless we write some convex hull calculations.

Specified by:
getLocalBoundingPolygon in class TextObject
Returns:
A bounding polygon; the polygon could be empty if the group has no glyph descendants.
See Also:
TextObject.getLocalBoundingPolygon()

toString

public java.lang.String toString()
Specified by:
toString in class TextObject