com.horstmann.violet.framework
Interface Node

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable
All Known Implementing Classes:
AbstractNode, ActorNode, CallNode, CircularStateNode, ClassNode, FieldNode, ImplicitParameterNode, InterfaceNode, NoteNode, ObjectNode, PackageNode, PointNode, RectangularNode, StateNode, UseCaseNode

public interface Node
extends java.io.Serializable, java.lang.Cloneable

A node in a graph.


Method Summary
 void addChild(int index, Node node)
          Adds a child node.
 boolean addEdge(Edge e, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
          Adds an edge that originates at this node.
 boolean addNode(Node n, java.awt.geom.Point2D p)
          Adds a node as a child node to this node.
 java.lang.Object clone()
           
 boolean contains(java.awt.geom.Point2D aPoint)
          Tests whether the node contains a point.
 void draw(java.awt.Graphics2D g2)
          Draw the node.
 java.awt.geom.Rectangle2D getBounds()
          Get the bounding rectangle of the shape of this node
 java.util.List getChildren()
          Gets the children of this node.
 java.awt.geom.Point2D getConnectionPoint(Direction d)
          Get the best connection point to connect this node with another node.
 Node getParent()
          Gets the parent of this node.
 void layout(Graph g, java.awt.Graphics2D g2, Grid grid)
          Lays out the node and its children.
 void removeChild(Node node)
          Removes a child node.
 void removeEdge(Graph g, Edge e)
          Notifies this node that an edge is being removed.
 void removeNode(Graph g, Node n)
          Notifies this node that a node is being removed.
 void setParent(Node node)
          Sets the parent of this node.
 void translate(double dx, double dy)
          Translates the node by a given amount
 

Method Detail

draw

void draw(java.awt.Graphics2D g2)
Draw the node.

Parameters:
g2 - the graphics context

translate

void translate(double dx,
               double dy)
Translates the node by a given amount

Parameters:
dx - the amount to translate in the x-direction
dy - the amount to translate in the y-direction

contains

boolean contains(java.awt.geom.Point2D aPoint)
Tests whether the node contains a point.

Parameters:
aPoint - the point to test
Returns:
true if this node contains aPoint

getConnectionPoint

java.awt.geom.Point2D getConnectionPoint(Direction d)
Get the best connection point to connect this node with another node. This should be a point on the boundary of the shape of this node.

Parameters:
d - the direction from the center of the bounding rectangle towards the boundary
Returns:
the recommended connection point

getBounds

java.awt.geom.Rectangle2D getBounds()
Get the bounding rectangle of the shape of this node

Returns:
the bounding rectangle

addEdge

boolean addEdge(Edge e,
                java.awt.geom.Point2D p1,
                java.awt.geom.Point2D p2)
Adds an edge that originates at this node.

Parameters:
p - the point that the user selected as the starting point. This may be used as a hint if edges are ordered.
e - the edge to add
Returns:
true if the edge was added

addNode

boolean addNode(Node n,
                java.awt.geom.Point2D p)
Adds a node as a child node to this node.

Parameters:
n - the child node
p - the point at which the node is being added
Returns:
true if this node accepts the given node as a child

removeEdge

void removeEdge(Graph g,
                Edge e)
Notifies this node that an edge is being removed.

Parameters:
g - the ambient graph
e - the edge to be removed

removeNode

void removeNode(Graph g,
                Node n)
Notifies this node that a node is being removed.

Parameters:
g - the ambient graph
n - the node to be removed

layout

void layout(Graph g,
            java.awt.Graphics2D g2,
            Grid grid)
Lays out the node and its children.

Parameters:
g - the ambient graph
g2 - the graphics context
grid - the grid to snap to

getParent

Node getParent()
Gets the parent of this node.

Returns:
the parent node, or null if the node has no parent

setParent

void setParent(Node node)
Sets the parent of this node.

Parameters:
node - the parent node, or null if the node has no parent

getChildren

java.util.List getChildren()
Gets the children of this node.

Returns:
an unmodifiable list of the children

addChild

void addChild(int index,
              Node node)
Adds a child node.

Parameters:
index - the position at which to add the child
node - the child node to add

removeChild

void removeChild(Node node)
Removes a child node.

Parameters:
node - the child to remove.

clone

java.lang.Object clone()