public abstract class GraphModel extends Object
Operations on nodes and edges can be performed by accessing the appropriate NodeAdapter or EdgeAdapter and calling their methods. The GraphModel class provides an event notification mechanism over the top of this basic functionality. Specifically, any operations that modify the graph, such as adding a node or edge, should be performed through the interface in GraphModel so that events are generated for listeners. Many methods are also provided that delegate to the appropriate adapter method; in these case, documentation here is incomplete, and the adaptor method is referred to.
Event dispatching can also be done explicitly by calling the dispatchEvent() method. This can be used if a series of graph modifications will be performed and it is preferable to just generate a single event. Event dispatching can also be turned on or off with the setDispatchEnabled() method (by default, dispatching is on).
Modifier and Type | Field and Description |
---|---|
protected GraphEventMulticaster |
_graphListeners
The list of graph listeners.
|
Constructor and Description |
---|
GraphModel() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptHead(Object edge,
Object node)
Return true if the head of the given edge can be attached to the
given node.
|
boolean |
acceptTail(Object edge,
Object node)
Return true if the tail of the given edge can be attached to the
given node.
|
void |
addEdge(Object eventSource,
Object edge,
Object parent)
Add a edge to the graph.
|
void |
addGraphListener(GraphListener l)
Add a graph listener to the model.
|
void |
addNode(Object eventSource,
Object node,
Object parent)
Add a node to the graph.
|
void |
connectEdge(Object eventSource,
Object edge,
Object tailNode,
Object headNode)
Deprecated.
|
void |
disconnectEdge(Object eventSource,
Object edge)
Deprecated.
|
void |
dispatchGraphEvent(GraphEvent e)
Send an graph event to all of the graph listeners.
|
abstract EdgeAdapter |
getEdgeAdapter(Object edge)
Return the adapter for the given edge object.
|
Object |
getHead(Object edge)
Return the head node of the given edge.
|
abstract NodeAdapter |
getNodeAdapter(Object node)
Return the adapter for the given node object.
|
int |
getNodeCount(Object node)
Return the number of nodes contained in
the given node.
|
Object |
getParent(Object node)
Return the parent graph of this node, return
null if there is no parent.
|
Object |
getRoot()
Return the root graph of this graph model.
|
Object |
getTail(Object edge)
Return the tail node of this edge.
|
Iterator |
inEdges(Object node)
Return an iterator over the in edges of this
node.
|
boolean |
isComposite(Object node)
Return true if the given object is a composite
node in this model, i.e.
|
boolean |
isDispatchEnabled()
Test if dispatching is enabled
|
boolean |
isEdge(Object o)
Return true if the given object is a
node in this model.
|
boolean |
isNode(Object o)
Return true if the given object is a
node in this model.
|
Iterator |
nodes(Object node)
Provide an iterator over the nodes in the
given node.
|
Iterator |
outEdges(Object node)
Return an iterator over the out edges of this
node.
|
void |
removeGraphListener(GraphListener l)
Remove the given listener from this graph model.
|
void |
removeNode(Object eventSource,
Object node)
Delete a node from its parent graph and notify
graph listeners with a NODE_REMOVED event.
|
void |
setDispatchEnabled(boolean val)
Turn on/off all event dispatches from this graph model, for use
in an inner-loop algorithm.
|
void |
setHead(Object eventSource,
Object edge,
Object head)
Connect an edge to the given head node.
|
protected void |
setRoot(Object root)
Set the root of the graph.
|
void |
setTail(Object eventSource,
Object edge,
Object tail)
Connect an edge to the given tail node.
|
protected GraphEventMulticaster _graphListeners
public boolean acceptHead(Object edge, Object node)
public boolean acceptTail(Object edge, Object node)
public void addGraphListener(GraphListener l)
public void addEdge(Object eventSource, Object edge, Object parent)
public void addNode(Object eventSource, Object node, Object parent)
public void connectEdge(Object eventSource, Object edge, Object tailNode, Object headNode)
public void disconnectEdge(Object eventSource, Object edge)
public void dispatchGraphEvent(GraphEvent e)
This method furthermore ensures that all graph events are dispatched in the event thread.
setDispatchEnabled(boolean)
public abstract EdgeAdapter getEdgeAdapter(Object edge)
public int getNodeCount(Object node)
public abstract NodeAdapter getNodeAdapter(Object node)
public Object getParent(Object node)
public Object getRoot()
public Iterator inEdges(Object node)
public boolean isComposite(Object node)
public boolean isDispatchEnabled()
public boolean isEdge(Object o)
public boolean isNode(Object o)
public Iterator nodes(Object node)
public Iterator outEdges(Object node)
public void removeGraphListener(GraphListener l)
public void removeNode(Object eventSource, Object node)
public void setDispatchEnabled(boolean val)
dispatchGraphEvent(GraphEvent)
public void setHead(Object eventSource, Object edge, Object head)
protected void setRoot(Object root)
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.