Search this API

y.view
Class EdgeRealizer

java.lang.Object
  extended by y.view.EdgeRealizer
All Implemented Interfaces:
EdgeLayout
Direct Known Subclasses:
ArcEdgeRealizer, BezierEdgeRealizer, GenericEdgeRealizer, PolyLineEdgeRealizer, QuadCurveEdgeRealizer, SplineEdgeRealizer

public abstract class EdgeRealizer
extends java.lang.Object
implements EdgeLayout

Abstract graphical representation of an edge. This class provides methods to draw an edge. For this to happen an edge must be bound to the realizer. This can be done by calling Graph2D.setRealizer(Edge,EdgeRealizer)

An edge realizer allows the use of control points, so called bends. These bends influence the graphical path of the edge.

 

Field Summary
protected  BendList bends
          The list where bends are stored.
protected  java.awt.geom.GeneralPath path
          The graphical path of this realizer that will be drawn.
static byte PATH_CLIPPED_AT_SOURCE
          Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D).
static byte PATH_CLIPPED_AT_SOURCE_AND_TARGET
          Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D).
static byte PATH_CLIPPED_AT_TARGET
          Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D).
static byte PATH_INVISBLE
          Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D).
static byte PATH_UNCLIPPED
          Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D).
 
Constructor Summary
protected EdgeRealizer()
          Instantiates a new EdgeRealizer with default values.
protected EdgeRealizer(EdgeRealizer argEdgeRealizer)
          Instantiates a new EdgeRealizer as a copy of the given edge realizer.
 
Method Summary
 void addLabel(EdgeLabel label)
          Adds the given edge label to this realizer.
 void addPoint(double x, double y)
          EdgeLayout interface implementation.
 Bend appendBend(double x, double y)
          Appends a newly created bend at location (x,y) to the list of bends.
 void bendChanged(Bend b, double oldX, double oldY)
          Informs the edge, that a bend has changed position By default this method does nothing.
 int bendCount()
          Returns the number of bends of this realizer.
 int bendPos(Bend b)
          Returns the index of the bend in the bend sequence.
 BendCursor bends()
          Returns a cursor over all bends of this realizer.
protected  void bindEdge(Edge e)
          Binds an actual edge to this realizer.
static byte calculateClippingAndIntersection(EdgeRealizer er, java.awt.geom.GeneralPath path, java.awt.geom.GeneralPath result, java.awt.geom.Point2D sourceIntersectionOut, java.awt.geom.Point2D targetIntersectionOut)
          Static helper method that can be used as a convenience to calculate a clipped version of a GeneralPath for an EdgeRealizer.
protected abstract  byte calculatePath(java.awt.geom.Point2D sourceIntersectionOut, java.awt.geom.Point2D targetIntersectionOut)
          Calculates the visible path of this realizer.
 void calcUnionRect(java.awt.geom.Rectangle2D r)
          Calculates the union of rectangle enclosed by this realizer and r.
 void clearBends()
          Removes all bends from this realizer.
 void clearPoints()
          EdgeLayout interface implementation.
 boolean contains(double x, double y)
          Query if the visible path of this realizer contains the point (x,y).
 int containsSeg(double dx, double dy)
          like contains(), but returns number of the hit segment, 0 otherwise.
abstract  Bend createBend(double x, double y, Bend refBend, int dir)
          Adds a new bend before or after the given reference bend.
 EdgeRealizer createCopy()
          Returns a copy of this realizer that is not bound to any edge.
abstract  EdgeRealizer createCopy(EdgeRealizer er)
          Returns a realizer of the same type as this realizer, that adopts as many attributes as possible from the given realizer.
 EdgeLabel createEdgeLabel()
          Creates a new edge label that can be added to this realizer.
 Bend firstBend()
          Returns the first bend of the edge, null if the edge has none.
 Arrow getArrow()
          Returns the arrow type at the target location of the edge path.
 double getArrowScaleFactor()
          Calculates and returns the scaling factor of the arrows using the currently set LineType.
 Bend getBend(int index)
          Returns the bend at the given positional index.
 Edge getEdge()
          Returns the edge bound to this realizer.
static java.awt.Color getHighlightedBendColor()
          Returns the color of all highlighted bends.
 EdgeLabel getLabel()
          Returns the first label associated with this realizer.
 EdgeLabel getLabel(int i)
          Returns the i-th label of this realizer.
 java.lang.String getLabelText()
          Returns the text of the associated label of this realizer.
 byte getLayer()
          Returns the logical graphical layer for this realizer.
 java.awt.Color getLineColor()
          Returns the line color of the edge path.
 LineType getLineType()
          Returns the line type of the edge path.
 int getMinBendCount()
          Returns the minimal number of bends the edge must have.
 MouseInputEditorProvider getMouseInputEditorProvider()
          Returns a provider, that can be used to query for a mouse input editor for this realizer.
 java.awt.geom.GeneralPath getPath()
          Returns the visible path of the edge as it will be drawn on a graphics context.
 YPoint getPoint(int index)
          EdgeLayout interface implementation.
static java.awt.Color getSelectionColor()
          Returns the color of all selected edges.
static java.awt.Stroke getSelectionStroke()
          Returns the stroke of the selected edge.
 Arrow getSourceArrow()
          Returns the arrow at the source location of the edge path.
 java.awt.geom.Point2D getSourceIntersection()
          Returns the intersection point between this realizer and the source node realizer.
 YPoint getSourcePoint()
          EdgeLayout interface implementation.
 Port getSourcePort()
          Returns the source port of this edge realizer.
 NodeRealizer getSourceRealizer()
          Returns the node realizer that is bound to the source node of the underlying edge.
 Arrow getTargetArrow()
          Returns the arrow type at the target location of the edge path.
 java.awt.geom.Point2D getTargetIntersection()
          Returns the intersection point between this realizer and the target node realizer.
 YPoint getTargetPoint()
          EdgeLayout interface implementation.
 Port getTargetPort()
          Returns the target port of this edge realizer.
 NodeRealizer getTargetRealizer()
          Returns the node realizer that is bound to the target node of the underlying edge.
 boolean hasVisiblePath()
          Determines whether this realizer is both visible and has a currently visible, non-empty path.
abstract  Bend insertBend(double x, double y)
          Inserts a new bend into this realizer and returns it.
 boolean intersects(java.awt.geom.Rectangle2D box)
          Checks whether the given rectangle overlaps the edge.
protected  boolean isDirty()
          Whether or not this realizer requires an update of it's graphical representation.
static boolean isLabelRenderingOrderInverted()
          Returns whether or not the rendering order of the labels is inverted.
 boolean isPathClippedAtSource()
          Returns whether the calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D) method indicated that the calculated path had been clipped at the source side of the path in order to account for the length of the source arrow.
 boolean isPathClippedAtTarget()
          Returns whether the calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D) method indicated that the calculated path had been clipped at the source side of the path in order to account for the length of the source arrow.
 boolean isReversedPathRenderingEnabled()
          Returns whether or not to render the path in reversed direction.
 boolean isSelected()
          Returns the selected state of this realizer.
 boolean isVisible()
          Returns the visibility state of this realizer.
protected  void labelBoundsChanged()
          Callback method that should be overwritten by subclasses, that are interested in changes of the realizer's label bounds.
 int labelCount()
          Returns the number of labels associated with this realizer.
 Bend lastBend()
          Returns the last bend of the edge, null if the edge has none.
 void paint(java.awt.Graphics2D gfx)
          Paints this realizer on the given graphics context.
protected  void paintArrows(java.awt.Graphics2D g)
          Paints the arrows of this realizer.
protected  void paintBends(java.awt.Graphics2D gfx)
          Paints the bends if they are in selected state.
protected  void paintHighlightedBends(java.awt.Graphics2D gfx)
          Paints the bends if this realizer is in a selected state
protected  void paintLabels(java.awt.Graphics2D gfx)
          Paints the labels belonging to this realizer.
protected  void paintPorts(java.awt.Graphics2D gfx)
          Paints the ports of this realizer.
 void paintSloppy(java.awt.Graphics2D g)
          Paints this realizer in a quick and rather sloppy way.
 boolean pathIntersects(java.awt.geom.Rectangle2D box, boolean considerLabels)
          This method complements the contains(double,double) method.
 int pointCount()
          EdgeLayout interface implementation.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
protected  void recalculateFeatures()
          Recalculates all features.
 void registerObstacles(BridgeCalculator calculator)
          This callback method is e.g. by DefaultGraph2DRenderer if a BridgeCalculator is used for the rendering whose crossing mode is set to values other than BridgeCalculator.CROSSING_MODE_ORDER_INDUCED.
abstract  void reInsertBend(Bend bend, Bend refBend, int dir)
          Reinserts a bend to the edge which had been removed before.
abstract  Bend removeBend(Bend b)
          Removes a Bend of this realizer.
 void removeLabel(EdgeLabel label)
          Removes the given edge label from this realizer.
 void removeLabel(int i)
          Removes the i-th edge label from this realizer.
 void repaint()
          Repaints this realizer.
 void setArrow(Arrow arrow)
          Sets the arrow type at the target location of the edge path.
 void setDirty()
          Marks this realizer as dirty.
static void setHighlightedBendColor(java.awt.Color color)
          Sets the color of all highlighted bends.
static void setLabelRenderingOrderInverted(boolean isInverted)
          Specifies whether or not the rendering order of the labels is inverted.
 void setLabelText(java.lang.String label)
          Sets the text of the associated label for this realizer.
 void setLayer(byte l)
          Sets the logical graphical layer for this realizer.
 void setLineColor(java.awt.Color c)
          Sets the line color of the edge path.
 void setLineType(LineType t)
          Sets the line type for the edge path.
 void setPoint(int index, double x, double y)
          EdgeLayout interface implementation.
 void setPorts(Port sourceP, Port targetP)
          Sets the specified source- and target-port for this edge realizer.
 void setReversedPathRenderingEnabled(boolean enabled)
          Specifies whether or not to render the path in reversed direction.
 void setSelected(boolean s)
          Sets the selected state of this realizer.
static void setSelectionColor(java.awt.Color color)
          Sets the color of all selected edges.
static void setSelectionStroke(LineType t)
          Sets the stroke of a selected edges.
 void setSourceArrow(Arrow arrow)
          Sets the arrow at the source location of the edge path.
 void setSourcePoint(YPoint point)
          EdgeLayout interface implementation.
 void setSourcePort(Port p)
          Sets the specified source port to this edge realizer.
 void setTargetArrow(Arrow arrow)
          Sets the arrow type at the target location of the edge path.
 void setTargetPoint(YPoint point)
          EdgeLayout interface implementation.
 void setTargetPort(Port p)
          Sets the specified target port to this edge realizer.
 void setVisible(boolean visible)
          Sets the visibility state of this realizer.
 void write(java.io.ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_UNCLIPPED

public static final byte PATH_UNCLIPPED
Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D). This value indicates that neither the source end nor the target end of the calculated path took into account the length of the arrows.

See Also:
Constant Field Values

PATH_CLIPPED_AT_SOURCE

public static final byte PATH_CLIPPED_AT_SOURCE
Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D). This value indicates that the source end but not the target end of the calculated path took into account the length of the corresponding arrows. This constant can be bitwise combined with PATH_CLIPPED_AT_TARGET to produce PATH_CLIPPED_AT_SOURCE_AND_TARGET.

See Also:
Constant Field Values

PATH_CLIPPED_AT_TARGET

public static final byte PATH_CLIPPED_AT_TARGET
Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D). This value indicates that the target end but not the source end of the calculated path took into account the length of the corresponding arrows. This constant can be bitwise combined with PATH_CLIPPED_AT_SOURCE to produce PATH_CLIPPED_AT_SOURCE_AND_TARGET.

See Also:
Constant Field Values

PATH_CLIPPED_AT_SOURCE_AND_TARGET

public static final byte PATH_CLIPPED_AT_SOURCE_AND_TARGET
Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D). This value indicates that both the source end and the target end of the calculated path took into account the length of the arrows. This value is the bitwise combination of with PATH_CLIPPED_AT_SOURCE and PATH_CLIPPED_AT_TARGET.

See Also:
Constant Field Values

PATH_INVISBLE

public static final byte PATH_INVISBLE
Possible return value of calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D). This value indicates that the calculation yielded an empty path because the whole path had been clipped.

See Also:
Constant Field Values

bends

protected BendList bends
The list where bends are stored.


path

protected java.awt.geom.GeneralPath path
The graphical path of this realizer that will be drawn.

Constructor Detail

EdgeRealizer

protected EdgeRealizer()
Instantiates a new EdgeRealizer with default values.


EdgeRealizer

protected EdgeRealizer(EdgeRealizer argEdgeRealizer)
Instantiates a new EdgeRealizer as a copy of the given edge realizer.

Method Detail

createCopy

public EdgeRealizer createCopy()
Returns a copy of this realizer that is not bound to any edge.

This method simply returns createCopy(this).


createCopy

public abstract EdgeRealizer createCopy(EdgeRealizer er)
Returns a realizer of the same type as this realizer, that adopts as many attributes as possible from the given realizer.

Subclass realizers should always implement or overwrite this method, to guarantee correct copy behavior of the realizer.

Note: This method must not return null.


bindEdge

protected void bindEdge(Edge e)
Binds an actual edge to this realizer. Without a bound edge this realizer is NOT fully functional.


getTargetRealizer

public NodeRealizer getTargetRealizer()
Returns the node realizer that is bound to the target node of the underlying edge. This method is only valid if an edge is bound to this realizer.


getSourceRealizer

public NodeRealizer getSourceRealizer()
Returns the node realizer that is bound to the source node of the underlying edge. This method is only valid if an edge is bound to this realizer.


getEdge

public Edge getEdge()
Returns the edge bound to this realizer.


setPorts

public void setPorts(Port sourceP,
                     Port targetP)
Sets the specified source- and target-port for this edge realizer.


setSourcePort

public void setSourcePort(Port p)
Sets the specified source port to this edge realizer.


setTargetPort

public void setTargetPort(Port p)
Sets the specified target port to this edge realizer.


getSourcePort

public Port getSourcePort()
Returns the source port of this edge realizer.


getTargetPort

public Port getTargetPort()
Returns the target port of this edge realizer.


createBend

public abstract Bend createBend(double x,
                                double y,
                                Bend refBend,
                                int dir)
Adds a new bend before or after the given reference bend.

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 abstract void reInsertBend(Bend bend,
                                  Bend refBend,
                                  int dir)
Reinserts a bend to the edge which had been removed before.

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 abstract Bend insertBend(double x,
                                double y)
Inserts a new bend into 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 segments splits in two parts. Otherwise the bend will be appended to the list of bends.

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.

removeBend

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

Parameters:
b - Bend to be removed

bendChanged

public void bendChanged(Bend b,
                        double oldX,
                        double oldY)
Informs the edge, that a bend has changed position By default this method does nothing.

Parameters:
b - Bend which has changed position
oldX - previous x-coordinate
oldY - previous y-coordinate

labelBoundsChanged

protected void labelBoundsChanged()
Callback method that should be overwritten by subclasses, that are interested in changes of the realizer's label bounds. This method is called after the bounds of an EdgeLabel (position or size) have changed.


appendBend

public Bend appendBend(double x,
                       double y)
Appends a newly created bend at location (x,y) to the list of bends.

Parameters:
x - X-coordinates of bend
y - Y-coordinates of bend

bendPos

public int bendPos(Bend b)
Returns the index of the bend in the bend sequence. If the bend is not part of the edge a value < 0 is returned.

Parameters:
b - the bend in question

bendCount

public int bendCount()
Returns the number of bends of this realizer.


getBend

public Bend getBend(int index)
Returns the bend at the given positional index. The first bend in the sequence has index 0 and consequently the last bend has index bendCount() - 1.

Parameters:
index - position of the Bend in the bend sequence

bends

public BendCursor bends()
Returns a cursor over all bends of this realizer.


firstBend

public Bend firstBend()
Returns the first bend of the edge, null if the edge has none.


lastBend

public Bend lastBend()
Returns the last bend of the edge, null if the edge has none.


getMinBendCount

public int getMinBendCount()
Returns the minimal number of bends the edge must have. The return value defaults to 0.


clearBends

public void clearBends()
Removes all bends from this realizer.


getPoint

public YPoint getPoint(int index)
EdgeLayout interface implementation.

Specified by:
getPoint in interface EdgeLayout
Parameters:
index - the position of the control point in the control point sequence
Returns:
the absolute coordinates of the control point at the given index
See Also:
EdgeLayout.getPoint(int)

pointCount

public int pointCount()
EdgeLayout interface implementation.

Specified by:
pointCount in interface EdgeLayout
Returns:
the number of control points
See Also:
EdgeLayout.pointCount()

getSourcePoint

public YPoint getSourcePoint()
EdgeLayout interface implementation. The source point will be mapped onto the source port of this realizer.

Specified by:
getSourcePoint in interface EdgeLayout
Returns:
the relative coordinates of the source point
See Also:
EdgeLayout.getSourcePoint()

getTargetPoint

public YPoint getTargetPoint()
EdgeLayout interface implementation. The target point will be mapped onto the target port of this realizer.

Specified by:
getTargetPoint in interface EdgeLayout
Returns:
the relative coordinates of the target point
See Also:
EdgeLayout.getTargetPoint()

setSourcePoint

public void setSourcePoint(YPoint point)
EdgeLayout interface implementation. The source point will be mapped onto the source port of this realizer.

Specified by:
setSourcePoint in interface EdgeLayout
Parameters:
point - the new relative coordinates of the source point
See Also:
EdgeLayout.setSourcePoint(YPoint)

setTargetPoint

public void setTargetPoint(YPoint point)
EdgeLayout interface implementation. The target point will be mapped onto the target port of this realizer.

Specified by:
setTargetPoint in interface EdgeLayout
Parameters:
point - the new relative coordinates of the target point
See Also:
EdgeLayout.setTargetPoint(YPoint)

setPoint

public void setPoint(int index,
                     double x,
                     double y)
EdgeLayout interface implementation. Points will be mapped onto bends of this realizer.

Specified by:
setPoint in interface EdgeLayout
Parameters:
index - the position of the changing control point in the sequence
x - the new absolute x-coordinate of the control point at the given index
y - the new absolute y-coordinate of the control point at the given index
See Also:
EdgeLayout.setPoint(int,double,double)

addPoint

public void addPoint(double x,
                     double y)
EdgeLayout interface implementation. Points will be mapped onto bends of this realizer.

Specified by:
addPoint in interface EdgeLayout
Parameters:
x - the absolute x-coordinate of the new control point
y - the absolute y-coordinate of the new control point
See Also:
EdgeLayout.addPoint(double,double)

clearPoints

public void clearPoints()
EdgeLayout interface implementation. Points will be mapped onto bends of this realizer.

Specified by:
clearPoints in interface EdgeLayout
See Also:
EdgeLayout.clearPoints()

registerObstacles

public void registerObstacles(BridgeCalculator calculator)
This callback method is e.g. by DefaultGraph2DRenderer if a BridgeCalculator is used for the rendering whose crossing mode is set to values other than BridgeCalculator.CROSSING_MODE_ORDER_INDUCED. Implementations should use the provided calculator instance to call BridgeCalculator.registerObstacles(java.awt.geom.PathIterator) using the getPath() method for example or BridgeCalculator.registerObstacleLine(double, double, double, double) directly to add obstacle lines for the calculation directly. This implementation does nothing.

Parameters:
calculator - the calculator instance used for the next rendering pass.

paintSloppy

public void paintSloppy(java.awt.Graphics2D g)
Paints this realizer in a quick and rather sloppy way. Useful if a small zoom level is applied to the graphics context.


repaint

public void repaint()
Repaints this realizer.


paint

public void paint(java.awt.Graphics2D gfx)
Paints this realizer on the given graphics context.


paintHighlightedBends

protected void paintHighlightedBends(java.awt.Graphics2D gfx)
Paints the bends if this realizer is in a selected state


paintBends

protected void paintBends(java.awt.Graphics2D gfx)
Paints the bends if they are in selected state.


paintPorts

protected void paintPorts(java.awt.Graphics2D gfx)
Paints the ports of this realizer.


paintArrows

protected void paintArrows(java.awt.Graphics2D g)
Paints the arrows of this realizer.


getArrowScaleFactor

public double getArrowScaleFactor()
Calculates and returns the scaling factor of the arrows using the currently set LineType.

Returns:
the scaling factor by which the arrows should be scaled.

paintLabels

protected void paintLabels(java.awt.Graphics2D gfx)
Paints the labels belonging to this realizer.


calculatePath

protected abstract byte calculatePath(java.awt.geom.Point2D sourceIntersectionOut,
                                      java.awt.geom.Point2D targetIntersectionOut)
Calculates the visible path of this realizer. Subclasses need to implement this. Implementations have to set the source intersection point and target intersection point via the out-parameters. This method returns whether the calculated path takes into account the length of the source and/or target arrow. Implementations of this method may use the calculateClippingAndIntersection(EdgeRealizer, java.awt.geom.GeneralPath, java.awt.geom.GeneralPath, java.awt.geom.Point2D, java.awt.geom.Point2D) method to perform the clipping.

Parameters:
sourceIntersectionOut - a Point2D instance that must be set by the implementation to point to the source intersection point unless the path is empty.
targetIntersectionOut - a Point2D instance that must be set by the implementation to point to the target intersection point unless the path is empty.
Returns:
either PATH_UNCLIPPED, PATH_CLIPPED_AT_SOURCE, PATH_CLIPPED_AT_TARGET, or PATH_CLIPPED_AT_SOURCE_AND_TARGET
See Also:
path, isPathClippedAtSource(), isPathClippedAtTarget()

calculateClippingAndIntersection

public static final byte calculateClippingAndIntersection(EdgeRealizer er,
                                                          java.awt.geom.GeneralPath path,
                                                          java.awt.geom.GeneralPath result,
                                                          java.awt.geom.Point2D sourceIntersectionOut,
                                                          java.awt.geom.Point2D targetIntersectionOut)
Static helper method that can be used as a convenience to calculate a clipped version of a GeneralPath for an EdgeRealizer. This implementation will clip the path at the source and target node and will automatically take into account the lengths of the source and target arrow. It will put the resulting intersection points into the out parameters provided and return one of the constants as required for the calculatePath(java.awt.geom.Point2D, java.awt.geom.Point2D) method.

Parameters:
er - the EdgeRealizer which serves as the context of the path
path - a GeneralPath instance that will be flattened and appropriately clipped.
result - the GeneralPath instance that will store the result. This can be the same instance as path. It will be initially Path2D.reset()
sourceIntersectionOut - the out parameter that will contain the source intersection point after the method has completed
targetIntersectionOut - the out parameter that will contain the target intersection point after the method has completed
Returns:
either PATH_UNCLIPPED, PATH_CLIPPED_AT_SOURCE, PATH_CLIPPED_AT_TARGET, or PATH_CLIPPED_AT_SOURCE_AND_TARGET

recalculateFeatures

protected final void recalculateFeatures()
Recalculates all features. This should be called before the realizer gets painted in case it is marked as dirty.


hasVisiblePath

public boolean hasVisiblePath()
Determines whether this realizer is both visible and has a currently visible, non-empty path.


getSourceIntersection

public java.awt.geom.Point2D getSourceIntersection()
Returns the intersection point between this realizer and the source node realizer. The intersection point is given in absolute world coordinates.

Precondition:
a bound edge

getTargetIntersection

public java.awt.geom.Point2D getTargetIntersection()
Returns the intersection point between this realizer and the target node realizer. The intersection point is given in absolute world coordinates.

Precondition:
a bound edge

isReversedPathRenderingEnabled

public boolean isReversedPathRenderingEnabled()
Returns whether or not to render the path in reversed direction.

By default this feature is disabled.

Returns:
true if the visual path will be rendered from target to source end and false if it will be rendered from source to target end.
See Also:
setReversedPathRenderingEnabled(boolean)

setReversedPathRenderingEnabled

public void setReversedPathRenderingEnabled(boolean enabled)
Specifies whether or not to render the path in reversed direction.

By default this feature is disabled.

Parameters:
enabled - if true the visual path will be rendered from target to source end; otherwise it will be rendered from source to target end.
See Also:
isReversedPathRenderingEnabled()

getLineColor

public java.awt.Color getLineColor()
Returns the line color of the edge path.

This attribute defaults to Color.black.

See Also:
setLineColor(java.awt.Color)

setLineColor

public void setLineColor(java.awt.Color c)
Sets the line color of the edge path.

This attribute defaults to Color.black.

See Also:
getLineColor()

getSelectionColor

public static java.awt.Color getSelectionColor()
Returns the color of all selected edges.

By default the color Color.orange is returned.

See Also:
setSelectionColor(java.awt.Color)

setSelectionColor

public static void setSelectionColor(java.awt.Color color)
Sets the color of all selected edges.

By default the color Color.cyan is set.

See Also:
getSelectionColor()

setHighlightedBendColor

public static void setHighlightedBendColor(java.awt.Color color)
Sets the color of all highlighted bends.

By default the color Color.green is set.

See Also:
getHighlightedBendColor()

getHighlightedBendColor

public static java.awt.Color getHighlightedBendColor()
Returns the color of all highlighted bends.

By default the color Color.green is returned.

See Also:
setHighlightedBendColor(java.awt.Color)

setLabelRenderingOrderInverted

public static void setLabelRenderingOrderInverted(boolean isInverted)
Specifies whether or not the rendering order of the labels is inverted.

By default the rendering order is inverted that means the last inserted label is rendered first.

See Also:
isLabelRenderingOrderInverted()

isLabelRenderingOrderInverted

public static boolean isLabelRenderingOrderInverted()
Returns whether or not the rendering order of the labels is inverted.

By default the rendering order is inverted that means the last inserted label is rendered first.

See Also:
setLabelRenderingOrderInverted(boolean)

getLineType

public LineType getLineType()
Returns the line type of the edge path.

This attribute defaults to LineType.LINE_1.

See Also:
setLineType(LineType)

setLineType

public void setLineType(LineType t)
Sets the line type for the edge path.

This attribute defaults to LineType.LINE_1.

See Also:
getLineType()

setSelectionStroke

public static void setSelectionStroke(LineType t)
Sets the stroke of a selected edges.

This attribute defaults to LineType.LINE_5.

See Also:
getSelectionStroke()

getSelectionStroke

public static java.awt.Stroke getSelectionStroke()
Returns the stroke of the selected edge.

This attribute defaults to LineType.LINE_5.

See Also:
setSelectionStroke(LineType)

getArrow

public Arrow getArrow()
Returns the arrow type at the target location of the edge path. Same as getTargetArrow().

This attribute defaults to Arrow.NONE.

See Also:
setTargetArrow(Arrow), getSourceArrow(), setSourceArrow(Arrow)

setArrow

public void setArrow(Arrow arrow)
Sets the arrow type at the target location of the edge path. Calls setTargetArrow(Arrow).

This attribute defaults to Arrow.NONE.

See Also:
getTargetArrow(), setTargetArrow(Arrow), getSourceArrow(), setSourceArrow(Arrow)

getTargetArrow

public Arrow getTargetArrow()
Returns the arrow type at the target location of the edge path.

This attribute defaults to Arrow.NONE.

See Also:
setTargetArrow(Arrow), getSourceArrow(), setSourceArrow(Arrow)

setTargetArrow

public void setTargetArrow(Arrow arrow)
Sets the arrow type at the target location of the edge path.

This attribute defaults to Arrow.NONE.

See Also:
getTargetArrow(), getSourceArrow(), setSourceArrow(Arrow)

getSourceArrow

public Arrow getSourceArrow()
Returns the arrow at the source location of the edge path.

This attribute defaults to Arrow.NONE.

See Also:
setSourceArrow(Arrow), getTargetArrow(), setTargetArrow(Arrow)

setSourceArrow

public void setSourceArrow(Arrow arrow)
Sets the arrow at the source location of the edge path.

This attribute defaults to Arrow.NONE.

See Also:
getSourceArrow(), getTargetArrow(), setTargetArrow(Arrow)

setLayer

public void setLayer(byte l)
Sets the logical graphical layer for this realizer. Layer information can be used by viewers to optimize redraws.

See Also:
Graph2DView.FG_LAYER, Graph2DView.BG_LAYER

getLayer

public byte getLayer()
Returns the logical graphical layer for this realizer. Layer information can be used by viewers to optimize redraws.

See Also:
Graph2DView.FG_LAYER, Graph2DView.BG_LAYER

setVisible

public void setVisible(boolean visible)
Sets the visibility state of this realizer. A realizer will paint itself if and only if it is visible. By default a realizer is visible.


isVisible

public boolean isVisible()
Returns the visibility state of this realizer.


isPathClippedAtSource

public boolean isPathClippedAtSource()
Returns whether the calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D) method indicated that the calculated path had been clipped at the source side of the path in order to account for the length of the source arrow. This information is queried by paintArrows(java.awt.Graphics2D).


isPathClippedAtTarget

public boolean isPathClippedAtTarget()
Returns whether the calculatePath(java.awt.geom.Point2D,java.awt.geom.Point2D) method indicated that the calculated path had been clipped at the source side of the path in order to account for the length of the source arrow. This information is queried by paintArrows(java.awt.Graphics2D).


setSelected

public void setSelected(boolean s)
Sets the selected state of this realizer. A selected edge will be painted in a highlighted fashion. By default a realizer is not selected.


isSelected

public boolean isSelected()
Returns the selected state of this realizer.


setDirty

public void setDirty()
Marks this realizer as dirty. This causes recalculation of the visible path upon paint requests. Typically needed when source or target node of the bound edge changed state or bends changed. Also the label offset has to be recalculated.


isDirty

protected boolean isDirty()
Whether or not this realizer requires an update of it's graphical representation. This method should be called whenever a change occurs that modifies the visible path of the realizer.


getPath

public java.awt.geom.GeneralPath getPath()
Returns the visible path of the edge as it will be drawn on a graphics context. Precondition: a bound edge


getMouseInputEditorProvider

public MouseInputEditorProvider getMouseInputEditorProvider()
Returns a provider, that can be used to query for a mouse input editor for this realizer. The default implementation returns this realizer, if it implements the MouseInputEditorProvider interface.

Returns:
an implementation of interface MouseInputEditorProvider or null, if no such provider is bound to this realizer.

addLabel

public void addLabel(EdgeLabel label)
Adds the given edge label to this realizer.


removeLabel

public void removeLabel(EdgeLabel label)
Removes the given edge label from this realizer.

Parameters:
label - the edge label to remove from this realizer.
See Also:
removeLabel(int)

removeLabel

public void removeLabel(int i)
Removes the i-th edge label from this realizer.

Parameters:
i - the index of the edge label to remove.
Throws:
java.lang.IndexOutOfBoundsException - if i >= labelCount or i < 0.
See Also:
removeLabel(EdgeLabel)

getLabel

public EdgeLabel getLabel()
Returns the first label associated with this realizer. If no label is associated with this realizer, a default label will be created, added to the realizer, and returned.


labelCount

public int labelCount()
Returns the number of labels associated with this realizer.


getLabel

public EdgeLabel getLabel(int i)
Returns the i-th label of this realizer.


setLabelText

public void setLabelText(java.lang.String label)
Sets the text of the associated label for this realizer.


getLabelText

public java.lang.String getLabelText()
Returns the text of the associated label of this realizer.


createEdgeLabel

public EdgeLabel createEdgeLabel()
Creates a new edge label that can be added to this realizer.


contains

public boolean contains(double x,
                        double y)
Query if the visible path of this realizer contains the point (x,y). Essentially a hit test.


containsSeg

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


calcUnionRect

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


pathIntersects

public boolean pathIntersects(java.awt.geom.Rectangle2D box,
                              boolean considerLabels)
This method complements the contains(double,double) method. Its primary use is for checking whether or not an edge lies within the bounds of a selection box.

Parameters:
box - the box that will be used for the intersection test
considerLabels - if true, labels will be considered
Returns:
if any segment or label intersects the given box

intersects

public boolean intersects(java.awt.geom.Rectangle2D box)
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.

Parameters:
box - The box that has to be checked on intersection with this edge.

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.

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.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

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