Class AbstractGraphModel
- All Implemented Interfaces:
GraphModel
- Direct Known Subclasses:
DefaultGraphModel
The listener list, the lookups and the refusals every read-only model shares.
A subclass supplies getNodes, getEdges and getGroups. Every edit is
refused until the matching method is overridden.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener told about every change.Makes an edge from one node or port to another.protected voidTells every listener the model changed.The group with this id, or null.The node with this id, or null.booleaninsertEdge(GraphEdge edge, int index) Adds an edge as it is, without the checksconnectmakes: pasting and undo put back edges that were valid when they were made.booleaninsertNode(GraphNode node, int index) Adds a node the user made, from a palette or by pasting.booleanMoves a node to a world position.voidRemoves a listener.booleanremoveEdge(GraphEdge edge) Removes an edge.booleanremoveNode(GraphNode node) Removes a node and every edge that touches it.booleanrenameNode(GraphNode node, String label) Gives a node a new label.booleanresizeGroup(GraphGroup group, double x, double y, double width, double height) Gives a lane new bounds, in world units.booleanresizeNode(GraphNode node, double width, double height) Gives a node a new size, in world units.booleansetCollapsed(GraphGroup group, boolean collapsed) Collapses or expands a group.booleansetNodeGroup(GraphNode node, String groupId) Moves a node into a group or a lane, or out of every one with null.booleansetPortValue(GraphPort port, Object value) Sets the value an unconnected input port uses.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GraphModel
getEdges, getGroups, getNodes
-
Constructor Details
-
AbstractGraphModel
public AbstractGraphModel()
-
-
Method Details
-
getNode
Description copied from interface:GraphModelThe node with this id, or null.- Specified by:
getNodein interfaceGraphModel
-
getGroup
Description copied from interface:GraphModelThe group with this id, or null.- Specified by:
getGroupin interfaceGraphModel
-
moveNode
Description copied from interface:GraphModelMoves a node to a world position.
Returns
false when the model refuses the move
- Specified by:
moveNodein interfaceGraphModel
-
connect
public GraphEdge connect(GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort) Description copied from interface:GraphModelMakes an edge from one node or port to another.
Parameters
source: the node the edge leavessourcePort: its output port, or nulltarget: the node the edge enterstargetPort: its input port, or null
Returns
the new edge, or null when the model refuses it
- Specified by:
connectin interfaceGraphModel
-
removeEdge
Description copied from interface:GraphModelRemoves an edge.
Returns
false when the model refuses
- Specified by:
removeEdgein interfaceGraphModel
-
removeNode
Description copied from interface:GraphModelRemoves a node and every edge that touches it.
Returns
false when the model refuses
- Specified by:
removeNodein interfaceGraphModel
-
renameNode
Description copied from interface:GraphModelGives a node a new label.
Returns
false when the model refuses
- Specified by:
renameNodein interfaceGraphModel
-
setCollapsed
Description copied from interface:GraphModelCollapses or expands a group.
Returns
false when the model refuses
- Specified by:
setCollapsedin interfaceGraphModel
-
insertNode
Description copied from interface:GraphModelAdds a node the user made, from a palette or by pasting.
Returns
false when the model refuses, or already has a node with this id
Parameters
node: the nodeindex: where ingetNodesit goes, which is its painting order; negative, or past the end, for the end. Undoing a removal puts a node back where it was.
A view's undo of a delete puts nodes back through this method, so a model that refuses it cannot have its deletes undone.
- Specified by:
insertNodein interfaceGraphModel
-
insertEdge
Description copied from interface:GraphModelAdds an edge as it is, without the checks
connectmakes: pasting and undo put back edges that were valid when they were made.Returns
false when the model refuses, has an edge with this id, or lacks one of the nodes the edge names
Parameters
edge: the edgeindex: where ingetEdgesit goes; negative, or past the end, for the end
- Specified by:
insertEdgein interfaceGraphModel
-
resizeNode
Description copied from interface:GraphModelGives a node a new size, in world units.
Returns
false when the model refuses
- Specified by:
resizeNodein interfaceGraphModel
-
setNodeGroup
Description copied from interface:GraphModelMoves a node into a group or a lane, or out of every one with null.
Returns
false when the model refuses
- Specified by:
setNodeGroupin interfaceGraphModel
-
resizeGroup
Description copied from interface:GraphModelGives a lane new bounds, in world units.
Returns
false when the model refuses
- Specified by:
resizeGroupin interfaceGraphModel
-
setPortValue
Description copied from interface:GraphModelSets the value an unconnected input port uses.
Returns
false when the model refuses
- Specified by:
setPortValuein interfaceGraphModel
-
addChangeListener
Description copied from interface:GraphModelAdds a listener told about every change.- Specified by:
addChangeListenerin interfaceGraphModel
-
removeChangeListener
Description copied from interface:GraphModelRemoves a listener.- Specified by:
removeChangeListenerin interfaceGraphModel
-
fireChanged
protected void fireChanged()Tells every listener the model changed.
-