Class GraphPinScene<N,E,P>
java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.Scene
org.netbeans.api.visual.model.ObjectScene
org.netbeans.api.visual.graph.GraphPinScene<N,E,P>
- All Implemented Interfaces:
Accessible
,org.openide.util.Lookup.Provider
- Direct Known Subclasses:
GraphPinScene.StringGraph
,VMDGraphScene
This class holds and manages graph-oriented model.
In comparison with the GraphScene class, in this class the graph consists of nodes, edges and pins. Each pin is assigned to a node (the assigned cannot be change at any time. Each edge could be attach to a single source and target pin.
The class is abstract and manages only data model and mapping with widgets. The graphics (widgets) has to be supplied by a developer by overriding the attachNodeWidget, attachPinWidget, attachEdgeWidget, attachEdgeSourceAnchor and attachEdgeTargetAnchor abstract methods.
This class is using generics and allows you to specify type representation for nodes and edges in the graph model. Example:
class MyGraph extends GraphScene<MyNode, MyEdge, MyPin> { ... }Since the type of nodes, edges and pins could be the same, all node, edge and pin instances have to be unique within the whole scene.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class is a particular GraphPinScene where nodes, edges and pins are represented with String class.Nested classes/interfaces inherited from class org.netbeans.api.visual.widget.Scene
Scene.SceneListener
Nested classes/interfaces inherited from class org.netbeans.api.visual.widget.Widget
Widget.Dependency
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Widget
Adds an edge.final Widget
Adds a node.final Widget
Adds a pin and assigns it to a specified node.protected abstract void
attachEdgeSourceAnchor
(E edge, P oldSourcePin, P sourcePin) Called by the setEdgeSource method to notify about the changing the edge source in the graph model.protected abstract void
attachEdgeTargetAnchor
(E edge, P oldTargetPin, P targetPin) Called by the setEdgeTarget method to notify about the changing the edge target in the graph model.protected abstract Widget
attachEdgeWidget
(E edge) Called by the addEdge method before the edge is registered to acquire a widget that is going to represent the edge in the scene.protected abstract Widget
attachNodeWidget
(N node) Called by the addNode method before the node is registered to acquire a widget that is going to represent the node in the scene.protected abstract Widget
attachPinWidget
(N node, P pin) Called by the addPin method before the pin is registered to acquire a widget that is going to represent the pin in the scene.protected void
detachEdgeWidget
(E edge, Widget widget) Called by the removeEdge method to notify that an edge is removed from the graph model.protected void
detachNodeWidget
(N node, Widget widget) Called by the removeNode method to notify that a node is removed from the graph model.protected void
detachPinWidget
(P pin, Widget widget) Called by the removePin method to notify that a pin is removed from the graph model.final Collection
<E> findEdgesBetween
(P sourcePin, P targetPin) Returns a collection of edges that are between a source and a target pin.final Collection
<E> findPinEdges
(P pin, boolean allowOutputEdges, boolean allowInputEdges) Returns a collection of edges that are attached to a specified pin.final Collection
<E> getEdges()
Returns a collection of all edges registered in the graph model.final P
getEdgeSource
(E edge) Returns an edge source.final P
getEdgeTarget
(E edge) Returns an edge target.final Collection
<P> getNodePins
(N node) Returns a collection of pins that are assigned to a specified nodefinal Collection
<N> getNodes()
Returns a collection of all nodes registered in the graph model.final N
getPinNode
(P pin) Returns a node where the pin assigned to.final Collection
<P> getPins()
Returns all pins registered in the graph model.boolean
Checks whether an object is registered as an edge in the graph model.boolean
Checks whether an object is registered as a node in the graph model.boolean
Checks whether an object is registered as a pin in the graph model.protected void
notifyEdgeAdded
(E edge, Widget widget) Called by the addEdge method to notify that an edge is added into the graph model.protected void
notifyNodeAdded
(N node, Widget widget) Called by the addNode method to notify that a node is added into the graph model.protected void
notifyPinAdded
(N node, P pin, Widget widget) Called by the addPin method to notify that a pin is added into the graph model.final void
removeEdge
(E edge) Removes an edge and detaches it from its source and target pins.final void
removeNode
(N node) Removes a node with all pins that are assigned to the node.final void
removeNodeWithEdges
(N node) Removes a node with all pins that are assign to the node and with all edges that are connected to the pins.final void
Removes an pin and detaches all edges that are connected to it.final void
removePinWithEdges
(P pin) Removes a pin with all edges that are connected to the pin.final void
setEdgeSource
(E edge, P sourcePin) Sets an edge source.final void
setEdgeTarget
(E edge, P targetPin) Sets an edge target.Methods inherited from class org.netbeans.api.visual.model.ObjectScene
addObject, addObjectSceneListener, clearObjectState, createObjectHoverAction, createSelectAction, findObject, findObjectState, findStoredObject, findWidget, findWidgets, getFocusedObject, getHighlightedObjects, getHoveredObject, getIdentityCode, getObjects, getObjectState, getSelectedObjects, isObject, removeObject, removeObjectMapping, removeObjectSceneListener, setFocusedObject, setHighlightedObjects, setHoveredObject, setSelectedObjects, userSelectionSuggested
Methods inherited from class org.netbeans.api.visual.widget.Scene
addSceneListener, convertSceneToView, convertSceneToView, convertViewToScene, convertViewToScene, createBirdView, createSatelliteView, createView, createWidgetHoverAction, getActiveTool, getDefaultFont, getFocusedWidget, getGraphics, getInputBindings, getKeyEventProcessingType, getLookFeel, getMaximumBounds, getPriorActions, getResourceTable, getSceneAnimator, getView, getZoomFactor, isRepaintRequiredForRevalidating, isValidated, paint, removeSceneListener, setActiveTool, setFocusedWidget, setKeyEventProcessingType, setLookFeel, setMaximumBounds, setResourceTable, setZoomFactor, validate, validate
Methods inherited from class org.netbeans.api.visual.widget.Widget
addChild, addChild, addChild, addChild, addChildren, addDependency, bringToBack, bringToFront, calculateClientArea, convertLocalToScene, convertLocalToScene, convertSceneToLocal, convertSceneToLocal, createActions, equals, getAccessibleContext, getActions, getActions, getBackground, getBorder, getBounds, getChildConstraint, getChildren, getClientArea, getCursor, getCursorAt, getDependencies, getFont, getForeground, getLayout, getLocation, getLookup, getMaximumSize, getMinimumSize, getParentWidget, getPreferredBounds, getPreferredLocation, getPreferredSize, getScene, getState, getToolTipText, hashCode, isCheckClipping, isEnabled, isHitAt, isOpaque, isPreferredBoundsSet, isVisible, notifyAdded, notifyBackgroundChanged, notifyFontChanged, notifyForegroundChanged, notifyRemoved, notifyStateChanged, paint, paintBackground, paintBorder, paintChildren, paintWidget, removeChild, removeChildren, removeChildren, removeDependency, removeFromParent, repaint, resolveBounds, revalidate, revalidate, setAccessibleContext, setBackground, setBackgroundFromResource, setBorder, setBorder, setCheckClipping, setChildConstraint, setCursor, setEnabled, setFont, setFontFromResource, setForeground, setForegroundFromResource, setLayout, setMaximumSize, setMinimumSize, setOpaque, setPreferredBounds, setPreferredLocation, setPreferredSize, setState, setToolTipText, setVisible, updateResources
-
Constructor Details
-
GraphPinScene
public GraphPinScene()Creates a graph scene.
-
-
Method Details
-
addNode
Adds a node.- Parameters:
node
- the node to be added; the node must not be null, must not be already in the model, must be unique in the model (means: there is no other node, edge or pin in the model has is equal to this node) and must not be a Widget- Returns:
- the widget that is created by attachNodeWidget; null if the node is non-visual
-
removeNode
Removes a node with all pins that are assigned to the node.- Parameters:
node
- the node to be removed; the node must not be null and must be already in the model
-
removeNodeWithEdges
Removes a node with all pins that are assign to the node and with all edges that are connected to the pins.- Parameters:
node
- the node to be removed; the node must not be null and must be already in the model
-
getNodes
Returns a collection of all nodes registered in the graph model.- Returns:
- the collection of all nodes registered in the graph model
-
addEdge
Adds an edge.- Parameters:
edge
- the edge to be added; the edge must not be null, must not be already in the model, must be unique in the model (means: there is no other node, edge or pin in the model has is equal to this edge) and must not be a Widget- Returns:
- the widget that is created by attachEdgeWidget; null if the edge is non-visual
-
removeEdge
Removes an edge and detaches it from its source and target pins.- Parameters:
edge
- the edge to be removed; the edge must not be null and must be already in the model
-
getEdges
Returns a collection of all edges registered in the graph model.- Returns:
- the collection of all edges registered in the graph model
-
addPin
Adds a pin and assigns it to a specified node.- Parameters:
node
- the node where the pin is assigned topin
- the pin to be added; the pin must not be null, must not be already in the model, must be unique in the model (means: there is no other node, edge or pin in the model has is equal to this pin) and must not be a Widget- Returns:
- the widget that is created by attachPinWidget; null if the pin is non-visual
-
removePin
Removes an pin and detaches all edges that are connected to it.- Parameters:
pin
- the pin to be removed; the pin must not be null and must be already in the model
-
removePinWithEdges
Removes a pin with all edges that are connected to the pin.- Parameters:
pin
- the pin to be removed; the pin must not be null and must be already in the model
-
getPinNode
-
getPins
Returns all pins registered in the graph model.- Returns:
- the collection of all pins registered in the graph model
-
getNodePins
Returns a collection of pins that are assigned to a specified node- Parameters:
node
- the node- Returns:
- the collection of pins; null if node does not exist in the scene
-
setEdgeSource
-
setEdgeTarget
-
getEdgeSource
-
getEdgeTarget
-
findPinEdges
Returns a collection of edges that are attached to a specified pin.- Parameters:
pin
- the pin which edges connections are searched forallowOutputEdges
- if true, the output edges are included in the collection; if false, the output edges are not includedallowInputEdges
- if true, the input edges are included in the collection; if false, the input edges are not included- Returns:
- the collection of edges
-
findEdgesBetween
Returns a collection of edges that are between a source and a target pin.- Parameters:
sourcePin
- the source pintargetPin
- the target pin- Returns:
- the collection of edges
-
isNode
Checks whether an object is registered as a node in the graph model.- Parameters:
object
- the object; must not be a Widget- Returns:
- true, if the object is registered as a node
-
isEdge
Checks whether an object is registered as an edge in the graph model.- Parameters:
object
- the object; must not be a Widget- Returns:
- true, if the object is registered as a edge
-
isPin
Checks whether an object is registered as a pin in the graph model.- Parameters:
object
- the object; must not be a Widget- Returns:
- true, if the object is registered as a pin
-
notifyNodeAdded
-
notifyEdgeAdded
-
notifyPinAdded
Called by the addPin method to notify that a pin is added into the graph model.- Parameters:
node
- the node where the pin is assigned topin
- the added pinwidget
- the widget created by the attachPinWidget method as a visual representation of the pin
-
detachNodeWidget
Called by the removeNode method to notify that a node is removed from the graph model. The default implementation removes the node widget from its parent widget.- Parameters:
node
- the removed nodewidget
- the removed node widget; null if the node is non-visual
-
detachEdgeWidget
Called by the removeEdge method to notify that an edge is removed from the graph model. The default implementation removes the edge widget from its parent widget.- Parameters:
edge
- the removed edgewidget
- the removed edge widget; null if the edge is non-visual
-
detachPinWidget
Called by the removePin method to notify that a pin is removed from the graph model. The default implementation removes the pin widget from its parent widget.- Parameters:
pin
- the removed pinwidget
- the removed pin widget; null if the pin is non-visual
-
attachNodeWidget
Called by the addNode method before the node is registered to acquire a widget that is going to represent the node in the scene. The method is responsible for creating the widget, adding it into the scene and returning it from the method.- Parameters:
node
- the node that is going to be added- Returns:
- the widget representing the node; null, if the node is non-visual
-
attachEdgeWidget
Called by the addEdge method before the edge is registered to acquire a widget that is going to represent the edge in the scene. The method is responsible for creating the widget, adding it into the scene and returning it from the method.- Parameters:
edge
- the edge that is going to be added- Returns:
- the widget representing the edge; null, if the edge is non-visual
-
attachPinWidget
Called by the addPin method before the pin is registered to acquire a widget that is going to represent the pin in the scene. The method is responsible for creating the widget, adding it into the scene and returning it from the method.- Parameters:
node
- the node where the pin is assigned topin
- the pin that is going to be added- Returns:
- the widget representing the pin; null, if the pin is non-visual
-
attachEdgeSourceAnchor
Called by the setEdgeSource method to notify about the changing the edge source in the graph model. The method is responsible for attaching a new source pin to the edge in the visual representation.Usually it is implemented as:
Widget sourcePinWidget = findWidget (sourcePin); Anchor sourceAnchor = AnchorFactory.createRectangularAnchor (sourcePinWidget) ConnectionWidget edgeWidget = (ConnectionWidget) findWidget (edge); edgeWidget.setSourceAnchor (sourceAnchor);
- Parameters:
edge
- the edge which source is changed in graph modeloldSourcePin
- the old source pinsourcePin
- the new source pin
-
attachEdgeTargetAnchor
Called by the setEdgeTarget method to notify about the changing the edge target in the graph model. The method is responsible for attaching a new target pin to the edge in the visual representation.Usually it is implemented as:
Widget targetPinWidget = findWidget (targetPin); Anchor targetAnchor = AnchorFactory.createRectangularAnchor (targetPinWidget) ConnectionWidget edgeWidget = (ConnectionWidget) findWidget (edge); edgeWidget.setTargetAnchor (targetAnchor);
- Parameters:
edge
- the edge which target is changed in graph modeloldTargetPin
- the old target pintargetPin
- the new target pin
-