edu.mit.sketch.ddg
Class ConnectsConstraint

java.lang.Object
  extended by edu.mit.sketch.ddg.Constraint
      extended by edu.mit.sketch.ddg.ConnectsConstraint
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ConnectsConstraint
extends Constraint
implements java.io.Serializable

This class represents the connects constraint. The main constraint graph stores how lines connect to each other. There are also additional 4 constraint graphs for exact specification of what end-points connect to waht end-points, given a labelling (example CONNECTS_P1_P2). This class has methods for checking that another connects constraint graph is a subgraph of this one, consistent with the labelling of points (but not necessarily the same labelling). It also has methods for determining the confidence of a constraint between two particular line end-points.

A lot of algorithms do not need the detailed end-point information, so they operate with this constraint as with any other constraint. Consistency with the more detailed graphs has to be verified explicitly.

Needed Improvements:
More detailed connects constraints should be reimplemented with directional lines and what other lines they connect to. That will reduce redundancy by half.

ConnectsConstraint.java Created: Sat Nov 21 18:26:00 2001

Author:
Olya Veselova
See Also:
Serialized Form

Field Summary
static int CONNECTS_P1_P1
          Subconstraint names
static int CONNECTS_P1_P2
           
static int CONNECTS_P2_P1
           
static int CONNECTS_P2_P2
           
 
Constructor Summary
ConnectsConstraint()
          Constructs an empty constraint graph (and empty constraint subgraphs)
 
Method Summary
 java.lang.Object clone()
          Clone the constraint
static double constraintConfidence(Line l1, Line l2)
          Returns the confidence that the constraint holds between the two given line primitives
static double constraintConfidence(Line l1, Line l2, int name)
          Returns the confidence the sub constraint with a given name between the two primitives.
 ConstraintGraph graphConnectsP1P1()
          Return the more detailed graph
 ConstraintGraph graphConnectsP1P2()
          Return the more detailed graph
 ConstraintGraph graphConnectsP2P1()
          Return the more detailed graph
 ConstraintGraph graphConnectsP2P2()
          Return the more detailed graph
 void initialize(java.util.HashMap primToGeomParts)
          Infer the constraints from the user stroke's geometric parts and record the constraint graphs.
 void mergeIn(Constraint other)
          Put the constraints that are in other into this one, if they are not already in the graph
 java.lang.String name()
          Name of the constraint
 boolean orientationInvariant()
          Returns true if the constraint is orinetation invariant
 boolean P1P1(ConstraintGraphEdge edge)
          Return weather the edge is in a given graph
 boolean P1P2(ConstraintGraphEdge edge)
          Return weather the edge is in a given graph
 boolean P2P1(ConstraintGraphEdge edge)
          Return weather the edge is in a given graph
 boolean P2P2(ConstraintGraphEdge edge)
          Return weather the edge is in a given graph
 void print(java.io.PrintStream out, boolean printDetails)
          Print the main constraint graph.
 void removeLowConfidence(double confidenceThreshold)
          Remove constraints that are below the confidence threshold.
 void removeLowRelevance(double relevanceThreshold)
          Remove constraints that are below the relevance threshold.
 void renamePrimitives(PrimitiveMapping mapping, PrimitiveList relabelled)
          Rename the primitives in the following constraint according to the given mapping
 boolean sameAs(Constraint other, PrimitiveMapping mapping)
          Verifies whether this constraint is the same as the other one given the mapping between primitives.
 Constraint subgraph(PrimitiveList primitiveList)
          Return a new constraint that is a subgraph of this one only for the primitives in the given list.
 boolean subgraphOfUpToRelabelling(Constraint otherConstraint, PrimitiveMapping mapping, PrimitiveList relabelled, PrimitiveList nonRelabelled)
          Verifies that this constraint is a subgraph of other up to swapping of line end-point labels (P1 and P2).
 
Methods inherited from class edu.mit.sketch.ddg.Constraint
constraintGraph, labelledEdgeList, setConstraintGraph
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTS_P1_P1

public static final int CONNECTS_P1_P1
Subconstraint names

See Also:
Constant Field Values

CONNECTS_P1_P2

public static final int CONNECTS_P1_P2
See Also:
Constant Field Values

CONNECTS_P2_P1

public static final int CONNECTS_P2_P1
See Also:
Constant Field Values

CONNECTS_P2_P2

public static final int CONNECTS_P2_P2
See Also:
Constant Field Values
Constructor Detail

ConnectsConstraint

public ConnectsConstraint()
Constructs an empty constraint graph (and empty constraint subgraphs)

Method Detail

orientationInvariant

public boolean orientationInvariant()
Returns true if the constraint is orinetation invariant

Specified by:
orientationInvariant in class Constraint

initialize

public void initialize(java.util.HashMap primToGeomParts)
Infer the constraints from the user stroke's geometric parts and record the constraint graphs. HashMap: type of key: Primitive, type of value: GeometricObject


constraintConfidence

public static double constraintConfidence(Line l1,
                                          Line l2)
Returns the confidence that the constraint holds between the two given line primitives


constraintConfidence

public static double constraintConfidence(Line l1,
                                          Line l2,
                                          int name)
Returns the confidence the sub constraint with a given name between the two primitives. Used to find out the confidence of particular end-points (like CONNECTS_P1_P2).


name

public java.lang.String name()
Name of the constraint

Specified by:
name in class Constraint

subgraph

public Constraint subgraph(PrimitiveList primitiveList)
Return a new constraint that is a subgraph of this one only for the primitives in the given list. It is ok for the list to contain primitives that are not in the constraint graph. They will just be ignored.

Overrides:
subgraph in class Constraint

mergeIn

public void mergeIn(Constraint other)
Put the constraints that are in other into this one, if they are not already in the graph

Overrides:
mergeIn in class Constraint

renamePrimitives

public void renamePrimitives(PrimitiveMapping mapping,
                             PrimitiveList relabelled)
Rename the primitives in the following constraint according to the given mapping

Overrides:
renamePrimitives in class Constraint

sameAs

public boolean sameAs(Constraint other,
                      PrimitiveMapping mapping)
Verifies whether this constraint is the same as the other one given the mapping between primitives. The first primitive in the mapping pair is from the other object and the second is from this. Will also verify that the subgraphs are ok up to relabelling

Overrides:
sameAs in class Constraint

subgraphOfUpToRelabelling

public boolean subgraphOfUpToRelabelling(Constraint otherConstraint,
                                         PrimitiveMapping mapping,
                                         PrimitiveList relabelled,
                                         PrimitiveList nonRelabelled)
Verifies that this constraint is a subgraph of other up to swapping of line end-point labels (P1 and P2). The first primitive in the mapping is from this constraint and the second from the other constraint. The relabelled and nonRelabelled lists specify which primitives are already known to be relabelled if any. The rest have to be consistent with these lists and the lists get filled in by additional info as the function proceeds


removeLowConfidence

public void removeLowConfidence(double confidenceThreshold)
Remove constraints that are below the confidence threshold. Also removes primitives that have no outgoing edges after the operation. Updates the subgraphs, as well as the main graph.

Overrides:
removeLowConfidence in class Constraint

removeLowRelevance

public void removeLowRelevance(double relevanceThreshold)
Remove constraints that are below the relevance threshold. Also removes primitives that have no outgoing edges after the operation. Updates the subgraphs, as well as the main graph.

Overrides:
removeLowRelevance in class Constraint

print

public void print(java.io.PrintStream out,
                  boolean printDetails)
Print the main constraint graph. Also print subgraphs, and confidence and relevance if the printDetails is true.

Overrides:
print in class Constraint

graphConnectsP1P1

public ConstraintGraph graphConnectsP1P1()
Return the more detailed graph


graphConnectsP1P2

public ConstraintGraph graphConnectsP1P2()
Return the more detailed graph


graphConnectsP2P1

public ConstraintGraph graphConnectsP2P1()
Return the more detailed graph


graphConnectsP2P2

public ConstraintGraph graphConnectsP2P2()
Return the more detailed graph


P1P1

public boolean P1P1(ConstraintGraphEdge edge)
Return weather the edge is in a given graph


P1P2

public boolean P1P2(ConstraintGraphEdge edge)
Return weather the edge is in a given graph


P2P1

public boolean P2P1(ConstraintGraphEdge edge)
Return weather the edge is in a given graph


P2P2

public boolean P2P2(ConstraintGraphEdge edge)
Return weather the edge is in a given graph


clone

public java.lang.Object clone()
Clone the constraint

Specified by:
clone in class Constraint