org.jgraph.graph.DefaultGraphModel Class Reference

Inheritance diagram for org.jgraph.graph.DefaultGraphModel:

org.jgraph.graph.GraphModel manas.event.MyModel manas.gui.MyModel List of all members.

Public Member Functions

 DefaultGraphModel ()
 DefaultGraphModel (List roots, AttributeMap attributes)
 DefaultGraphModel (List roots, AttributeMap attributes, ConnectionSet cs)
List getRoots ()
int getRootCount ()
Object getRootAt (int index)
int getIndexOfRoot (Object root)
boolean contains (Object node)
AttributeMap getAttributes (Object node)
Object getValue (Object cell)
Map getAttributes ()
Object getSource (Object edge)
Object getTarget (Object edge)
boolean acceptsSource (Object edge, Object port)
boolean acceptsTarget (Object edge, Object port)
Iterator edges (Object port)
boolean isEdge (Object edge)
boolean isPort (Object port)
ConnectionSet getConnectionSet ()
Map cloneCells (Object[] cells)
Object getParent (Object child)
int getIndexOfChild (Object parent, Object child)
Object getChild (Object parent, int index)
int getChildCount (Object parent)
boolean isLeaf (Object node)
void insert (Object[] roots, Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] edits)
void remove (Object[] roots)
void edit (Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] edits)
void edit (Object[] inserted, Object[] removed, Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] edits)
void toBack (Object[] cells)
void toFront (Object[] cells)
Object valueForCellChanged (Object cell, Object newValue)
void addGraphModelListener (GraphModelListener l)
void removeGraphModelListener (GraphModelListener l)
void cellsChanged (final Object[] cells)
GraphModelListener[] getGraphModelListeners ()

Static Public Member Functions

static Object cloneCell (GraphModel model, Object cell)
static Object[] cloneCell (GraphModel model, Object[] cells)
static void setSourcePort (GraphModel model, Object edge, Object port)
static void setTargetPort (GraphModel model, Object edge, Object port)
static Object getSourceVertex (GraphModel model, Object edge)
static Object getTargetVertex (GraphModel model, Object edge)
static Object getUserObject (Object cell)
static boolean isGroup (GraphModel model, Object cell)
static Object[] getAll (GraphModel model)
static Object[] getRoots (GraphModel model)
static Object[] getRoots (GraphModel model, Object[] cells)
static Object[] getTopmostCells (GraphModel model, Object[] cells)
static boolean hasAncestorIn (GraphModel model, Set parents, Object child)
static List getDescendants (GraphModel model, Object[] cells)
static Object[] order (GraphModel model, Object[] cells)
static Set getEdges (GraphModel model, Object[] cells)
static Object getOpposite (GraphModel model, Object edge, Object cell)
static boolean containsEdgeBetween (GraphModel model, Object v1, Object v2)
static Object[] getEdgesBetween (GraphModel model, Object cell1, Object cell2, boolean directed)
static Object[] getOutgoingEdges (GraphModel model, Object cell)
static Object[] getIncomingEdges (GraphModel model, Object cell)
static Object[] getEdges (GraphModel model, Object cell, boolean incoming)
static boolean isVertex (GraphModel model, Object vertex)

Protected Member Functions

void setParent (Object child, Object parent)
Object cloneCell (Object cellObj)
Object cloneUserObject (Object userObject)
GraphModelLayerEdit createLayerEdit (Object[] cells, int layer)
GraphModelEdit createRemoveEdit (Object[] cells)
GraphModelEdit createEdit (Object[] inserted, Object[] removed, Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] edits)
Object[] handleInsert (Object[] cells)
Object[] handleRemove (Object[] cells)
ParentMap handleParentMap (ParentMap parentMap)
Map handleAttributes (Map attributes)
ConnectionSet handleConnectionSet (ConnectionSet cs)
void handleConnection (ConnectionSet.Connection c, boolean establish)
void connect (Object edge, Object port, boolean isSource, boolean insert)
void fireGraphChanged (Object source, GraphModelEvent.GraphModelChange edit)

Protected Attributes

transient EventListenerList listenerList = new EventListenerList()
transient Iterator emptyIterator = new EmptyIterator()
List roots = null
boolean asksAllowsChildren = false
AttributeMap attributes = null

Private Member Functions

void readObject (ObjectInputStream s) throws IOException, ClassNotFoundException

Classes

class  EmptyIterator
class  GraphModelEdit
class  GraphModelLayerEdit

Detailed Description

A simple implementation of a graph model.

Version:
1.0 1/1/02
Author:
Gaudenz Alder


Constructor & Destructor Documentation

org.jgraph.graph.DefaultGraphModel.DefaultGraphModel  ) 
 

Constructs a model that is not an attribute store.

org.jgraph.graph.DefaultGraphModel.DefaultGraphModel List  roots,
AttributeMap  attributes
 

Constructs a model that is not an attribute store.

org.jgraph.graph.DefaultGraphModel.DefaultGraphModel List  roots,
AttributeMap  attributes,
ConnectionSet  cs
 

Constructs a model using the specified information to construct the cells, attributes and connection data.


Member Function Documentation

boolean org.jgraph.graph.DefaultGraphModel.acceptsSource Object  edge,
Object  port
 

Returns true if port is a valid source for edge. edge and port must be objects previously obtained from this data source.

Returns:
true if port is a valid source for edge.

Implements org.jgraph.graph.GraphModel.

Reimplemented in manas.event.MyModel, and manas.gui.MyModel.

boolean org.jgraph.graph.DefaultGraphModel.acceptsTarget Object  edge,
Object  port
 

Returns true if port is a valid target for edge. edge and port must be objects previously obtained from this data source.

Returns:
true if port is a valid target for edge.

Implements org.jgraph.graph.GraphModel.

Reimplemented in manas.event.MyModel, and manas.gui.MyModel.

void org.jgraph.graph.DefaultGraphModel.addGraphModelListener GraphModelListener  l  ) 
 

Adds a listener for the GraphModelEvent posted after the graph changes.

See also:
removeGraphModelListener
Parameters:
l the listener to add

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.cellsChanged final Object[]  cells  ) 
 

Invoke this method after you've changed how the cells are to be represented in the graph.

static Object [] org.jgraph.graph.DefaultGraphModel.cloneCell GraphModel  model,
Object[]  cells
[static]
 

Returns a deep clone of the specified cells, including all children.

static Object org.jgraph.graph.DefaultGraphModel.cloneCell GraphModel  model,
Object  cell
[static]
 

Returns a deep clone of the specified cell, including all children.

Object org.jgraph.graph.DefaultGraphModel.cloneCell Object  cellObj  )  [protected]
 

Creates a shallow copy of the cell including a copy of the user object. Subclassers can override the cloneUserObject to provide a custom user object cloning mechanism.

Map org.jgraph.graph.DefaultGraphModel.cloneCells Object[]  cells  ) 
 

Returns a map of (cell, clone)-pairs for all cells. In the new array, all references are replaced with references to the cloned cells (ie parent or anchor). This method does only include children which are in cells. Use JGraph.getDescendants to get a complete list of all children.

Implements org.jgraph.graph.GraphModel.

Object org.jgraph.graph.DefaultGraphModel.cloneUserObject Object  userObject  )  [protected]
 

Clones the user object. Helper method that is invoked from cloneCells. You must use cloneCells (or cloneCell for single cells) to get a deep copy of a clone. Subclassers must override this and valueForCellChanged to implement custom user objects. This implementation returns object.

void org.jgraph.graph.DefaultGraphModel.connect Object  edge,
Object  port,
boolean  isSource,
boolean  insert
[protected]
 

Connects or disconnects the edge and port in this model based on remove. Subclassers should override this to update connectivity datastructures.

boolean org.jgraph.graph.DefaultGraphModel.contains Object  node  ) 
 

Returns true if node or one of its ancestors is in the model.

Returns:
true if node is in the model

Implements org.jgraph.graph.GraphModel.

static boolean org.jgraph.graph.DefaultGraphModel.containsEdgeBetween GraphModel  model,
Object  v1,
Object  v2
[static]
 

Returns true if the given vertices are conntected by a single edge in this document.

GraphModelEdit org.jgraph.graph.DefaultGraphModel.createEdit Object[]  inserted,
Object[]  removed,
Map  attributes,
ConnectionSet  cs,
ParentMap  pm,
UndoableEdit[]  edits
[protected]
 

GraphModelLayerEdit org.jgraph.graph.DefaultGraphModel.createLayerEdit Object[]  cells,
int  layer
[protected]
 

GraphModelEdit org.jgraph.graph.DefaultGraphModel.createRemoveEdit Object[]  cells  )  [protected]
 

Returns an edit that represents a remove.

Iterator org.jgraph.graph.DefaultGraphModel.edges Object  port  ) 
 

Returns an iterator of the edges connected to port. port must be a object previously obtained from this data source. This method never returns null.

Parameters:
port a port in the graph, obtained from this data source
Returns:
Iterator that represents the connected edges

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.edit Object[]  inserted,
Object[]  removed,
Map  attributes,
ConnectionSet  cs,
ParentMap  pm,
UndoableEdit[]  edits
 

Applies attributes and the connection changes to the model. The initial edits that triggered the call are considered to be part of this transaction. The passed-in edits are executed if they implement the GraphModelEvent.ExecutableGraphChange interface in ascending array-order, after execution of the model change. Notifies the model- and undo listeners of the change. Note: If only edits is non-null, the edits are directly passed to the UndoableEditListeners. Note: The passed-in propertyMap may contains PortViews which must be turned into Points when stored in the model.

void org.jgraph.graph.DefaultGraphModel.edit Map  attributes,
ConnectionSet  cs,
ParentMap  pm,
UndoableEdit[]  edits
 

Shortcut to the new edit method which allows inserts and removes to go along with an edit.

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.fireGraphChanged Object  source,
GraphModelEvent.GraphModelChange  edit
[protected]
 

static Object [] org.jgraph.graph.DefaultGraphModel.getAll GraphModel  model  )  [static]
 

Returns all cells of the model in an array.

See also:
getDescendants(GraphModel, Object[])
Returns:
Returns all cells in the model including all descandants.

Map org.jgraph.graph.DefaultGraphModel.getAttributes  ) 
 

Returns the graph model's attribute. Shortcut to getAttributes(null).

Returns:
attributes of node as a Map

AttributeMap org.jgraph.graph.DefaultGraphModel.getAttributes Object  node  ) 
 

Returns a Map that represents the attributes for the specified cell. This attributes have precedence over each view's attributes, regardless of isAttributeStore.

Returns:
attributes of node as a Map

Implements org.jgraph.graph.GraphModel.

Object org.jgraph.graph.DefaultGraphModel.getChild Object  parent,
int  index
 

Returns the child of parent at index index in the parent's child array. parent must be a node previously obtained from this data source. This should not return null if index is a valid index for parent (that is index >= 0 && index < getChildCount( parent )).

Parameters:
parent a node in the tree, obtained from this data source
Returns:
the child of parent at index index

Implements org.jgraph.graph.GraphModel.

int org.jgraph.graph.DefaultGraphModel.getChildCount Object  parent  ) 
 

Returns the number of children of parent . Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.

Parameters:
parent a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

Implements org.jgraph.graph.GraphModel.

ConnectionSet org.jgraph.graph.DefaultGraphModel.getConnectionSet  ) 
 

A shortcut method to create a connection set that represents the connections in this model. Useful for encoding to avoid writing redundant connection data stored in the cells.

static List org.jgraph.graph.DefaultGraphModel.getDescendants GraphModel  model,
Object[]  cells
[static]
 

Flattens the given array of root cells by adding the roots and their descandants. The resulting set contains all cells, which means it contains branches and leafs. Note: This is an iterative implementation. No recursion used.
Note: This returns a linked list, for frequent read operations you should turn this into an array, or at least an array list.

static Object [] org.jgraph.graph.DefaultGraphModel.getEdges GraphModel  model,
Object  cell,
boolean  incoming
[static]
 

Returns the incoming or outgoing edges for cell. Cell should be a port or a vertex.

static Set org.jgraph.graph.DefaultGraphModel.getEdges GraphModel  model,
Object[]  cells
[static]
 

Returns the set of all connected edges to cells or their descendants. The passed-in cells are never returned as part of the result set. This can be used on vertices, edges and ports.

static Object [] org.jgraph.graph.DefaultGraphModel.getEdgesBetween GraphModel  model,
Object  cell1,
Object  cell2,
boolean  directed
[static]
 

Returns the edges between two specified ports or two specified vertices. If directed is true then cell1 must be the source of the returned edges. This method never returns null. If there are no edges between the specified cells, then an array of length 0 is returned.

GraphModelListener [] org.jgraph.graph.DefaultGraphModel.getGraphModelListeners  ) 
 

Return an array of all GraphModelListeners that were added to this model.

static Object [] org.jgraph.graph.DefaultGraphModel.getIncomingEdges GraphModel  model,
Object  cell
[static]
 

Returns the incoming edges for cell. Cell should be a port or a vertex.

int org.jgraph.graph.DefaultGraphModel.getIndexOfChild Object  parent,
Object  child
 

Returns the index of child in parent. If either the parent or child is null, returns -1.

Parameters:
parent a note in the tree, obtained from this data source
child the node we are interested in
Returns:
the index of the child in the parent, or -1 if either the parent or the child is null

Implements org.jgraph.graph.GraphModel.

int org.jgraph.graph.DefaultGraphModel.getIndexOfRoot Object  root  ) 
 

Returns the index of root in the model. If root is null, returns -1.

Parameters:
root a root in the model, obtained from this data source
Returns:
the index of the root in the model, or -1 if the parent is null

Implements org.jgraph.graph.GraphModel.

static Object org.jgraph.graph.DefaultGraphModel.getOpposite GraphModel  model,
Object  edge,
Object  cell
[static]
 

Returns:
Returns the opposite port or vertex in edge.

static Object [] org.jgraph.graph.DefaultGraphModel.getOutgoingEdges GraphModel  model,
Object  cell
[static]
 

Returns the outgoing edges for cell. Cell should be a port or a vertex.

Object org.jgraph.graph.DefaultGraphModel.getParent Object  child  ) 
 

Returns the parent of child in the model. child must be a node previously obtained from this data source. This returns null if child is a root in the model.

Parameters:
child a node in the graph, obtained from this data source
Returns:
the parent of child

Implements org.jgraph.graph.GraphModel.

Object org.jgraph.graph.DefaultGraphModel.getRootAt int  index  ) 
 

Returns the root at index index in the model. This should not return null if index is a valid index for the model (that is index >= 0 && index < getRootCount()).

Returns:
the root of at index index

Implements org.jgraph.graph.GraphModel.

int org.jgraph.graph.DefaultGraphModel.getRootCount  ) 
 

Returns the number of roots in the model. Returns 0 if the model is empty.

Returns:
the number of roots in the model

Implements org.jgraph.graph.GraphModel.

static Object [] org.jgraph.graph.DefaultGraphModel.getRoots GraphModel  model,
Object[]  cells
[static]
 

Returns the roots in cells by checking if their parent is null. This implementation only uses the GraphModel interface. This method never returns null.

static Object [] org.jgraph.graph.DefaultGraphModel.getRoots GraphModel  model  )  [static]
 

Returns the roots of the specified model as an array. This implementation uses the GraphModel interface in the general case, but if the model is a DefaultGraphModel the performance can be improved to linear time.

List org.jgraph.graph.DefaultGraphModel.getRoots  ) 
 

Object org.jgraph.graph.DefaultGraphModel.getSource Object  edge  ) 
 

Returns the source of edge. edge must be an object previously obtained from this data source.

Returns:
Object that represents the source of edge

Implements org.jgraph.graph.GraphModel.

static Object org.jgraph.graph.DefaultGraphModel.getSourceVertex GraphModel  model,
Object  edge
[static]
 

Returns the source vertex of the edge by calling getParent on getSource on the specified model.

Object org.jgraph.graph.DefaultGraphModel.getTarget Object  edge  ) 
 

Returns the target of edge. edge must be an object previously obtained from this data source.

Returns:
Object that represents the target of edge

Implements org.jgraph.graph.GraphModel.

static Object org.jgraph.graph.DefaultGraphModel.getTargetVertex GraphModel  model,
Object  edge
[static]
 

Returns the target vertex of the edge by calling getParent on getTarget on the specified model.

static Object [] org.jgraph.graph.DefaultGraphModel.getTopmostCells GraphModel  model,
Object[]  cells
[static]
 

Returns:
Returns the roots of cells, eg. an array that contains no cell having an ancestor in cells.

static Object org.jgraph.graph.DefaultGraphModel.getUserObject Object  cell  )  [static]
 

Returns:
Returns the user object of the given cell. This implementation checks if the cell is a default mutable tree node and returns it's user object.
Deprecated:
Use GraphModel#getValue(Object) instead.

Object org.jgraph.graph.DefaultGraphModel.getValue Object  cell  ) 
 

Returns:
Returns the user object of the given cell. This implementation checks if the cell is a default mutable tree node and returns it's user object.

Implements org.jgraph.graph.GraphModel.

Map org.jgraph.graph.DefaultGraphModel.handleAttributes Map  attributes  )  [protected]
 

Applies attributes to the cells specified as keys. Returns the attributes to undo the change.

void org.jgraph.graph.DefaultGraphModel.handleConnection ConnectionSet.Connection  c,
boolean  establish
[protected]
 

Inserts the specified connection into the model.

ConnectionSet org.jgraph.graph.DefaultGraphModel.handleConnectionSet ConnectionSet  cs  )  [protected]
 

Applies connectionSet to the model. Returns a connection set that may be used to undo this change.

Object [] org.jgraph.graph.DefaultGraphModel.handleInsert Object[]  cells  )  [protected]
 

Inserts cells into the model. Returns the cells that were inserted (including descendants).

ParentMap org.jgraph.graph.DefaultGraphModel.handleParentMap ParentMap  parentMap  )  [protected]
 

Applies cells to the model. Returns a parent map that may be used to undo this change.

Object [] org.jgraph.graph.DefaultGraphModel.handleRemove Object[]  cells  )  [protected]
 

Removes cells from the model. Returns the cells that were removed as roots.

static boolean org.jgraph.graph.DefaultGraphModel.hasAncestorIn GraphModel  model,
Set  parents,
Object  child
[static]
 

Returns true if the specified child has an ancestor in parents.

void org.jgraph.graph.DefaultGraphModel.insert Object[]  roots,
Map  attributes,
ConnectionSet  cs,
ParentMap  pm,
UndoableEdit[]  edits
 

Inserts the roots and connections into the model. Notifies the model- and undo listeners of the change. The passed-in edits are executed if they implement the GraphModelEvent.ExecutableGraphChange interface in ascending array-order, after execution of the model change. Note: The passed-in propertyMap may contain PortView s which must be turned into Point s when stored in the model.

Implements org.jgraph.graph.GraphModel.

boolean org.jgraph.graph.DefaultGraphModel.isEdge Object  edge  ) 
 

Returns true if edge is a valid edge.

Returns:
true if edge is a valid edge.

Implements org.jgraph.graph.GraphModel.

static boolean org.jgraph.graph.DefaultGraphModel.isGroup GraphModel  model,
Object  cell
[static]
 

Checks whether the cell has at least one child which is not a port. This implementation operates on the model, not taking into account visibility of cells. It returns true for groups regardless of their folded state.

Parameters:
cell the cell to check for being a group
Returns:
Returns true if the cell contains at least one cell which is not a port

boolean org.jgraph.graph.DefaultGraphModel.isLeaf Object  node  ) 
 

Returns whether the specified node is a leaf node. The way the test is performed depends on the.

Parameters:
node the node to check
Returns:
true if the node is a leaf node

Implements org.jgraph.graph.GraphModel.

boolean org.jgraph.graph.DefaultGraphModel.isPort Object  port  ) 
 

Returns true if port is a valid port, possibly supporting edge connection.

Returns:
true if port is a valid port.

Implements org.jgraph.graph.GraphModel.

static boolean org.jgraph.graph.DefaultGraphModel.isVertex GraphModel  model,
Object  vertex
[static]
 

Returns true if vertex is a valid vertex.

Returns:
true if vertex is a valid vertex.

static Object [] org.jgraph.graph.DefaultGraphModel.order GraphModel  model,
Object[]  cells
[static]
 

Orders cells so that they reflect the model order.

void org.jgraph.graph.DefaultGraphModel.readObject ObjectInputStream  s  )  throws IOException, ClassNotFoundException [private]
 

void org.jgraph.graph.DefaultGraphModel.remove Object[]  roots  ) 
 

Removes cells from the model. Notifies the model- and undo listeners of the change.

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.removeGraphModelListener GraphModelListener  l  ) 
 

Removes a listener previously added with addGraphModelListener() .

See also:
addGraphModelListener
Parameters:
l the listener to remove

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.setParent Object  child,
Object  parent
[protected]
 

Sets the parent of the specified cell.

static void org.jgraph.graph.DefaultGraphModel.setSourcePort GraphModel  model,
Object  edge,
Object  port
[static]
 

Helper methods that connects the source of edge to port in model</model>.

static void org.jgraph.graph.DefaultGraphModel.setTargetPort GraphModel  model,
Object  edge,
Object  port
[static]
 

Helper methods that connects the source of edge to port in model</model>.

void org.jgraph.graph.DefaultGraphModel.toBack Object[]  cells  ) 
 

Sends cells to back.

Implements org.jgraph.graph.GraphModel.

void org.jgraph.graph.DefaultGraphModel.toFront Object[]  cells  ) 
 

Brings cells to front.

Implements org.jgraph.graph.GraphModel.

Object org.jgraph.graph.DefaultGraphModel.valueForCellChanged Object  cell,
Object  newValue
 

Applies the new value to the specified cell. Unfortunately for cloning the user object you must still override the attribute map and provide a custom cloneUserObject method. This is because the cloning of a cell is local to the cell, which in turn has a reference to its attribute map.

Parameters:
cell 
newValue 
Returns:
the old value for the cell, if any

Implements org.jgraph.graph.GraphModel.


Member Data Documentation

boolean org.jgraph.graph.DefaultGraphModel.asksAllowsChildren = false [protected]
 

Indicates whether isLeaf is based on a node's allowsChildren value.

AttributeMap org.jgraph.graph.DefaultGraphModel.attributes = null [protected]
 

The model's own attributes as a map. Defaults to an empty Hashtable.

transient Iterator org.jgraph.graph.DefaultGraphModel.emptyIterator = new EmptyIterator() [protected]
 

Default instance of an empty iterator.

transient EventListenerList org.jgraph.graph.DefaultGraphModel.listenerList = new EventListenerList() [protected]
 

The list of listeners that listen to the model.

List org.jgraph.graph.DefaultGraphModel.roots = null [protected]
 

Set that contains all root cells of this model.


The documentation for this class was generated from the following file:
Generated on Sun May 28 19:13:14 2006 for Digimod by  doxygen 1.4.6-NO