Package pamViewFX.fxNodes.connectionPane
Class StandardConnectionNode
java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.Group
pamViewFX.fxNodes.connectionPane.StandardConnectionNode
- All Implemented Interfaces:
javafx.css.Styleable
,javafx.event.EventTarget
,ConnectionNode
- Direct Known Subclasses:
ConnectionGroupStructure
,ExtensionSocketStructure
,ModuleConnectionNode
Holds all elements of a connection node together. This consists
of a rectangle which can contain graphics, string names, controls etc., plugs
which can be dragged to connect to other connection nodes and lines
connecting plugs to the connection node.
Note:Originally a single subclass of pane was going to deal with all of this but issues with overlapping panes, z order, mouse events calling through overlapping panes and several bits and pieces made thing very difficult. Hence each node within the ConnectioNode is a child of whatever pane the whole thing sits on- the whole class is packaged as a Group in order to make it easier to all to a scene. That way all parts use the same co-ordinate system.
- Author:
- Jamie Macaulay
-
Property Summary
TypePropertyDescriptionjavafx.beans.property.DoubleProperty
Get plugX property.javafx.beans.property.DoubleProperty
Get plugY property.javafx.beans.property.DoubleProperty
Get the socket X property.javafx.beans.property.DoubleProperty
Get the socket Y property.Properties inherited from class javafx.scene.Group
autoSizeChildren
Properties inherited from class javafx.scene.Parent
needsLayout
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Indicates a click outside the connection pane.static double
static double
Default height of the nodestatic double
Default width of the nodestatic final int
Indicates the a node has finished dragging.static final int
Indicates that a node is being dragged.static final int
Indicates the a node has been dragged to another position.static double
static double
Default plug dimensionsstatic double
static double
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
Constructor Summary
ConstructorDescriptionStandardConnectionNode
(ConnectionPane connectionPane) Create a standard horizontal connection node.StandardConnectionNode
(ConnectionPane connectionPane, javafx.geometry.Orientation orientation) Create a connection node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionListener
(ConnectionListener connectListener) Adds a connectionListener which is triggered by any CollisionShape;void
addConnectorNodeListener
(ConnectorNodeListener connectorNodeListener) Add a connector node listener.Create a default plug and adds to the ConnectionNode.Create a default socket which has layout bounds binded to the ConnectionRectangle.javafx.geometry.Point2D
checkWithinPane
(double x, double y) Check that a point is within the connection pane (top and left) and if no return nearest position on pane boundary.boolean
connectNode
(StandardConnectionNode parentNode) Connect another node to this node.Create the connection node shape.Create the connection plug.boolean
disconnectNode
(StandardConnectionNode parentNode) Disconnect a node.Get list of sockets on a connection line of one the plugs of the this connection node.Get children of the connection nodejavafx.scene.Group
Get the group that holds all components of the ConnectionNode e.g.Get the ConnectionRectangle for a ConnectionNode.Get the connection pane the ConnectionNode is associated with.Gets all the connection plugs for a ConnectionNode.Gets a list of sockets associated with a ConnectionNode.int
Get the position of the node in the list of nodes in the connection pane.int
Get the number of connection listeners which have been added to the node.javafx.geometry.Orientation
Get the orientation of the ConnectionNode.Get all node parents of a connection node.Get all connection lines connected to plugsGet all connection lines connected to socketsvoid
Layout defaults and binding for a socket.void
Layout defaults and binding for a socket.boolean
Check whether branch sockets are allowed.boolean
True to disable mouse connections.void
notifyChange
(int flag, StandardConnectionNode connectionNode2) Called from the connection pane to notify a change from another connection node.void
notifyConnectionListeners
(ConnectorNode connectedShape, ConnectorNode plugShape, int connected) Notify all connection listener in the node.javafx.beans.property.DoubleProperty
Get plugX property.javafx.beans.property.DoubleProperty
Get plugY property.void
Remove all branch sockets;void
Remove all plugs.void
Remove all sockets.void
removeConnectionListener
(ConnectionListener connectListener) Remove a connection listeners.void
Remove a connectionSocket from the connection node.void
removeConnectorNodeListener
(ConnectorNodeListener connectorNodeListener) Remove a connector node listener.void
setAllowBranchSocket
(StandardConnectionPlug connectedPlug, boolean allow) Set all lines connecting a plug to node to accept/reject branch socketsvoid
setAllowBranchSockets
(boolean allowBranchSockets) Set whether branch sockets are allowed.void
Pass all collision listeners on all 'connection' shapes which are not in proximity to other shapes a null shape.void
setCollisionShapesNull
(ConnectionPane connectionPane) Pass all collision listeners on all 'connection' shapes which are not in proximity to other shapes a null shape.void
setConnectionPane
(ConnectionPane connectionPane) Set the nodes connection pane.void
setDisableMouseInteraction
(boolean disable) Disables all mouse interactions within the node.void
setPlugX
(double plugX) Set the x offset of the connection plugs, i.e.void
setPlugY
(double plugY) Set the y location of the connection plugs.javafx.beans.property.DoubleProperty
Get the socket X property.javafx.beans.property.DoubleProperty
Get the socket Y property.Methods inherited from class javafx.scene.Group
autoSizeChildrenProperty, getChildren, isAutoSizeChildren, minHeight, minWidth, prefHeight, prefWidth, setAutoSizeChildren
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildrenUnmodifiable, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout
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, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, 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, isFocusVisible, isFocusWithin, 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, maxHeight, maxWidth, 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, setEffect, setEventDispatcher, setFocusTraversable, 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, 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
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
plugY
public javafx.beans.property.DoubleProperty plugYPropertyGet plugY property. How far the plug sits down the node in Y.- See Also:
-
plugX
public javafx.beans.property.DoubleProperty plugXPropertyGet plugX property. How far the plug sits down the node in Y.- See Also:
-
socketY
public javafx.beans.property.DoubleProperty socketYPropertyGet the socket Y property. How many from top of connection node body the scoket should be.- See Also:
-
socketX
public javafx.beans.property.DoubleProperty socketXPropertyGet the socket X property. How many from top of connection node body the scoket should be.- See Also:
-
-
Field Details
-
DRAG_DROP
public static final int DRAG_DROPIndicates the a node has finished dragging.- See Also:
-
DRAGGING_CHNAGED
public static final int DRAGGING_CHNAGEDIndicates the a node has been dragged to another position.- See Also:
-
CONNECTION_PANE_CLICK
public static final int CONNECTION_PANE_CLICKIndicates a click outside the connection pane.- See Also:
-
DRAGGING
public static final int DRAGGINGIndicates that a node is being dragged.- See Also:
-
plugBodyWidth
public static double plugBodyWidthDefault plug dimensions -
plugEndWidth
public static double plugEndWidth -
plugBodyHeight
public static double plugBodyHeight -
plugEndHeight
public static double plugEndHeight -
cornerRadius
public static double cornerRadius -
DEFUALT_PREF_WIDTH
public static double DEFUALT_PREF_WIDTHDefault width of the node -
DEFUALT_PREF_HEIGHT
public static double DEFUALT_PREF_HEIGHTDefault height of the node
-
-
Constructor Details
-
StandardConnectionNode
public StandardConnectionNode(ConnectionPane connectionPane, javafx.geometry.Orientation orientation) Create a connection node.- Parameters:
connectionPane
- - the pane the connection node belongs to.oreintation
- - orientation of the node- HORIZONTAL or VERTICAL.
-
StandardConnectionNode
Create a standard horizontal connection node.- Parameters:
connectionPane
- - the pane the connection node belongs to.
-
-
Method Details
-
addDefaultPlug
Create a default plug and adds to the ConnectionNode. This is initially bound to the rectangle but un-binds as soon as a drag event is registered or enableFreePlug();- Returns:
- a default plug.
-
createPlug
Create the connection plug.- Returns:
- the connection plug.
-
initDefaultPlugLayout
Layout defaults and binding for a socket.- Parameters:
socket
- - the socket to apply binding and layout to.
-
removeAllConnectionPlugs
public void removeAllConnectionPlugs()Remove all plugs. -
addDefaultSocket
Create a default socket which has layout bounds binded to the ConnectionRectangle.- Returns:
- a default connection socket.
-
initDefaultSocketLayout
Layout defaults and binding for a socket.- Parameters:
socket
- - the socket to apply binding and layout to.
-
removeConnectionSocket
Remove a connectionSocket from the connection node. -
removeAllConnectionSockets
public void removeAllConnectionSockets()Remove all sockets. -
removeAllBranchSockets
public void removeAllBranchSockets()Remove all branch sockets; -
setCollisionShapesNull
public void setCollisionShapesNull()Pass all collision listeners on all 'connection' shapes which are not in proximity to other shapes a null shape. This will return shapes to default colours etc. -
setCollisionShapesNull
Pass all collision listeners on all 'connection' shapes which are not in proximity to other shapes a null shape. This will return shapes to default colours etc.- Parameters:
connectionPane
- - the connection pane to search for other conenction shapes.
-
getConnectionNodeBody
Get the ConnectionRectangle for a ConnectionNode. The ConnectionRectangle is essentially a blank pane and can have various controls, images etc. added.- Specified by:
getConnectionNodeBody
in interfaceConnectionNode
- Returns:
- the ConnectionRectangle for a ConnectionNode.
-
createNodeBody
Create the connection node shape.- Returns:
- the connection node shape.
-
getConnectionPlugs
Gets all the connection plugs for a ConnectionNode.- Specified by:
getConnectionPlugs
in interfaceConnectionNode
- Returns:
- a list of plugs for a ConnectionNode.
-
getConnectionSockets
Gets a list of sockets associated with a ConnectionNode.- Specified by:
getConnectionSockets
in interfaceConnectionNode
- Returns:
- a list of sockets for a ConnectionNode.
-
getBranchConnectionSockets
Get list of sockets on a connection line of one the plugs of the this connection node. These socket to do not provide any input to the ConnectionNode but are stored here for reference.- Specified by:
getBranchConnectionSockets
in interfaceConnectionNode
- Returns:
- list of branch connection sockets.
-
getPlugConnectionLines
Get all connection lines connected to plugs- Specified by:
getPlugConnectionLines
in interfaceConnectionNode
- Returns:
- all connection lines for all plugs associated with a ConnectionNode.
-
getSocketConnectionLines
Get all connection lines connected to sockets- Returns:
- all connection lines for all sockets associated with a ConnectionNode.
-
getNodeId
public int getNodeId()Get the position of the node in the list of nodes in the connection pane.- Returns:
- position of node in list of nodes added to connection pane.
-
getConnectionPane
Get the connection pane the ConnectionNode is associated with.- Returns:
- The ConnectionPane the ConnectionNode is associated with. Returns null if the node has no pane.
-
checkWithinPane
public javafx.geometry.Point2D checkWithinPane(double x, double y) Check that a point is within the connection pane (top and left) and if no return nearest position on pane boundary.- Parameters:
x
- -scene x co-ordinatey
- - scene y co-ordinate- Returns:
- null if within ConnectionPane boundary or a new Point2D of closest point on boundary if outside boundary.
-
isAllowBranchSockets
public boolean isAllowBranchSockets()Check whether branch sockets are allowed. Branch sockets allow plugs to connect to other plugs allowing multiple inputs into another ConnectionNode.- Returns:
- true if branch sockets are allowed
-
setAllowBranchSockets
public void setAllowBranchSockets(boolean allowBranchSockets) Set whether branch sockets are allowed. Branch sockets allow plugs to connect to other plugs allowing multiple inputs into another ConnectionNode.- Parameters:
allowBranchSockets
- - true to allow branch sockets. False to prevent branch sockets.
-
setAllowBranchSocket
Set all lines connecting a plug to node to accept/reject branch sockets- Parameters:
connectedPlug
- - the plug to which the lines belongallow
- - true to allow branch sockets. False to reject branch sockets.
-
disconnectNode
Disconnect a node.- Parameters:
parentNode
- - the parent node to disconnect- Returns:
- true if the plug was null.
-
connectNode
Connect another node to this node. Look for a free connection socket. If no socket is free then remove shape from first socket and connect with that socket. If no socket exists do nothing. Note this does not support connections via branch sockets- Returns:
- true if connection was successful, otherwise false.
-
setPlugY
public void setPlugY(double plugY) Set the y location of the connection plugs.- Parameters:
plugY
- - how far down the connection node in pixels the plug should be
-
setPlugX
public void setPlugX(double plugX) Set the x offset of the connection plugs, i.e. how far they jut out from a connection node main body- Parameters:
plugY
- - how far down the connection node in pixels the plug should be
-
notifyChange
Called from the connection pane to notify a change from another connection node.- Specified by:
notifyChange
in interfaceConnectionNode
- Parameters:
flag
- - the change typeconnectionNode2
- - the connection nodeconnectionNode
- - the connection node associated with the changed
-
setDisableMouseInteraction
public void setDisableMouseInteraction(boolean disable) Disables all mouse interactions within the node.- Parameters:
true
- to disable all mouse interaction. False to enable mouse actions.
-
isMouseDisable
public boolean isMouseDisable()True to disable mouse connections.- Returns:
- true.
-
getOrientation
public javafx.geometry.Orientation getOrientation()Get the orientation of the ConnectionNode. Orientation effects Positions of plugs and sockets.- Returns:
- the orientation
-
plugYProperty
public javafx.beans.property.DoubleProperty plugYProperty()Get plugY property. How far the plug sits down the node in Y.- Returns:
- the plug Y property
-
plugXProperty
public javafx.beans.property.DoubleProperty plugXProperty()Get plugX property. How far the plug sits down the node in Y.- Returns:
- the plug X property
-
socketYProperty
public javafx.beans.property.DoubleProperty socketYProperty()Get the socket Y property. How many from top of connection node body the scoket should be.- Returns:
- the socket y property.
-
socketXProperty
public javafx.beans.property.DoubleProperty socketXProperty()Get the socket X property. How many from top of connection node body the scoket should be.- Returns:
- the socket y property.
-
getParentConnectionNodes
Get all node parents of a connection node. Parents of a ConnectionNode are those noses which are connected directly before that node. i.e. you can draw a direct line form the socket of the node to the plug of a parent node. Note that structures are not included as parents.- Specified by:
getParentConnectionNodes
in interfaceConnectionNode
- Parameters:
connectionNode
- - the connection node for which to find parent- Returns:
- a list of children. List will be empty if the node has no children.
-
getChildConnectionNodes
Description copied from interface:ConnectionNode
Get children of the connection node- Specified by:
getChildConnectionNodes
in interfaceConnectionNode
- Returns:
- a list of the children connected to to the node.
-
addConnectionListener
Adds a connectionListener which is triggered by any CollisionShape;- Specified by:
addConnectionListener
in interfaceConnectionNode
- Parameters:
connectListener
- - connectionlistener to add;
-
removeConnectionListener
Description copied from interface:ConnectionNode
Remove a connection listeners. This listens for other connection nodes which have connected- Specified by:
removeConnectionListener
in interfaceConnectionNode
- Parameters:
connectListener
- - the connection listener to remove.
-
getNumConnectionListeners
public int getNumConnectionListeners()Get the number of connection listeners which have been added to the node.- Returns:
- the number of connection listeners attached to the node.
-
notifyConnectionListeners
public void notifyConnectionListeners(ConnectorNode connectedShape, ConnectorNode plugShape, int connected) Description copied from interface:ConnectionNode
Notify all connection listener in the node.- Specified by:
notifyConnectionListeners
in interfaceConnectionNode
-
addConnectorNodeListener
Description copied from interface:ConnectionNode
Add a connector node listener. This listens for any events from connector nodes attached to the connection node.- Specified by:
addConnectorNodeListener
in interfaceConnectionNode
-
removeConnectorNodeListener
Description copied from interface:ConnectionNode
Remove a connector node listener. This listens for any events from connector nodes attached to the connection node.- Specified by:
removeConnectorNodeListener
in interfaceConnectionNode
-
getConnectionGroup
public javafx.scene.Group getConnectionGroup()Description copied from interface:ConnectionNode
Get the group that holds all components of the ConnectionNode e.g. the body, plugs etc.- Specified by:
getConnectionGroup
in interfaceConnectionNode
- Returns:
- the connection node group.
-
setConnectionPane
Set the nodes connection pane.
-