y.view
Class PolyLineEdgeRealizer

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

public class PolyLineEdgeRealizer
extends EdgeRealizer

An edge realizer that displays an edge as a polyline. A polyline consists of a sequence of straigt line segments. The position of the bends determine the junction points of these segments. A special feature of this realizer is to draw a circular shaped edgepath for selfloop edges that to no contain any bends.


Field Summary
 
Fields inherited from class y.view.EdgeRealizer
bends, path
 
Constructor Summary
PolyLineEdgeRealizer()
          Constructs a new PolyLineEdgeRealizer with no bends.
PolyLineEdgeRealizer(EdgeRealizer er)
          Constructs a new PolyLineEdgeRealizer as a copy of the given realizer.
 
Method Summary
protected  void calculatePath()
          Calculates the visible path of this realizer.
 int containsSeg(double dx, double dy)
          like contains(), but returns number of the hit segment, 0 otherwise.
 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.
 boolean getSmoothedBends()
          Returns whether or not to draw bends in a smoothed fashion.
 Bend insertBend(double x, double y)
          Adds a new bend to this realizer and returns it.
 boolean pathIntersects(Rectangle2D box, boolean considerLabels)
          This method complements the EdgeRealizer.contains(double,double) 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 setSmoothedBends(boolean b)
          Sets whether or not to draw bends in a smoothed fashion.
 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, calcUnionRect, clearBends, clearPoints, contains, 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, paintHighlightedBends, paintLabels, paintPorts, paintSloppy, 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

PolyLineEdgeRealizer

public PolyLineEdgeRealizer()
Constructs a new PolyLineEdgeRealizer with no bends.


PolyLineEdgeRealizer

public PolyLineEdgeRealizer(EdgeRealizer er)
Constructs a new PolyLineEdgeRealizer 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

setSmoothedBends

public void setSmoothedBends(boolean b)
Sets whether or not to draw bends in a smoothed fashion.


getSmoothedBends

public boolean getSmoothedBends()
Returns whether or not to draw bends in a smoothed fashion. By default bends are drawn regularly.


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 an visible segment of the path, 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

removeBend

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

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

containsSeg

public int containsSeg(double dx,
                       double dy)
like contains(), but returns number of the hit segment, 0 otherwise.

Overrides:
containsSeg in class EdgeRealizer

pathIntersects

public boolean pathIntersects(Rectangle2D box,
                              boolean considerLabels)
Description copied from class: EdgeRealizer
This method complements the EdgeRealizer.contains(double,double) method. Its primary use is for checking whether or not an edge lies within the bounds of a selection box.

Overrides:
pathIntersects in class EdgeRealizer
Parameters:
box - the box that will be used for the intersectiontest
considerLabels - if true, labels will be considered
Returns:
if any segment or label intersects the given box

calculatePath

protected void calculatePath()
Calculates the visible path of this realizer.

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

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 PolyLineEdgeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class EdgeRealizer
IOException
ClassNotFoundException

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

2003