y.view
Class BezierEdgeRealizer

java.lang.Object
  |
  +--y.view.EdgeRealizer
        |
        +--y.view.BezierEdgeRealizer
All Implemented Interfaces:
EdgeLayout

public class BezierEdgeRealizer
extends EdgeRealizer

This realizer draws an edge as a bezier spline curve. The bends are interpreted as controlpoints for the curve. The controlpoints of this curve type do not lie on the curve itself. Very 2nd segment (starting with the 3rd) formed by the control points is tangential to the curve at the point lying in the middle of that segment.


Field Summary
 
Fields inherited from class y.view.EdgeRealizer
bends, path
 
Constructor Summary
BezierEdgeRealizer()
          Default Constructor.
BezierEdgeRealizer(EdgeRealizer r)
          Constrcts a new SplineEdgeRealizer as a copy of the given realizer.
 
Method Summary
protected  void calculatePath()
          Recalculates the bezier curve path after this realizer has been marked as dirty.
 void calcUnionRect(Rectangle2D r)
          Calculate the union of rectangle enclosed by this realizer and r.
 boolean contains(double x, double y)
          Tests whether or not the given coordinate hits the path of this realizer.
 Bend createBend(double x, double y, Bend refBend, int dir)
          Add a new Bend to the edge
 EdgeRealizer createCopy(EdgeRealizer er)
          Creates a copy of this realizer type that is initialized with the attributes of the given realizer.
 Bend insertBend(double x, double y)
          Adds a new bend to this realizer and returns it.
protected  void paintHighlightedBends(Graphics2D gfx)
          Specialized paint method.
 void read(ObjectInputStream in)
          Reads in the serialized form of this realizer.
 void reInsertBend(Bend bend, Bend refBend, int dir)
          Reinserts a bend to the edge which had been removed before.
 Bend removeBend(Bend b)
          Removes a Bend of this realizer
 void write(ObjectOutputStream out)
          Writes out this realizer in a serialized form.
 
Methods inherited from class y.view.EdgeRealizer
addLabel, addPoint, appendBend, bendChanged, bendCount, bendPos, bends, bindEdge, clearBends, clearPoints, containsSeg, createCopy, createEdgeLabel, firstBend, getArrow, getBend, getEdge, getHighlightedBendColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getMinBendCount, getPath, getPoint, getSelectionColor, getSelectionStroke, getSourceArrow, getSourceIntersection, getSourcePoint, getSourcePort, getSourceRealizer, getTargetArrow, getTargetIntersection, getTargetPoint, getTargetPort, getTargetRealizer, intersects, isDirty, isSelected, isVisible, labelCount, lastBend, paint, paintArrows, paintLabels, paintPorts, paintSloppy, pathIntersects, pointCount, recalculateFeatures, removeLabel, setArrow, setDirty, setHighlightedBendColor, setLabelText, setLayer, setLineColor, setLineType, setPoint, setPorts, setSelected, setSelectionColor, setSelectionStroke, setSourceArrow, setSourcePoint, setSourcePort, setTargetArrow, setTargetPoint, setTargetPort, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BezierEdgeRealizer

public BezierEdgeRealizer()
Default Constructor.


BezierEdgeRealizer

public BezierEdgeRealizer(EdgeRealizer r)
Constrcts a new SplineEdgeRealizer as a copy of the given realizer. If the given realizer is not of the same type as this class only the known values will be copied.

Method Detail

createCopy

public EdgeRealizer createCopy(EdgeRealizer er)
Creates a copy of this realizer type that is initialized with the attributes of the given realizer.

Specified by:
createCopy in class EdgeRealizer

createBend

public Bend createBend(double x,
                       double y,
                       Bend refBend,
                       int dir)
Add a new Bend to the edge

Specified by:
createBend in class EdgeRealizer
Parameters:
x - X-coordinate of the Bend
y - Y-coordinate of the Bend
refBend - Bend which should be neighbour
dir - indicates if the new Bend should be added before (Graph.BEFORE) or after (Graph.AFTER) the refBend in the bend sequence of the edge

reInsertBend

public void reInsertBend(Bend bend,
                         Bend refBend,
                         int dir)
Description copied from class: EdgeRealizer
Reinserts a bend to the edge which had been removed before.

Specified by:
reInsertBend in class EdgeRealizer
Parameters:
bend - the bend to be reinserted
refBend - reference bend already contained in this realizer
dir - indicates whether the bend should be inserted before or after the reference bend.Allowed values are Graph.AFTER and Graph.BEFORE.

insertBend

public Bend insertBend(double x,
                       double y)
Adds a new bend to this realizer and returns it. If the given coordinate lies on the underlying bezier-polygon then the bend will be inserted in such a way that the segment splits in two parts. Otherwise the bend will be appended to the list of bends.

Specified by:
insertBend in class EdgeRealizer
Parameters:
x - X-coordinates of the bend
y - Y-coordinates of the bend

contains

public boolean contains(double x,
                        double y)
Tests whether or not the given coordinate hits the path of this realizer. The behaviour of this method depends on the selection state of this realizer. If unselected this hit-test will be performed on the bezier curve path. If selected the hit-test will be performed on the underlying bezier polyline.

Overrides:
contains in class EdgeRealizer

removeBend

public Bend removeBend(Bend b)
Removes a Bend of this realizer

Specified by:
removeBend in class EdgeRealizer
Parameters:
b - Bend to be removed

calculatePath

protected void calculatePath()
Recalculates the bezier curve path after this realizer has been marked as dirty.

Specified by:
calculatePath in class EdgeRealizer
See Also:
EdgeRealizer.path

calcUnionRect

public void calcUnionRect(Rectangle2D r)
Calculate the union of rectangle enclosed by this realizer and r. For efficency reasons the result is returned by modifying r.

Overrides:
calcUnionRect in class EdgeRealizer

paintHighlightedBends

protected void paintHighlightedBends(Graphics2D gfx)
Specialized paint method. Highlights the controlpoints and underlying bezier-polypath if edge is selected

Overrides:
paintHighlightedBends in class EdgeRealizer

write

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

Overrides:
write in class EdgeRealizer
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 BezierEdgeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class EdgeRealizer
IOException
ClassNotFoundException

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

2003