Class Connection
- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.Group
-
- org.eclipse.gef.fx.nodes.Connection
-
- All Implemented Interfaces:
javafx.css.Styleable
,javafx.event.EventTarget
public class Connection extends javafx.scene.Group
A (binary)Connection
is a visual curveProperty, whose appearance is defined through a single start and end point, and a set of control points, which may be 'connected', i.e. be attached to anIAnchor
. The exact curveProperty shape is determined by anIConnectionRouter
, which is responsible of computing anICurve
geometry for a givenConnection
(which is then rendered using aGeometryNode
).Whether the control points are interpreted as way points (that lie on the curveProperty) or as 'real' control points depends on the
IConnectionInterpolator
. WhilePolylineInterpolator
andPolyBezierInterpolator
interpret control points to be way points, other routers may e.g. interpret them as the control points of aBezierCurve
.In addition to the curveProperty shape, the visual appearance of a
Connection
can be controlled via start and end decorations. They will be rendered 'on-top' of the curveProperty shape and the curveProperty shape will be properly clipped at the decorations (so it does not paint through).
-
-
Constructor Summary
Constructors Constructor Description Connection()
Constructs a newConnection
whose start and end point are set tonull
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAnchor(AnchorKey anchorKey, IAnchor anchor)
void
addControlAnchor(int index, IAnchor anchor)
Adds the givenIAnchor
as a control point anchor for the given index into theanchorsUnmodifiableProperty()
of thisConnection
.void
addControlPoint(int index, Point controlPoint)
Adds anStaticAnchor
yielding the givenPoint
as a control point anchor for the given index into theanchorsUnmodifiableProperty()
of thisConnection
.javafx.beans.property.ReadOnlyListProperty<IAnchor>
anchorsUnmodifiableProperty()
Returns an unmodifiable read-only list property, which contains theIAnchor
s that determine the start point, control points, and end point of thisConnection
.protected javafx.collections.MapChangeListener<? super AnchorKey,? super Point>
createPCL(AnchorKey anchorKey)
Creates a position change listener (PCL) whichrefreshes
thisConnection
upon anchor position changes corresponding to the givenAnchorKey
.javafx.beans.property.ObjectProperty<javafx.scene.Node>
curveProperty()
Returns a property wrapping the curveNode
.javafx.beans.property.ObjectProperty<javafx.scene.Node>
endDecorationProperty()
Returns anObjectProperty
wrapping the end decorationNode
.IAnchor
getAnchor(int index)
Returns the anchor at the given index.protected int
getAnchorIndex(AnchorKey anchorKey)
Returns the anchor index for the givenAnchorKey
.protected AnchorKey
getAnchorKey(int anchorIndex)
Returns theAnchorKey
for the given anchor index, i.e. the reverse ofgetAnchorIndex(AnchorKey)
.javafx.collections.ObservableList<IAnchor>
getAnchorsUnmodifiable()
Returns aList
containing theIAnchor
s which are assigned to thisConnection
in the order: start anchor, control point anchorsByKeys, end anchor.Point
getCenter()
Computes the 'logical' center point of theConnection
, which is the middle control point position (in case the curveProperty consists of an even number of segment) or the middle point of the middle segment.IAnchor
getControlAnchor(int index)
protected int
getControlAnchorIndex(AnchorKey key)
Returns the control anchor index for the givenAnchorKey
, i.e.protected AnchorKey
getControlAnchorKey(int index)
Returns theAnchorKey
for the given control anchor index.java.util.List<IAnchor>
getControlAnchors()
Point
getControlPoint(int index)
Returns the controlPoint
for the given control anchor index within the coordinate system of thisConnection
which is determined by querying the anchor position for the correspondingcontrol anchor
, ornull
if nocontrol anchor
is assigned for the given index.java.util.List<Point>
getControlPoints()
javafx.scene.Node
getCurve()
Returns theNode
which displays the curveProperty geometry.IAnchor
getEndAnchor()
protected AnchorKey
getEndAnchorKey()
Returns the endAnchorKey
for thisConnection
.javafx.scene.Node
getEndDecoration()
Point
getEndPoint()
Returns the endPoint
of thisConnection
within its coordinate system which is determined by querying the anchor position for theend anchor key
, ornull
when noend anchor
is assigned.Point
getEndPointHint()
Returns the currently set end position hint ornull
if no hint is present.IConnectionInterpolator
getInterpolator()
Returns theIConnectionInterpolator
of thisConnection
.Point
getPoint(int index)
Returns the point at the given index.javafx.collections.ObservableList<Point>
getPointsUnmodifiable()
Returns thePoint
s constituting thisConnection
within its coordinate system in the order: start point, control points, end point.IConnectionRouter
getRouter()
Returns theIConnectionRouter
of thisConnection
.IAnchor
getStartAnchor()
protected AnchorKey
getStartAnchorKey()
Returns the startAnchorKey
for thisConnection
.javafx.scene.Node
getStartDecoration()
Point
getStartPoint()
Returns the startPoint
of thisConnection
within its coordinate system which is determined by querying the anchor position for thestart anchor key
, ornull
when nostart anchor
is assigned.Point
getStartPointHint()
Returns the currently set start position hint ornull
if no hint is present.javafx.beans.property.ObjectProperty<IConnectionInterpolator>
interpolatorProperty()
Returns theIConnectionInterpolator
property.boolean
isConnected(int index)
Returns whether the (start, end, or control) anchor at the respective index is connected.boolean
isConnected(IAnchor anchor)
Returntrue
in case the anchor is bound to an anchorage unequal to this connection.boolean
isControlConnected(int index)
Returnstrue
if the currently assignedcontrol anchor
for the given index is bound to an anchorage.boolean
isEndConnected()
Returnstrue
if the currently assignedend anchor
is bound to an anchorage.boolean
isStartConnected()
Returnstrue
if the currently assignedstart anchor
is bound to an anchorage.double
maxHeight(double width)
double
maxWidth(double height)
double
minHeight(double width)
double
minWidth(double height)
javafx.beans.property.ReadOnlyListProperty<Point>
pointsUnmodifiableProperty()
Returns an unmodifiable read-only list property, which contains the points (start, control, end) that constitute this connection.protected void
reattachAnchorKeys(javafx.scene.Node oldAnchored, javafx.scene.Node newAnchored)
Re-attaches allAnchorKey
s that are managed by thisConnection
.protected void
refresh()
Refreshes the visualization in response to anchor, position, transformation, etc. changes.void
removeAllControlAnchors()
Removes all control points of thisConnection
.void
removeAllControlPoints()
Removes all control points of thisConnection
.protected void
removeAnchor(AnchorKey anchorKey, IAnchor anchor)
void
removeControlAnchor(int index)
Removes the control anchor specified by the given index from thisConnection
.void
removeControlPoint(int index)
Removes the control point specified by the given control anchor index from thisConnection
.javafx.beans.property.ObjectProperty<IConnectionRouter>
routerProperty()
Returns a writable property containing theIConnectionRouter
of this connection.protected void
setAnchor(AnchorKey anchorKey, IAnchor anchor)
void
setAnchors(java.util.List<IAnchor> anchors)
Replaces all anchors of thisConnection
with the givenIAnchor
s, i.e. the first givenIAnchor
replaces the currently assigned start anchor, the last givenIAnchor
replaces the currently assigned end anchor, and the intermediateIAnchor
s replace the currently assigned control anchorsByKeys.void
setControlAnchor(int index, IAnchor anchor)
Sets the control anchor for the given control anchor index to the givenIAnchor
.void
setControlAnchors(java.util.List<IAnchor> anchors)
void
setControlPoint(int index, Point controlPoint)
Sets the control anchor for the given control anchor index to anStaticAnchor
which yields the givenPoint
.void
setControlPoints(java.util.List<Point> controlPoints)
void
setCurve(javafx.scene.Node curve)
Sets theNode
that is used to render the connection.void
setEndAnchor(IAnchor anchor)
Sets the endIAnchor
of thisConnection
to the given value.void
setEndDecoration(javafx.scene.Node decoration)
Sets the end decorationNode
of thisConnection
to the given value.void
setEndPoint(Point endPoint)
void
setEndPointHint(Point endPositionHint)
Sets the end position hint to the given value.void
setInterpolator(IConnectionInterpolator interpolator)
void
setPoints(java.util.List<Point> points)
Replaces all anchors of thisConnection
with the givenIAnchor
s, i.e. the first givenIAnchor
replaces the currently assigned start anchor, the last givenIAnchor
replaces the currently assigned end anchor, and the intermediateIAnchor
s replace the currently assigned control anchorsByKeys.void
setRouter(IConnectionRouter router)
Sets theIConnectionRouter
of thisConnection
to the given value.void
setStartAnchor(IAnchor anchor)
Sets the startIAnchor
of thisConnection
to the given value.void
setStartDecoration(javafx.scene.Node decoration)
Sets the start decorationNode
of thisConnection
to the given value.void
setStartPoint(Point startPoint)
void
setStartPointHint(Point startPositionHint)
Sets the start position hint to the given value.javafx.beans.property.ObjectProperty<javafx.scene.Node>
startDecorationProperty()
Returns anObjectProperty
wrapping the start decorationNode
.-
Methods inherited from class javafx.scene.Group
autoSizeChildrenProperty, getChildren, isAutoSizeChildren, layoutChildren, prefHeight, prefWidth, setAutoSizeChildren
-
Methods inherited from class javafx.scene.Parent
computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
-
-
-
Constructor Detail
-
Connection
public Connection()
Constructs a newConnection
whose start and end point are set tonull
.
-
-
Method Detail
-
addAnchor
protected void addAnchor(AnchorKey anchorKey, IAnchor anchor)
Inserts the givenIAnchor
into theanchorsUnmodifiableProperty()
of thisConnection
. The givenAnchorKey
is attached to theIAnchor
. Furthermore, aPCL
for theAnchorKey
is registered on the position property of theIAnchor
and the visualization isrefreshed
.
-
addControlAnchor
public void addControlAnchor(int index, IAnchor anchor)
Adds the givenIAnchor
as a control point anchor for the given index into theanchorsUnmodifiableProperty()
of thisConnection
.- Parameters:
index
- The position where theIAnchor
is inserted within the control point anchorsByKeys of thisConnection
.anchor
- TheIAnchor
which determines the position of the corresponding control point.
-
addControlPoint
public void addControlPoint(int index, Point controlPoint)
Adds anStaticAnchor
yielding the givenPoint
as a control point anchor for the given index into theanchorsUnmodifiableProperty()
of thisConnection
.- Parameters:
index
- The position where theIAnchor
is inserted within the control point anchorsByKeys of thisConnection
.controlPoint
- The position for the specified control point.
-
anchorsUnmodifiableProperty
public javafx.beans.property.ReadOnlyListProperty<IAnchor> anchorsUnmodifiableProperty()
Returns an unmodifiable read-only list property, which contains theIAnchor
s that determine the start point, control points, and end point of thisConnection
.- Returns:
- An unmodifiable read-only list property containing this
Connection
's anchors.
-
createPCL
protected javafx.collections.MapChangeListener<? super AnchorKey,? super Point> createPCL(AnchorKey anchorKey)
Creates a position change listener (PCL) whichrefreshes
thisConnection
upon anchor position changes corresponding to the givenAnchorKey
.- Parameters:
anchorKey
- TheAnchorKey
for which a position change will trigger arefresh()
with the returned PCL.- Returns:
- A position change listener to
refresh
thisConnection
when the position for the givenAnchorKey
changes.
-
curveProperty
public javafx.beans.property.ObjectProperty<javafx.scene.Node> curveProperty()
Returns a property wrapping the curveNode
.- Returns:
- The curve
Node
used to visualize the connection.
-
endDecorationProperty
public javafx.beans.property.ObjectProperty<javafx.scene.Node> endDecorationProperty()
Returns anObjectProperty
wrapping the end decorationNode
.- Returns:
- A property wrapping the end decoration.
-
getAnchor
public IAnchor getAnchor(int index)
Returns the anchor at the given index. The start anchor will be provided forindex == 0
, the end anchor for the last defined index. Control anchorsByKeys will be returned for all indices in between.- Parameters:
index
- The index of the anchor to retrieve.- Returns:
- The anchor at the given index.
-
getAnchorIndex
protected int getAnchorIndex(AnchorKey anchorKey)
Returns the anchor index for the givenAnchorKey
.
-
getAnchorKey
protected AnchorKey getAnchorKey(int anchorIndex)
Returns theAnchorKey
for the given anchor index, i.e. the reverse ofgetAnchorIndex(AnchorKey)
.
-
getAnchorsUnmodifiable
public javafx.collections.ObservableList<IAnchor> getAnchorsUnmodifiable()
Returns aList
containing theIAnchor
s which are assigned to thisConnection
in the order: start anchor, control point anchorsByKeys, end anchor.- Returns:
- A
List
containing theIAnchor
s which are assigned to thisConnection
.
-
getCenter
public Point getCenter()
Computes the 'logical' center point of theConnection
, which is the middle control point position (in case the curveProperty consists of an even number of segment) or the middle point of the middle segment.- Returns:
- The logical center of this
Connection
.
-
getControlAnchor
public IAnchor getControlAnchor(int index)
-
getControlAnchorIndex
protected int getControlAnchorIndex(AnchorKey key)
Returns the control anchor index for the givenAnchorKey
, i.e.0
for the first controlanchor
,1
for the seconds, etc.- Parameters:
key
- TheAnchorKey
whose control anchor index is returned.- Returns:
- The control anchor index for the given
AnchorKey
. - Throws:
java.lang.IllegalArgumentException
- when there currently is no controlanchor
assigned to thisConnection
for the givenAnchorKey
.
-
getControlAnchorKey
protected AnchorKey getControlAnchorKey(int index)
Returns theAnchorKey
for the given control anchor index.
-
getControlAnchors
public java.util.List<IAnchor> getControlAnchors()
- Returns:
- A
List
containing the controlanchorsByKeys
currently assigned to thisConnection
.
-
getControlPoint
public Point getControlPoint(int index)
Returns the controlPoint
for the given control anchor index within the coordinate system of thisConnection
which is determined by querying the anchor position for the correspondingcontrol anchor
, ornull
if nocontrol anchor
is assigned for the given index.- Parameters:
index
- The control anchor index for which to return the anchor position.- Returns:
- The start
Point
of thisConnection
, ornull
.
-
getControlPoints
public java.util.List<Point> getControlPoints()
- Returns:
- A
List
containing the controlPoint
s of thisConnection
.
-
getCurve
public javafx.scene.Node getCurve()
Returns theNode
which displays the curveProperty geometry. Will be aGeometryNode
by default.- Returns:
- The
Node
which displays the curveProperty geometry.
-
getEndAnchorKey
protected AnchorKey getEndAnchorKey()
Returns the endAnchorKey
for thisConnection
. An endAnchorKey
uses thecurveProperty node
as its anchored and"end"
as its role.- Returns:
- The end
AnchorKey
for thisConnection
.
-
getEndDecoration
public javafx.scene.Node getEndDecoration()
- Returns:
- The end decoration
Node
of thisConnection
, ornull
.
-
getEndPoint
public Point getEndPoint()
Returns the endPoint
of thisConnection
within its coordinate system which is determined by querying the anchor position for theend anchor key
, ornull
when noend anchor
is assigned.- Returns:
- The end
Point
of thisConnection
, ornull
.
-
getEndPointHint
public Point getEndPointHint()
Returns the currently set end position hint ornull
if no hint is present.- Returns:
- The currently set end position hint or
null
if no hint is present.
-
getInterpolator
public IConnectionInterpolator getInterpolator()
Returns theIConnectionInterpolator
of thisConnection
.- Returns:
- The
IConnectionInterpolator
of thisConnection
.
-
getPoint
public Point getPoint(int index)
Returns the point at the given index. The start point will be provided forindex == 0
, the end point for the last defined index. Control points will be returned for all indices in between.- Parameters:
index
- The index of the point to retrieve.- Returns:
- The point at the given index.
- See Also:
getPointsUnmodifiable()
-
getPointsUnmodifiable
public javafx.collections.ObservableList<Point> getPointsUnmodifiable()
Returns thePoint
s constituting thisConnection
within its coordinate system in the order: start point, control points, end point.- Returns:
- The
Point
s constituting thisConnection
.
-
getRouter
public IConnectionRouter getRouter()
Returns theIConnectionRouter
of thisConnection
.- Returns:
- The
IConnectionRouter
of thisConnection
.
-
getStartAnchor
public IAnchor getStartAnchor()
- Returns:
- The currently assigned start
anchor
, ornull
.
-
getStartAnchorKey
protected AnchorKey getStartAnchorKey()
Returns the startAnchorKey
for thisConnection
. A startAnchorKey
uses thecurveProperty node
as its anchored and"start"
as its role.- Returns:
- The start
AnchorKey
for thisConnection
.
-
getStartDecoration
public javafx.scene.Node getStartDecoration()
- Returns:
- The start decoration
Node
of thisConnection
, ornull
.
-
getStartPoint
public Point getStartPoint()
Returns the startPoint
of thisConnection
within its coordinate system which is determined by querying the anchor position for thestart anchor key
, ornull
when nostart anchor
is assigned.- Returns:
- The start
Point
of thisConnection
, ornull
.
-
getStartPointHint
public Point getStartPointHint()
Returns the currently set start position hint ornull
if no hint is present.- Returns:
- The currently set start position hint or
null
if no hint is present.
-
interpolatorProperty
public javafx.beans.property.ObjectProperty<IConnectionInterpolator> interpolatorProperty()
Returns theIConnectionInterpolator
property.- Returns:
- The
IConnectionInterpolator
property.
-
isConnected
public boolean isConnected(IAnchor anchor)
Returntrue
in case the anchor is bound to an anchorage unequal to this connection.- Parameters:
anchor
- The anchor to test- Returns:
true
if the anchor is connected,false
otherwise.
-
isConnected
public boolean isConnected(int index)
Returns whether the (start, end, or control) anchor at the respective index is connected.- Parameters:
index
- The index, referring to the start, end, or a control point.- Returns:
true
if the anchor at the given index is connected,false
otherwise.
-
isControlConnected
public boolean isControlConnected(int index)
Returnstrue
if the currently assignedcontrol anchor
for the given index is bound to an anchorage. Otherwise returnsfalse
.- Parameters:
index
- The control anchor index of the control anchor to test for connectedness.- Returns:
true
if the currently assignedcontrol anchor
for the given index is bound to an anchorage, otherwisefalse
.
-
isEndConnected
public boolean isEndConnected()
Returnstrue
if the currently assignedend anchor
is bound to an anchorage. Otherwise returnsfalse
.- Returns:
true
if the currently assignedend anchor
is bound to an anchorage, otherwisefalse
.
-
isStartConnected
public boolean isStartConnected()
Returnstrue
if the currently assignedstart anchor
is bound to an anchorage. Otherwise returnsfalse
.- Returns:
true
if the currently assignedstart anchor
is bound to an anchorage, otherwisefalse
.
-
maxHeight
public double maxHeight(double width)
- Overrides:
maxHeight
in classjavafx.scene.Node
-
maxWidth
public double maxWidth(double height)
- Overrides:
maxWidth
in classjavafx.scene.Node
-
minHeight
public double minHeight(double width)
- Overrides:
minHeight
in classjavafx.scene.Group
-
minWidth
public double minWidth(double height)
- Overrides:
minWidth
in classjavafx.scene.Group
-
pointsUnmodifiableProperty
public javafx.beans.property.ReadOnlyListProperty<Point> pointsUnmodifiableProperty()
Returns an unmodifiable read-only list property, which contains the points (start, control, end) that constitute this connection.- Returns:
- An unmodifiable read-only list property containing this
Connection
's points.
-
reattachAnchorKeys
protected void reattachAnchorKeys(javafx.scene.Node oldAnchored, javafx.scene.Node newAnchored)
Re-attaches allAnchorKey
s that are managed by thisConnection
.- Parameters:
oldAnchored
- The previous anchoredNode
.newAnchored
- The new anchoredNode
.
-
refresh
protected void refresh()
Refreshes the visualization in response to anchor, position, transformation, etc. changes. This method is safe against reentrance, i.e. changes performed byrefresh()
are allowed to lead to anotherrefresh()
call. However, when this method is called reentrant, it returns immediately.The process of refreshing a
Connection
is somewhat complicated as it involves transforming points according to a transformation change, removing volatile anchors, computing new parameters for its anchors, inserting volatile anchors, computing a curve geometry, and updating the visualization to that geometry. In addition, the position change listeners registered at the individualAbstractAnchor.positionsUnmodifiableProperty()
need to be disabled duringrefresh()
to preventConcurrentModificationException
. The process can be described by the following steps:- The connection unregisters all position change listeners.
- The connection queries all points from its anchors and transforms them from curve to connection coordinates (curve-to-connection-transform, c2ctx).
- The router removes all (previously inserted) volatile anchors.
- => The connection's points are refreshed in-place, because removal
of anchors calls
removeAnchor(AnchorKey, IAnchor)
, which updates the points straight away. - The router queries the (updated, user-defined) points from the connection and computes parameters for the anchors based on these points (and other criteria).
- => The router computes the
DynamicAnchor.AnchoredReferencePoint
parameter value within the coordinate system of the connection. - => The parameter is then bound to a binding that depends on the
c2ctx, which transforms the
Point
from the coordinate system of the connection to the coordinate system of thegetCurve()
. - The anchors compute new positions for the
AnchorKey
s for which new parameters were provided or parameter values changed. - The router queries the positions from the anchors and transforms them manually, because the connection did not yet update its points.
- The router inserts volatile anchors according to the routing strategy.
- The connection refreshes its points manually, because the position change listeners are disabled.
- The interpolator computes a new curve geometry and applies it to the connection.
- => The c2ctx changes, that's why the parameters are recomputed from the bindings, which triggers a recomputation of the anchor positions.
- The connection refreshed its points manually again.
- The connection registers all position change listeners.
-
removeAllControlAnchors
public void removeAllControlAnchors()
Removes all control points of thisConnection
.
-
removeAllControlPoints
public void removeAllControlPoints()
Removes all control points of thisConnection
.
-
removeControlAnchor
public void removeControlAnchor(int index)
Removes the control anchor specified by the given index from thisConnection
.- Parameters:
index
- The index specifying which control anchor to remove.
-
removeControlPoint
public void removeControlPoint(int index)
Removes the control point specified by the given control anchor index from thisConnection
.- Parameters:
index
- The control anchor index specifying which control point to remove.
-
routerProperty
public javafx.beans.property.ObjectProperty<IConnectionRouter> routerProperty()
Returns a writable property containing theIConnectionRouter
of this connection.- Returns:
- A writable property providing the
IConnectionRouter
used by this connection.
-
setAnchors
public void setAnchors(java.util.List<IAnchor> anchors)
Replaces all anchors of thisConnection
with the givenIAnchor
s, i.e. the first givenIAnchor
replaces the currently assigned start anchor, the last givenIAnchor
replaces the currently assigned end anchor, and the intermediateIAnchor
s replace the currently assigned control anchorsByKeys.- Parameters:
anchors
- The newIAnchor
s for thisConnection
.- Throws:
java.lang.IllegalArgumentException
- when less than 2IAnchor
s are given.
-
setControlAnchor
public void setControlAnchor(int index, IAnchor anchor)
Sets the control anchor for the given control anchor index to the givenIAnchor
.- Parameters:
index
- The control anchor index of the control anchor to replace.anchor
- The new controlIAnchor
for that index.
-
setControlAnchors
public void setControlAnchors(java.util.List<IAnchor> anchors)
- Parameters:
anchors
- The new controlIAnchor
s for thisConnection
.
-
setControlPoint
public void setControlPoint(int index, Point controlPoint)
Sets the control anchor for the given control anchor index to anStaticAnchor
which yields the givenPoint
.- Parameters:
index
- The control anchor index of the control anchor to replace.controlPoint
- The new controlPoint
for the respective index within local coordinates of theConnection
.
-
setControlPoints
public void setControlPoints(java.util.List<Point> controlPoints)
- Parameters:
controlPoints
- The new controlPoint
s for thisConnection
.
-
setCurve
public void setCurve(javafx.scene.Node curve)
Sets theNode
that is used to render the connection.- Parameters:
curve
- The new curveProperty node.
-
setEndAnchor
public void setEndAnchor(IAnchor anchor)
Sets the endIAnchor
of thisConnection
to the given value.- Parameters:
anchor
- The new endIAnchor
for thisConnection
.
-
setEndDecoration
public void setEndDecoration(javafx.scene.Node decoration)
Sets the end decorationNode
of thisConnection
to the given value.- Parameters:
decoration
- The new end decorationNode
for thisConnection
.
-
setEndPoint
public void setEndPoint(Point endPoint)
- Parameters:
endPoint
- The new endPoint
within local coordinates of theConnection
.
-
setEndPointHint
public void setEndPointHint(Point endPositionHint)
Sets the end position hint to the given value.- Parameters:
endPositionHint
- The new end position hint.
-
setInterpolator
public void setInterpolator(IConnectionInterpolator interpolator)
- Parameters:
interpolator
- The newIConnectionInterpolator
for thisConnection
.
-
setPoints
public void setPoints(java.util.List<Point> points)
Replaces all anchors of thisConnection
with the givenIAnchor
s, i.e. the first givenIAnchor
replaces the currently assigned start anchor, the last givenIAnchor
replaces the currently assigned end anchor, and the intermediateIAnchor
s replace the currently assigned control anchorsByKeys.- Parameters:
points
- The newPoint
s for thisConnection
.- Throws:
java.lang.IllegalArgumentException
- when less than 2IAnchor
s are given.
-
setRouter
public void setRouter(IConnectionRouter router)
Sets theIConnectionRouter
of thisConnection
to the given value.- Parameters:
router
- The newIConnectionRouter
for thisConnection
.
-
setStartAnchor
public void setStartAnchor(IAnchor anchor)
Sets the startIAnchor
of thisConnection
to the given value.- Parameters:
anchor
- The new startIAnchor
for thisConnection
.
-
setStartDecoration
public void setStartDecoration(javafx.scene.Node decoration)
Sets the start decorationNode
of thisConnection
to the given value.- Parameters:
decoration
- The new start decorationNode
for thisConnection
.
-
setStartPoint
public void setStartPoint(Point startPoint)
- Parameters:
startPoint
- The new startPoint
within local coordinates of theConnection
.
-
setStartPointHint
public void setStartPointHint(Point startPositionHint)
Sets the start position hint to the given value.- Parameters:
startPositionHint
- The new start position hint.
-
startDecorationProperty
public javafx.beans.property.ObjectProperty<javafx.scene.Node> startDecorationProperty()
Returns anObjectProperty
wrapping the start decorationNode
.- Returns:
- An Object Property wrapping the start decoration.
-
-