Interface GraphModel
- All Known Implementing Classes:
AbstractGraphModel, DefaultGraphModel
public interface GraphModel
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.
-
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.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.booleansetCollapsed(GraphGroup group, boolean collapsed) Collapses or expands a group.
-
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
-
addChangeListener
Adds a listener told about every change. -
removeChangeListener
Removes a listener.
-