|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--diva.sketch.parser2d.CompositeConstituent
A default implementation for a non-terminal constituent. Composite constituents cache the bounding box of their children once it is computed. Children of this constituent have names, which distinguish two children of the same type. For example, suppose you are parsing an "integral" mathematical expression, and the integral has a lower bound, upper bound, and body all of type expression. Then these would be distinguished by the names given in the parsing rule, such as "lowerBound", "upperBound", and "body".
Field Summary | |
(package private) java.awt.geom.Rectangle2D |
_bounds
Cache the bounds. |
(package private) java.lang.String[] |
_childNames
The names of the children of this constituent. |
(package private) Constituent[] |
_children
The children of this constituent. |
(package private) java.lang.String |
_type
The type (LHS) of this constituent. |
Constructor Summary | |
CompositeConstituent(java.lang.String type,
Constituent[] children,
java.lang.String[] childNames)
Construct a composite constituent with the given type and children. |
Method Summary | |
java.util.Iterator |
children()
Return an iterator of the child constituents. |
void |
clearCachedBounds()
Clear the cached bounds (in case the child constituents have changed some way. |
boolean |
equals(java.lang.Object o)
A customized equals implementation to enable parser memoization. |
java.awt.geom.Rectangle2D |
getBounds()
Return the 2D bounding box of the constituent. |
Constituent |
getChild(java.lang.String name)
Return the child with the given name; throw an IllegalArgument exception if the argument is not a child of this composite. |
java.lang.String |
getName(Constituent child)
Return the name of the given child; throw an IllegalArgument exception if the argument is not a child of this composite. |
java.lang.String |
getType()
Return the type of the constituent (its LHS) |
int |
hashCode()
A customized hash code implementation to enable parser memoization. |
java.lang.String |
toString()
Return a string with the type. |
Methods inherited from class java.lang.Object |
|
Field Detail |
java.awt.geom.Rectangle2D _bounds
java.lang.String _type
Constituent[] _children
java.lang.String[] _childNames
Constructor Detail |
public CompositeConstituent(java.lang.String type, Constituent[] children, java.lang.String[] childNames)
Method Detail |
public java.util.Iterator children()
public void clearCachedBounds()
public boolean equals(java.lang.Object o)
public Constituent getChild(java.lang.String name)
public java.lang.String getName(Constituent child)
public java.awt.geom.Rectangle2D getBounds()
public java.lang.String getType()
public int hashCode()
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |