y.view
Class ShapeNodeRealizer

java.lang.Object
  |
  +--y.view.NodeRealizer
        |
        +--y.view.ShapeNodeRealizer
All Implemented Interfaces:
NodeLayout
Direct Known Subclasses:
Graph2DNodeRealizer, GroupNodeRealizer, ProxyShapeNodeRealizer

public class ShapeNodeRealizer
extends NodeRealizer

A node realizer that displays a node as a geometric shape. Possible shapes are rectangle, ellipse, rounded rect, triangle, ocagon, hexagon, diamond and parallelogram.


Field Summary
static byte DIAMOND
          Shape type constant.
static byte ELLIPSE
          Shape type constant.
static byte HEXAGON
          Shape type constant.
static byte OCTAGON
          Shape type constant.
static byte PARALLELOGRAM
          Shape type constant.
static byte RECT
          Shape type constant.
static byte RECT_3D
          Shape type constant.
static byte ROUND_RECT
          Shape type constant.
protected  Shape shape
          The graphical shape representation that gets painted.
static byte TRAPEZOID
          Shape type constant.
static byte TRAPEZOID_2
          Shape type constant.
static byte TRIANGLE
          Shape type constant.
 
Fields inherited from class y.view.NodeRealizer
height, HOTSPOT_E, HOTSPOT_N, HOTSPOT_NE, HOTSPOT_NONE, HOTSPOT_NW, HOTSPOT_S, HOTSPOT_SE, HOTSPOT_SW, HOTSPOT_W, width, x, y
 
Constructor Summary
ShapeNodeRealizer()
          Creates a new ShapeNodeRealizer with rectangular at position (0,0) and with empty label
ShapeNodeRealizer(byte type)
          Creates a new ShapeNodeRealizer at position (x,y) with specific type and empty label.
ShapeNodeRealizer(byte type, double x, double y, String label)
          Creates a new ShapeNodeRealizer
ShapeNodeRealizer(NodeRealizer argNodeRealizer)
          Creates a new ShapeNodeRealizer as a copy of the given realizer.
 
Method Summary
 boolean contains(double x, double y)
          Evaluate hit test on the node realizer.
 NodeRealizer createCopy(NodeRealizer nr)
          Creates a copy of this realizer type that will be initialized with the values found in the given realizer.
 boolean findIntersection(double ix, double iy, double ox, double oy, Point2D result)
          Special Intersection handling for some types of shape.
 byte getShapeType()
          Returns shape type of this realizier
 void moveBy(double dx, double dy)
          Moves this realizer by the vector (dx,dy).
protected  void paintNode(Graphics2D gfx)
          Paints the node.
 void read(ObjectInputStream in)
          Reads in the serialized form of this realizer.
 void setCenter(double x, double y)
          Sets the center location of this realizer
 void setLocation(double x, double y)
          Sets the upper left corner location of this realizer.
 void setShapeType(byte type)
          Sets the shape type of this realizer.
 void setSize(double w, double h)
          Sets the size of the realizer.
static Map shapeTypeToStringMap()
          Returns a map whose keys are the shape type specifiers wrapped in Byte objects.
 void write(ObjectOutputStream out)
          Writes this realizer in a serialized form to the given stream.
 
Methods inherited from class y.view.NodeRealizer
addLabel, calcUnionRect, calcUnionRect, createCopy, createNodeLabel, findBBIntersection, getBoundingBox, getCenterX, getCenterY, getFillColor, getFillColor2, getHeight, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getNode, getPortCandidates, getSloppySelectionColor, getWidth, getX, getY, hotSpotHit, intersects, isInBox, isSelected, isTransparent, isVisible, labelCount, paint, paintHotSpots, paintLayer, paintLayerSloppy, paintSloppy, paintText, removeLabel, setCenterX, setCenterY, setEdgesDirty, setFillColor, setFillColor2, setFrame, setFrame, setHeight, setHotSpotColor, setLabel, setLabelText, setLayer, setLayer, setLineColor, setLineType, setSelected, setSloppySelectionColor, setTransparent, setVisible, setWidth, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECT

public static final byte RECT
Shape type constant. Specifies a rectangular shape.

See Also:
Constant Field Values

ROUND_RECT

public static final byte ROUND_RECT
Shape type constant. Specifies a rectangular shape whose corners are rounded.

See Also:
Constant Field Values

ELLIPSE

public static final byte ELLIPSE
Shape type constant. Specifies an oval (ellipsoid) shape.

See Also:
Constant Field Values

PARALLELOGRAM

public static final byte PARALLELOGRAM
Shape type constant. Specifies a rhomboidal shape, whose upper right corner is further to the right than it's lower right corner.

See Also:
Constant Field Values

HEXAGON

public static final byte HEXAGON
Shape type constant. Specifies a hexagonal shape, i.e, a shape with six corners.

See Also:
Constant Field Values

TRIANGLE

public static final byte TRIANGLE
Shape type constant. Specifies a triangular shape, i.e, a shape with three corners.

See Also:
Constant Field Values

RECT_3D

public static final byte RECT_3D
Shape type constant. Specifies a rectangular shape with 3D-ish looks.

See Also:
Constant Field Values

OCTAGON

public static final byte OCTAGON
Shape type constant. Specifies an octagonal shape, i.e, a shape with eight corners.

See Also:
Constant Field Values

DIAMOND

public static final byte DIAMOND
Shape type constant. Specifies a diamond shape, i.e, a shape with four corners and diagonally sloped sides.

See Also:
Constant Field Values

TRAPEZOID

public static final byte TRAPEZOID
Shape type constant. Specifies a trapezoidal shape, whose upper line is half as long as it's lower line.

See Also:
Constant Field Values

TRAPEZOID_2

public static final byte TRAPEZOID_2
Shape type constant. Specifies a trapezoidal shape, whose lower line is half as long as it's upper line.

See Also:
Constant Field Values

shape

protected Shape shape
The graphical shape representation that gets painted.

Constructor Detail

ShapeNodeRealizer

public ShapeNodeRealizer()
Creates a new ShapeNodeRealizer with rectangular at position (0,0) and with empty label


ShapeNodeRealizer

public ShapeNodeRealizer(byte type)
Creates a new ShapeNodeRealizer at position (x,y) with specific type and empty label.

Parameters:
type - A shape type specifier.

ShapeNodeRealizer

public ShapeNodeRealizer(byte type,
                         double x,
                         double y,
                         String label)
Creates a new ShapeNodeRealizer

Parameters:
type - A shape type specifier. ShapeNodeRealizer.ELLIPSE or ShapeNodeRealizer.RECT
x - x-Coordinate of the node
y - y-Coordinate of the node
label - The label of the node

ShapeNodeRealizer

public ShapeNodeRealizer(NodeRealizer argNodeRealizer)
Creates a new ShapeNodeRealizer as a copy of the given realizer. If the given realizer is not of type ShapeNodeRealizer then a rectangular shape will be used as default.

Method Detail

createCopy

public NodeRealizer createCopy(NodeRealizer nr)
Creates a copy of this realizer type that will be initialized with the values found in the given realizer.

Specified by:
createCopy in class NodeRealizer

setCenter

public void setCenter(double x,
                      double y)
Sets the center location of this realizer

Overrides:
setCenter in class NodeRealizer

setLocation

public void setLocation(double x,
                        double y)
Sets the upper left corner location of this realizer.

Specified by:
setLocation in interface NodeLayout
Overrides:
setLocation in class NodeRealizer
Parameters:
x - the x-coordinates of the upper left corner.
y - the y-coordinates of the upper left corner.

moveBy

public void moveBy(double dx,
                   double dy)
Moves this realizer by the vector (dx,dy).

Overrides:
moveBy in class NodeRealizer

setSize

public void setSize(double w,
                    double h)
Sets the size of the realizer. Note that this method resizes the node in a way that the center location of this realizer won't change. The upper left corner of this realizer *will* change though.

Specified by:
setSize in interface NodeLayout
Overrides:
setSize in class NodeRealizer
Parameters:
w - the width of the node.
h - the heigth of the node.

setShapeType

public void setShapeType(byte type)
Sets the shape type of this realizer. The shape type specifier can be one of the following:

ShapeNodeRealizer.RECT, ShapeNodeRealizer.ROUND_RECT, ShapeNodeRealizer.ELLIPSE, ShapeNodeRealizer.PARALLELOGRAM, ShapeNodeRealizer.HEXAGON, ShapeNodeRealizer.TRIANGLE, ShapeNodeRealizer.RECT_3D, ShapeNodeRealizer.OCTAGON, ShapeNodeRealizer.DIAMOND, ShapeNodeRealizer.TRAPEZOID, ShapeNodeRealizer.TRAPEZOID_2.


getShapeType

public byte getShapeType()
Returns shape type of this realizier

See Also:
ShapeNodeRealizer.setShapeType(byte)

paintNode

protected void paintNode(Graphics2D gfx)
Paints the node.

Specified by:
paintNode in class NodeRealizer

contains

public boolean contains(double x,
                        double y)
Evaluate hit test on the node realizer. When a node is transparent, only its boundary is evaluated for the hit test.

Overrides:
contains in class NodeRealizer
Returns:
true if the position (x,y) is part of the node false otherwise.

findIntersection

public boolean findIntersection(double ix,
                                double iy,
                                double ox,
                                double oy,
                                Point2D result)
Special Intersection handling for some types of shape. When shape is an ellipse or an rectangle, the intersectin point is calculated, not iteratively determined.

Overrides:
findIntersection in class NodeRealizer

write

public void write(ObjectOutputStream out)
           throws IOException
Writes this realizer in a serialized form to the given stream.

Overrides:
write in class NodeRealizer
IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Reads in the serialized form of this realizer. The realizer must have been written out before by it's ShapeNodeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class NodeRealizer
IOException
ClassNotFoundException

shapeTypeToStringMap

public static Map shapeTypeToStringMap()
Returns a map whose keys are the shape type specifiers wrapped in Byte objects. The value for each key is a String that describes the shape type.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003