Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public abstract class AbstractGraphModel
- Object
- AbstractGraphModel
ImplementsGraphModel
Known subtypesDefaultGraphModel
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.
Constructors
public AbstractGraphModel() |
Methods
public GraphNode getNode(String id) | The node with this id, or null. |
public GraphGroup getGroup(String id) | The group with this id, or null. |
public boolean moveNode(GraphNode node, double x, double y) | Moves a node to a world position. |
public GraphEdge connect(GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort) | Makes an edge from one node or port to another. |
public boolean removeEdge(GraphEdge edge) | Removes an edge. |
public boolean removeNode(GraphNode node) | Removes a node and every edge that touches it. |
public boolean renameNode(GraphNode node, String label) | Gives a node a new label. |
public boolean setCollapsed(GraphGroup group, boolean collapsed) | Collapses or expands a group. |
public void addChangeListener(GraphChangeListener l) | Adds a listener told about every change. |
public void removeChangeListener(GraphChangeListener l) | Removes a listener. |
protected void fireChanged() | Tells every listener the model changed. |
Inherited methods
From Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait, clone, finalize
From GraphModel
Constructor details
AbstractGraphModel
public AbstractGraphModel()Method details
getNode
public GraphNode getNode(String id)The node with this id, or null.
getGroup
public GraphGroup getGroup(String id)The group with this id, or null.
moveNode
public boolean moveNode(GraphNode node, double x, double y)Moves a node to a world position.
Returns
false when the model refuses the move
connect
public GraphEdge connect(GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort)Makes an edge from one node or port to another.
Parameters
sourceGraphNode- the node the edge leaves
sourcePortGraphPort- its output port, or null
targetGraphNode- the node the edge enters
targetPortGraphPort- its input port, or null
Returns
the new edge, or null when the model refuses it
removeEdge
public boolean removeEdge(GraphEdge edge)Removes an edge.
Returns
false when the model refuses
removeNode
public boolean removeNode(GraphNode node)Removes a node and every edge that touches it.
Returns
false when the model refuses
renameNode
public boolean renameNode(GraphNode node, String label)Gives a node a new label.
Returns
false when the model refuses
setCollapsed
public boolean setCollapsed(GraphGroup group, boolean collapsed)Collapses or expands a group.
Returns
false when the model refuses
addChangeListener
public void addChangeListener(GraphChangeListener l)Adds a listener told about every change.
removeChangeListener
public void removeChangeListener(GraphChangeListener l)Removes a listener.
fireChanged
protected void fireChanged()Tells every listener the model changed.