Search this API

y.view
Class QuadCurveEdgeRealizer

java.lang.Object
  extended by y.view.EdgeRealizer
      extended by y.view.QuadCurveEdgeRealizer
All Implemented Interfaces:
EdgeLayout

public class QuadCurveEdgeRealizer
extends EdgeRealizer

This realizer represents the path of an edge as a sequence of quadratic curves. The bends are interpreted as control points for the curve. The control points of this curve type do not lie on the curve itself. Every segment formed by the control points is tangential to the curve at the point lying in the middle of that segment. A straightness factor in the range [0.0d .. 1.0d] defines the portion of the segment that will fully lie on the control segment.

 

Field Summary
 
Fields inherited from class y.view.EdgeRealizer
bends, path, PATH_CLIPPED_AT_SOURCE, PATH_CLIPPED_AT_SOURCE_AND_TARGET, PATH_CLIPPED_AT_TARGET, PATH_INVISBLE, PATH_UNCLIPPED
 
Constructor Summary
QuadCurveEdgeRealizer()
          Default Constructor.
QuadCurveEdgeRealizer(EdgeRealizer r)
          Constructs a new SplineEdgeRealizer as a copy of the given realizer.
 
Method Summary
protected  byte calculatePath(java.awt.geom.Point2D sourceIntersectionOut, java.awt.geom.Point2D targetIntersectionOut)
          Recalculates the quadratic curve path after this realizer has been marked as dirty.
 void calcUnionRect(java.awt.geom.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)
          Adds a new bend before or after the given reference bend.
 EdgeRealizer createCopy(EdgeRealizer er)
          Creates a copy of this realizer type that is initialized with the attributes of the given realizer.
 double getStraightness()
          Returns the "straightness" of this realizer.
 Bend insertBend(double x, double y)
          Inserts a new bend at location (x,y) into this realizer.
 boolean intersects(java.awt.geom.Rectangle2D box)
          Checks whether the given rectangle overlaps the edge.
protected  void paintHighlightedBends(java.awt.Graphics2D gfx)
          Specialized paint method.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
 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 setStraightness(double straightness)
          Sets the "straightness" of this realizer.
 void write(java.io.ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class y.view.EdgeRealizer
addLabel, addPoint, appendBend, bendChanged, bendCount, bendPos, bends, bindEdge, calculateClippingAndIntersection, clearBends, clearPoints, containsSeg, createCopy, createEdgeLabel, firstBend, getArrow, getArrowScaleFactor, getBend, getEdge, getHighlightedBendColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getMinBendCount, getMouseInputEditorProvider, getPath, getPoint, getSelectionColor, getSelectionStroke, getSourceArrow, getSourceIntersection, getSourcePoint, getSourcePort, getSourceRealizer, getTargetArrow, getTargetIntersection, getTargetPoint, getTargetPort, getTargetRealizer, hasVisiblePath, isDirty, isLabelRenderingOrderInverted, isPathClippedAtSource, isPathClippedAtTarget, isReversedPathRenderingEnabled, isSelected, isVisible, labelBoundsChanged, labelCount, lastBend, paint, paintArrows, paintBends, paintLabels, paintPorts, paintSloppy, pathIntersects, pointCount, recalculateFeatures, registerObstacles, removeLabel, removeLabel, repaint, setArrow, setDirty, setHighlightedBendColor, setLabelRenderingOrderInverted, setLabelText, setLayer, setLineColor, setLineType, setPoint, setPorts, setReversedPathRenderingEnabled, 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

QuadCurveEdgeRealizer

public QuadCurveEdgeRealizer()
Default Constructor.


QuadCurveEdgeRealizer

public QuadCurveEdgeRealizer(EdgeRealizer r)
Constructs 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)
Adds a new bend before or after the given reference bend.

Specified by:
createBend in class EdgeRealizer
Parameters:
x - X-coordinate of the Bend
y - Y-coordinate of the Bend
refBend - Bend which should be neighbor
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)
Inserts a new bend at location (x,y) into this realizer.

If the given coordinates lie on an visible segment of the quadratic curve, a new bend will be added that splits the corresponding segment in two parts. Otherwise, no bend is created (e.g. for coordinates very far away from the quadratic curve).

Specified by:
insertBend in class EdgeRealizer
Parameters:
x - X-coordinates of the bend
y - Y-coordinates of the bend
Returns:
a new Bend instance or null if no bend was created for the given coordinates.

contains

public boolean contains(double x,
                        double y)
Tests whether or not the given coordinate hits the path of this realizer. The behavior 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 byte calculatePath(java.awt.geom.Point2D sourceIntersectionOut,
                             java.awt.geom.Point2D targetIntersectionOut)
Recalculates the quadratic curve path after this realizer has been marked as dirty.

Specified by:
calculatePath in class EdgeRealizer
Parameters:
sourceIntersectionOut - output parameter for the coordinates of the source intersection point calculated by this method.
targetIntersectionOut - output parameter for the coordinates of the target intersection point calculated by this method.
Returns:
either EdgeRealizer.PATH_UNCLIPPED, EdgeRealizer.PATH_CLIPPED_AT_SOURCE, EdgeRealizer.PATH_CLIPPED_AT_TARGET, or EdgeRealizer.PATH_CLIPPED_AT_SOURCE_AND_TARGET
See Also:
EdgeRealizer.path, EdgeRealizer.isPathClippedAtSource(), EdgeRealizer.isPathClippedAtTarget()

intersects

public boolean intersects(java.awt.geom.Rectangle2D box)
Description copied from class: EdgeRealizer
Checks whether the given rectangle overlaps the edge. This method should be overridden by subclasses. This method assumes that we have straight lines with bends.

Overrides:
intersects in class EdgeRealizer
Parameters:
box - The box that has to be checked on intersection with this edge.

calcUnionRect

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

Overrides:
calcUnionRect in class EdgeRealizer

paintHighlightedBends

protected void paintHighlightedBends(java.awt.Graphics2D gfx)
Specialized paint method. Highlights the control points and underlying bezier poly path if edge is selected

Overrides:
paintHighlightedBends in class EdgeRealizer

write

public void write(java.io.ObjectOutputStream out)
           throws java.io.IOException
Deprecated. Use the GraphML format instead.

Writes out this realizer in a serialized form.

Overrides:
write in class EdgeRealizer
Throws:
java.io.IOException

read

public void read(java.io.ObjectInputStream in)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Deprecated. Use the GraphML format instead.

Reads in the serialized form of this realizer. The realizer must have been written out before by it's write(ObjectOutputStream) method.

Overrides:
read in class EdgeRealizer
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getStraightness

public double getStraightness()
Returns the "straightness" of this realizer. Valid values lie in the range [0.0d .. 1.0d] where 1.0d results in a polyline drawing and otherwise determines the portion of the segments that fall together with the corresponding segments of the control polygon. The default is 0.10d.

Returns:
the straightness [0.0d .. 1.0d]

setStraightness

public void setStraightness(double straightness)
Sets the "straightness" of this realizer. Valid values lie in the range [0.0d .. 1.0d] where 1.0d results in a polyline drawing and otherwise determines the portion of the segments that fall together with the corresponding segments of the control polygon. The default is 0.10d.

Parameters:
straightness - the straightness [0.0d .. 1.0d]

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