easik.sketch.constraint
Class Constraint

java.lang.Object
  extended by easik.sketch.vertex.SketchVertex
      extended by easik.sketch.constraint.Constraint
Direct Known Subclasses:
CommutativeDiagram, ProductConstraint, PullbackConstraint, SumConstraint

public abstract class Constraint
extends SketchVertex

This is the superclass for all constraints. Constraints get a non-unique label that shows what kind of constraint it is (symbolically) and have a set of paths which it deals with.

Version:
2006-07-26 Kevin Green
Author:
Rob Fletcher 2005, Kevin Green 2006, Vera Ranieri 2006

Field Summary
protected  java.lang.String _constraintLabel
          The label on the constraint
protected  javax.swing.tree.DefaultMutableTreeNode _constraintNode
          The DefaultMutableTreeNode respresentation of this constraint
protected  java.util.ArrayList<SketchEdge> _edges
          The edge involved in the constraint
protected  boolean _isVisible
          Stores whether the constraint is visible or not
protected  java.util.ArrayList<SketchPath> _paths
          The paths involved in the constraint
protected  java.util.ArrayList<GuideEdge> _visuals
          The Guide Edges of the constraint
 
Fields inherited from class easik.sketch.vertex.SketchVertex
_marked, _name, _posX, _posY
 
Constructor Summary
Constraint()
          Default constructor needed for subclasses
Constraint(java.lang.String name, int x, int y, boolean isVisible)
          Creates a very simple constraint node.
 
Method Summary
protected  void addEdges()
          Adds all edges participating in this constraint to an arraylist of edges.
 void addVisualsToSketch(org.jgrapht.graph.ListenableDirectedGraph<SketchVertex,org.jgrapht.graph.DefaultEdge> inGraph, SketchAdapter adapter)
          Adds the visual aids to the sketch provided
 java.util.ArrayList<SketchEdge> getEdges()
          Returns the edges dealt with in the constraint.
 javax.swing.tree.DefaultMutableTreeNode getNode()
          Returns the node used to display the constraint in the tree
 java.util.ArrayList<SketchPath> getPaths()
          Returns the set of the paths involved in the constraint
static java.lang.String getTablesInvolvedForError(java.util.ArrayList<SketchPath> paths)
          Determines the entities involved in a constraint and lists them for an error message.
 java.lang.String getType()
          Returns a string corresponding to the constraint type.
 boolean hasEdge(SketchEdge inEdge)
          Checks to see if the constraint contains a path that uses an edge
 boolean isDomainOrCoDomain(EntityNode inEntity)
          Tests to see if an entity is either the domain or co-domain of any of the paths involved in the constraint
 boolean isVisible()
          Returns if the constraint is visible or not (True = visible)
static void setAllConstraintsVisible(java.util.LinkedList<Constraint> constraints, boolean show)
          Sets all constraints to visible/invisible in the sketch.
 void setNode(javax.swing.tree.DefaultMutableTreeNode inNode)
          Sets the node used to display the constraint in the tree
 void setVisible(boolean inIsVisible)
          Sets if the constraint should be visible or not
 java.lang.String toString()
          Accessor for the constraint label
 
Methods inherited from class easik.sketch.vertex.SketchVertex
getMarked, getName, getX, getY, setMarked, setName, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_constraintLabel

protected java.lang.String _constraintLabel
The label on the constraint


_paths

protected java.util.ArrayList<SketchPath> _paths
The paths involved in the constraint


_edges

protected java.util.ArrayList<SketchEdge> _edges
The edge involved in the constraint


_constraintNode

protected javax.swing.tree.DefaultMutableTreeNode _constraintNode
The DefaultMutableTreeNode respresentation of this constraint


_isVisible

protected boolean _isVisible
Stores whether the constraint is visible or not


_visuals

protected java.util.ArrayList<GuideEdge> _visuals
The Guide Edges of the constraint

Constructor Detail

Constraint

public Constraint()
Default constructor needed for subclasses


Constraint

public Constraint(java.lang.String name,
                  int x,
                  int y,
                  boolean isVisible)
Creates a very simple constraint node.

Parameters:
name - The label on the node
x - x coordinate
y - y coordinate
isVisible - If the constraint is visible in the graph or not
Method Detail

isVisible

public boolean isVisible()
Returns if the constraint is visible or not (True = visible)

Returns:
If the constraint is visible or not

setVisible

public void setVisible(boolean inIsVisible)
Sets if the constraint should be visible or not

Parameters:
inIsVisible - If the constraint should be visible or not.

addVisualsToSketch

public void addVisualsToSketch(org.jgrapht.graph.ListenableDirectedGraph<SketchVertex,org.jgrapht.graph.DefaultEdge> inGraph,
                               SketchAdapter adapter)
Adds the visual aids to the sketch provided

Parameters:
inGraph - The graph which will be getting the visual aids
adapter - The adapter between the graph and the sketch

isDomainOrCoDomain

public boolean isDomainOrCoDomain(EntityNode inEntity)
Tests to see if an entity is either the domain or co-domain of any of the paths involved in the constraint

Parameters:
inEntity - The entity to be tested
Returns:
True if it is either domain or co-domain of a path involved in the constraint, false otherwise.

addEdges

protected void addEdges()
Adds all edges participating in this constraint to an arraylist of edges.


toString

public java.lang.String toString()
Accessor for the constraint label

Overrides:
toString in class SketchVertex
Returns:
The label

hasEdge

public boolean hasEdge(SketchEdge inEdge)
Checks to see if the constraint contains a path that uses an edge

Parameters:
inEdge - The edge to check against.
Returns:
True if constraint contains inEdge, false otherwise.

getEdges

public java.util.ArrayList<SketchEdge> getEdges()
Returns the edges dealt with in the constraint.

Returns:
The edges

getPaths

public java.util.ArrayList<SketchPath> getPaths()
Returns the set of the paths involved in the constraint

Returns:
The array of sketch paths

getType

public java.lang.String getType()
Returns a string corresponding to the constraint type. (used in XML generation).

Returns:
A string of the type of constraint

setNode

public void setNode(javax.swing.tree.DefaultMutableTreeNode inNode)
Sets the node used to display the constraint in the tree

Parameters:
inNode - The node used to display the constraint in the tree

getNode

public javax.swing.tree.DefaultMutableTreeNode getNode()
Returns the node used to display the constraint in the tree

Returns:
The node used to display the constraint in the tree

setAllConstraintsVisible

public static void setAllConstraintsVisible(java.util.LinkedList<Constraint> constraints,
                                            boolean show)
Sets all constraints to visible/invisible in the sketch.

Parameters:
constraints - The list of constraints.
show - true if constraints are to be set to visible, false otherwise
Since:
2006-05-29 Vera Ranieri

getTablesInvolvedForError

public static java.lang.String getTablesInvolvedForError(java.util.ArrayList<SketchPath> paths)
Determines the entities involved in a constraint and lists them for an error message.

Parameters:
paths - The paths forming the constraint
Returns:
A string of the domains and codomains of the constraint, formatted for an error message
Since:
2006-08-04 Vera Ranieri