public class ConnectionWidget extends Widget(Code)
This class represents a connection between two location. The locations are resolved by Anchors.
The path of the connection is specified by control points which are resolved by Routers (DirectRouter is used by default).
The connection is rendered using the foreground color and a specified stroke. It also renders control points,
end points (first and last control points) and anchors. The shape of points are defined by assigned AnchorShape and PointShape.
For speed optimalization, the connection widget are usually placed in the a separate layer widget that is rendered after
the main layer with widgets (that used anchors depends on) is rendered.
Line color is defined by foregroundColor property. Note: If you are changing a state of the ConnectionWidget
(e.g. using it as a representation of an object in ObjectScene, GraphScene or GraphPinScene classes,
then the ConnectionWidget.notifyStateChanged method is automatically called.
The built-in implementation of this method overrides foregroundColor based on a new state of the widget
(the particular color is resolved by the LookFeel of the scene).
author: David Kaspar
Returns a location of control point at the specified index in the list of control points.
Parameters: index - index of the control point to return the point; null if the control point does not exist
Returns the cut distance at control points.
the cut distance since: 2.5
getControlPointHitAt
final public int getControlPointHitAt(Point localLocation)(Code)
Returns an index of a control point that is hit by the local location
Parameters: localLocation - the local location the index; -1 if no control point was hit
Returns a cursor for a specified local location in the widget.
If paintControlPoints is true and controlPointsCursor is non-null and local location is over a control point, then it return controlPointsCursor.
Otherwise it return value from super.getCursorAt method.
Parameters: localLocation - the local location the cursor since: 2.3
Returns an anchor shape of the target of the connection widget.
the target anchor shape
getTargetAnchorShapeRotation
public double getTargetAnchorShapeRotation()(Code)
Returns the rotation of the target anchor shape.
the target anchor shape rotation
isFirstControlPointHitAt
final public boolean isFirstControlPointHitAt(Point localLocation)(Code)
Returns whether the local location hits the first control point (also meant to be the source anchor).
Parameters: localLocation - the local location true if it hits the first control point
Returns whether a specified local location is a part of the connection widget. It checks whether the location is
close to the control-points-based path (up to 4px from the line),
close to the anchors (defined by AnchorShape) or
close to the control points (PointShape).
Parameters: localLocation - the local locaytion true, if the location is a part of the connection widget
isLastControlPointHitAt
final public boolean isLastControlPointHitAt(Point localLocation)(Code)
Returns whether the local location hits the last control point (also meant to be the target anchor).
Parameters: localLocation - the local location true if it hits the last control point
Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.
Parameters: childWidget - the child widget for which the constraint is set Parameters: alignment - the alignment specified relatively to the origin point Parameters: placementInPercentage - the placement on a path in percentage of the path length
Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.
Parameters: childWidget - the child widget for which the constraint is set Parameters: alignment - the alignment specified relatively to the origin point Parameters: placementAtDistance - the placement on a path in pixels as a distance from the source anchor
setControlPointCutDistance
public void setControlPointCutDistance(int controlPointCutDistance)(Code)
Sets the cut distance at control points.
Parameters: controlPointCutDistance - if positive number, then the path is cut to render smooth corners;otherwise the path is rendered using control points only since: 2.5
setControlPointShape
public void setControlPointShape(PointShape controlPointShape)(Code)
Sets a point shape of control points of the connection widget.
Parameters: controlPointShape - the control points shape
setControlPoints
public void setControlPoints(Collection<Point> controlPoints, boolean sceneLocations)(Code)
Sets control points.
Parameters: controlPoints - the list of control points Parameters: sceneLocations - if true, then controlPoints argyment is taken as a list of scene locations;if false, then controlPoints argument is taken as a list of local locations
setControlPointsCursor
final public void setControlPointsCursor(Cursor controlPointsCursor)(Code)
Sets a control points cursor. The cursor is used only when mouse is over a visible control point
Parameters: controlPointsCursor - the control points cursor since: 2.3
Sets a control-points-based path router of the connection widget.
Parameters: router - the path router
setRoutingPolicy
final public void setRoutingPolicy(RoutingPolicy routingPolicy)(Code)
Sets a routing policy. It invokes re-routing in case of routing policy change unless its is changed to DISABLE_ROUTING.
Parameters: routingPolicy - the new routing policy since: 2.9
setSourceAnchor
final public void setSourceAnchor(Anchor sourceAnchor)(Code)
Sets a source anchor of the connection widget.
Parameters: sourceAnchor - the source anchor
setSourceAnchorShape
public void setSourceAnchorShape(AnchorShape sourceAnchorShape)(Code)
Sets the anchor shape of the source of the connection widget.
Parameters: sourceAnchorShape - the source anchor shape