|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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; }
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 |
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
NodeShape
. The returned
Object
should be a concrete implementation type of NodeShape
and also have copies of any mutable fields of this object.clone
in class java.lang.Object
NodeShape
.java.lang.CloneNotSupportedException
- should never be thrown.public void enclose(java.awt.geom.Rectangle2D rectangle)
NodeShape
completely encloses the specified
rectangle.rectangle
- the rectangle to enclose.public java.awt.Shape getShape()
Shape
object represented by this NodeShape
.Shape
object represented by this NodeShape
.public void position(double x, double y)
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.x
- the x-coordinate of the new position.y
- the y-coordinate of the new position.public void translate(double dx, double dy)
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.dx
- the amount to translate the x direction.dy
- the amount to translate in the y direction.public void transform(java.awt.geom.AffineTransform transform)
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.transform
- the AffineTransform
used to transform this NodeShape
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |