Interface GraphModel
- All Known Implementing Classes:
AbstractGraphModel, DefaultGraphModel
The nodes, edges and groups a com.codename1.ui.graph.NodeGraph shows.
Every edit a user makes in the view goes through one of the methods below,
so a model that refuses an edit (by returning false or null) keeps the
graph as it was. AbstractGraphModel refuses all of them; extend
DefaultGraphModel for an editable graph in memory.
Write a model of your own by extending AbstractGraphModel, not by
implementing this interface: an edit a later component learns to make
arrives there as one more method that refuses.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener told about every change.Makes an edge from one node or port to another.getEdges()Every edge.The group with this id, or null.Every group.The node with this id, or null.getNodes()Every node, in painting order: later nodes are drawn over earlier ones.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.
-
Method Details
-
getNodes
-
getEdges
-
getGroups
List<GraphGroup> getGroups()Every group. -
getNode
-
getGroup
The group with this id, or null. -
moveNode
Moves a node to a world position.
Returns
false when the model refuses the move
-
connect
Makes 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
-
removeEdge
Removes an edge.
Returns
false when the model refuses
-
removeNode
Removes a node and every edge that touches it.
Returns
false when the model refuses
-
renameNode
-
setCollapsed
Collapses or expands a group.
Returns
false when the model refuses
-
insertNode
Adds 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.
-
insertEdge
Adds 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
-
resizeNode
Gives a node a new size, in world units.
Returns
false when the model refuses
-
setNodeGroup
-
resizeGroup
Gives a lane new bounds, in world units.
Returns
false when the model refuses
-
setPortValue
-
addChangeListener
Adds a listener told about every change. -
removeChangeListener
Removes a listener.
-