diva.sketch.parser2d
Class ConstituentSet

java.lang.Object
  |
  +--diva.sketch.parser2d.ConstituentSet

public class ConstituentSet
extends java.lang.Object

A set of constituents that supports 2D geometric queries. The 2D geometric queries are of the form "tell me all the constituents that have [a given spatial relation] to the given constituent". The format of the query is sufficiently abstract that it can eventually be rewritten to be more optimized without changing the interface.

Version:
$Revision: 1.1 $

Field Summary
(package private)  Constituent[] _children
          The constituents that this set contains.
 
Constructor Summary
ConstituentSet(Constituent[] children)
          Construct a set of the given constituents.
 
Method Summary
 java.util.Iterator constituentsOfType(java.lang.String type)
          Return an iterator over the constituents contained by this set that are of the given type.
static void debug(java.lang.String s)
          Debugging output.
 boolean equals(java.lang.Object o)
          A customized equals implementation to enable parser memoization.
 Constituent[] findRelatives(Constituent c, java.lang.String type, RelationConstraint r)
          Return the set of constituents of the given type, related to the the given constituent by the given relation.
 int hashCode()
          A customized hash code implementation to enable parser memoization.
 java.util.Iterator iterator()
          Return an iterator over this set's contents.
 ConstituentSet reduce(Constituent lhs, Constituent[] rhs)
          Return a new constituent set that has been reduced by the given "production".
 int size()
          Return the number of constituents this set contains.
 java.lang.String toString()
          Return a string representation of this set for printing.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_children

Constituent[] _children
The constituents that this set contains.
Constructor Detail

ConstituentSet

public ConstituentSet(Constituent[] children)
Construct a set of the given constituents.
Method Detail

constituentsOfType

public java.util.Iterator constituentsOfType(java.lang.String type)
Return an iterator over the constituents contained by this set that are of the given type.

debug

public static void debug(java.lang.String s)
Debugging output.

equals

public boolean equals(java.lang.Object o)
A customized equals implementation to enable parser memoization.
Overrides:
equals in class java.lang.Object

findRelatives

public Constituent[] findRelatives(Constituent c,
                                   java.lang.String type,
                                   RelationConstraint r)
Return the set of constituents of the given type, related to the the given constituent by the given relation.

hashCode

public int hashCode()
A customized hash code implementation to enable parser memoization.
Overrides:
hashCode in class java.lang.Object

iterator

public java.util.Iterator iterator()
Return an iterator over this set's contents.

reduce

public ConstituentSet reduce(Constituent lhs,
                             Constituent[] rhs)
Return a new constituent set that has been reduced by the given "production". In other words, make a shallow copy of the set, add "lhs" to the copy, and remove "rhs" from the copy. Provided as a method since this is a common operation and may be able to be optimized depending on the constituent set's data structure and geometric optimizations, etc.

size

public int size()
Return the number of constituents this set contains.

toString

public java.lang.String toString()
Return a string representation of this set for printing.
Overrides:
toString in class java.lang.Object