com.horstmann.violet
Class ObjectNode

java.lang.Object
  extended by com.horstmann.violet.framework.AbstractNode
      extended by com.horstmann.violet.framework.RectangularNode
          extended by com.horstmann.violet.ObjectNode
All Implemented Interfaces:
Node, java.io.Serializable, java.lang.Cloneable

public class ObjectNode
extends RectangularNode

An object node in an object diagram.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.horstmann.violet.framework.AbstractNode
SHADOW_GAP
 
Constructor Summary
ObjectNode()
          Construct an object node with a default size
 
Method Summary
 void addChild(Node n)
          This is a patch to ensure that object diagrams can be read back in correctly.
 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()
           
 void draw(java.awt.Graphics2D g2)
          Draw the node.
 java.awt.geom.Point2D getConnectionPoint(Direction d)
          Get the best connection point to connect this node with another node.
 MultiLineString getName()
          Gets the name property value.
 java.awt.geom.Rectangle2D getTopRectangle()
          Returns the rectangle at the top of the object node.
 void layout(Graph g, java.awt.Graphics2D g2, Grid grid)
          Lays out the node and its children.
 void setName(MultiLineString n)
          Sets the name property value.
 
Methods inherited from class com.horstmann.violet.framework.RectangularNode
contains, getBounds, getShape, setBounds, translate
 
Methods inherited from class com.horstmann.violet.framework.AbstractNode
addChild, getChildren, getParent, removeChild, removeEdge, removeNode, setParent, setPersistenceDelegate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectNode

public ObjectNode()
Construct an object node with a default size

Method Detail

draw

public void draw(java.awt.Graphics2D g2)
Description copied from interface: Node
Draw the node.

Specified by:
draw in interface Node
Overrides:
draw in class AbstractNode
Parameters:
g2 - the graphics context

getTopRectangle

public java.awt.geom.Rectangle2D getTopRectangle()
Returns the rectangle at the top of the object node.

Returns:
the top rectangle

addEdge

public boolean addEdge(Edge e,
                       java.awt.geom.Point2D p1,
                       java.awt.geom.Point2D p2)
Description copied from interface: Node
Adds an edge that originates at this node.

Specified by:
addEdge in interface Node
Overrides:
addEdge in class AbstractNode
Parameters:
e - the edge to add
Returns:
true if the edge was added

getConnectionPoint

public java.awt.geom.Point2D getConnectionPoint(Direction d)
Description copied from interface: Node
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.

Specified by:
getConnectionPoint in interface Node
Overrides:
getConnectionPoint in class RectangularNode
Parameters:
d - the direction from the center of the bounding rectangle towards the boundary
Returns:
the recommended connection point

layout

public void layout(Graph g,
                   java.awt.Graphics2D g2,
                   Grid grid)
Description copied from interface: Node
Lays out the node and its children.

Specified by:
layout in interface Node
Overrides:
layout in class RectangularNode
Parameters:
g - the ambient graph
g2 - the graphics context
grid - the grid to snap to

setName

public void setName(MultiLineString n)
Sets the name property value.

Parameters:
newValue - the new object name

getName

public MultiLineString getName()
Gets the name property value.

Parameters:
the - object name

clone

public java.lang.Object clone()
Specified by:
clone in interface Node
Overrides:
clone in class RectangularNode

addNode

public boolean addNode(Node n,
                       java.awt.geom.Point2D p)
Description copied from interface: Node
Adds a node as a child node to this node.

Specified by:
addNode in interface Node
Overrides:
addNode in class AbstractNode
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

addChild

public void addChild(Node n)
This is a patch to ensure that object diagrams can be read back in correctly.

Overrides:
addChild in class AbstractNode