fcmodeler.view.figures
Interface NodeShape

All Superinterfaces:
java.lang.Cloneable
All Known Implementing Classes:
DiamondNodeShape, RoundRectangleNodeShape, TestNodeShape, TinyRectangleNodeShape, RectangleNodeShape, EllipseNodeShape

public interface NodeShape
extends java.lang.Cloneable

NodeShape provides a Shape object to be used as the outline for a node figure, as well as functionality for positioning, translating, and transforming the Shape. This interface and the NodeFigure class define the two main classes in the State design pattern. NodeShape represents the State interface, and concrete NodeShape implementation classes represent different shapes to be used as node figure outlines.

Because of the internals of NodeFigure, NodeShape must be cloneable. All NodeShape implementations should define a clone method, and implement it as follows (example taken from RectangleNodeShape):

 public Object clone() throws CloneNotSupportedException {
  //create the clone
  RectangleNodeShape clone = (RectangleNodeShape) super.clone();

  //create new copies of any mutable fields
  clone._shape = new Rectangle2D.Double(_shape.getX(), _shape.getY(), _shape.getWidth(), _shape.getHeight());

  return clone;
 }
 

Since:
JDK1.3
Version:
$Revision: 1.4 $
Author:
Zach Cox

Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this NodeShape.
 void enclose(java.awt.geom.Rectangle2D rectangle)
          Ensures that this NodeShape completely encloses the specified rectangle.
 java.awt.Shape getShape()
          Returns the Shape object represented by this NodeShape.
 void position(double x, double y)
          Positions this NodeShape at the specified coordinates.
 void transform(java.awt.geom.AffineTransform transform)
          Transforms this NodeShape using the specified AffineTransform.
 void translate(double dx, double dy)
          Translates this NodeShape by the specified x and y values.
 

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this NodeShape. The returned Object should be a concrete implementation type of NodeShape and also have copies of any mutable fields of this object.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this NodeShape.
Throws:
java.lang.CloneNotSupportedException - should never be thrown.

enclose

public void enclose(java.awt.geom.Rectangle2D rectangle)
Ensures that this NodeShape completely encloses the specified rectangle.
Parameters:
rectangle - the rectangle to enclose.

getShape

public java.awt.Shape getShape()
Returns the Shape object represented by this NodeShape.
Returns:
the Shape object represented by this NodeShape.

position

public void position(double x,
                     double y)
Positions this NodeShape at the specified coordinates. Note that calling this method may create a new Shape instance. Therefore, a new call to getShape may be necessary after calling this method.
Parameters:
x - the x-coordinate of the new position.
y - the y-coordinate of the new position.

translate

public void translate(double dx,
                      double dy)
Translates this NodeShape by the specified x and y values. Note that calling this method may create a new Shape instance. Therefore, a new call to getShape may be necessary after calling this method.
Parameters:
dx - the amount to translate the x direction.
dy - the amount to translate in the y direction.

transform

public void transform(java.awt.geom.AffineTransform transform)
Transforms this NodeShape using the specified AffineTransform. Note that calling this method may create a new Shape instance. Therefore, a new call to getShape may be necessary after calling this method.
Parameters:
transform - the AffineTransform used to transform this NodeShape object.