edu.iastate.metnet.graphmodel
Class MyJGraphModelAdapter

java.lang.Object
  extended by javax.swing.undo.UndoableEditSupport
      extended by org.jgraph.graph.DefaultGraphModel
          extended by edu.iastate.metnet.graphmodel.MyJGraphModelAdapter
All Implemented Interfaces:
java.io.Serializable, org.jgraph.graph.GraphModel

public class MyJGraphModelAdapter
extends org.jgraph.graph.DefaultGraphModel

See Also:
Serialized Form

Nested Class Summary
 class MyJGraphModelAdapter.DefaultCellFactory
          A simple default cell factory.
static interface MyJGraphModelAdapter.ICellFactory
          Creates the JGraph cells that reflect the respective JGraphT elements.
 
Nested classes/interfaces inherited from class org.jgraph.graph.DefaultGraphModel
org.jgraph.graph.DefaultGraphModel.EmptyIterator, org.jgraph.graph.DefaultGraphModel.GraphModelEdit, org.jgraph.graph.DefaultGraphModel.GraphModelLayerEdit
 
Field Summary
(package private)  java.util.Set m_jEdgesBeingAdded
           
(package private)  java.util.Set m_jEdgesBeingRemoved
           
(package private)  java.util.Set m_jtEdgesBeingAdded
           
(package private)  java.util.Set m_jtEdgesBeingRemoved
           
(package private)  java.util.Set m_jtVerticesBeingAdded
           
(package private)  java.util.Set m_jtVerticesBeingRemoved
           
(package private)  java.util.Set m_jVerticesBeingAdded
           
(package private)  java.util.Set m_jVerticesBeingRemoved
           
 
Fields inherited from class org.jgraph.graph.DefaultGraphModel
asksAllowsChildren, attributes, emptyIterator, listenerList, roots
 
Fields inherited from class javax.swing.undo.UndoableEditSupport
compoundEdit, listeners, realSource, updateLevel
 
Constructor Summary
MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph)
          Constructs a new JGraph model adapter for the specified JGraphT graph.
MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap defaultEdgeAttributes, MyJGraphModelAdapter.ICellFactory cellFactory)
          Constructs a new JGraph model adapter for the specified JGraphT graph.
MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph, java.util.Map defaultVertexAttributes, java.util.Map defaultEdgeAttributes)
          Constructs a new JGraph model adapter for the specified JGraphT graph.
MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph, java.util.Map defaultVertexAttributes, java.util.Map defaultEdgeAttributes, MyJGraphModelAdapter.ICellFactory cellFactory)
          Constructs a new JGraph model adapter for the specified JGraphT graph.
 
Method Summary
protected  boolean addJGraphEdge(org.jgraph.graph.Edge jEdge)
          Adds an edge corresponding to the specified JGraph edge to the underlying JGraphT graph.
protected  void addJGraphTEdge(org._3pq.jgrapht.Edge jtEdge)
          Adds the specified JGraphT edge to be reflected by this graph model.
protected  void addJGraphTVertex(java.lang.Object jtVertex)
          Adds the specified JGraphT vertex to be reflected by this graph model.
protected  boolean addJGraphVertex(org.jgraph.graph.GraphCell jVertex)
          Add a vertex corresponding to this JGraph vertex to the JGraphT graph.
static org.jgraph.graph.AttributeMap createDefaultEdgeAttributes(org._3pq.jgrapht.Graph jGraphTGraph)
          Creates and returns a map of attributes to be used as defaults for edge attributes, depending on the specified graph.
static org.jgraph.graph.AttributeMap createDefaultVertexAttributes()
          Creates and returns a map of attributes to be used as defaults for vertex attributes.
 void edit(java.util.Map attrs)
          Applies the specified attributes to the model, as in GraphModel.edit(java.util.Map, org.jgraph.graph.ConnectionSet, org.jgraph.graph.ParentMap, javax.swing.undo.UndoableEdit[]) method.
 org.jgraph.graph.DefaultEdge getEdgeCell(org._3pq.jgrapht.Edge jGraphTEdge)
          Returns the JGraph edge cell that corresponds to the specified JGraphT edge.
 org._3pq.jgrapht.Graph getM_jtGraph()
           
 org.jgraph.graph.DefaultGraphCell getVertexCell(java.lang.Object jGraphTVertex)
          Returns the JGraph vertex cell that corresponds to the specified JGraphT vertex.
 org.jgraph.graph.DefaultPort getVertexPort(java.lang.Object jGraphTVertex)
          Returns the JGraph port cell that corresponds to the specified JGraphT vertex.
 boolean isStoreInteraction()
           
protected  boolean removeJGraphEdge(org.jgraph.graph.Edge jEdge)
          Remove the edge corresponding to this JGraph edge from the JGraphT graph.
protected  void removeJGraphTEdge(org._3pq.jgrapht.Edge jtEdge)
          Removes the specified JGraphT edge from being reflected by this graph model.
protected  void removeJGraphTVertex(java.lang.Object jtVertex)
          Removes the specified JGraphT vertex from being reflected by this graph model.
protected  boolean removeJGraphVertex(org.jgraph.graph.GraphCell jVertex)
          Remove the vertex corresponding to this JGraph vertex from the JGraphT graph.
 void setStoreInteraction(boolean storeInteraction)
           
 
Methods inherited from class org.jgraph.graph.DefaultGraphModel
acceptsSource, acceptsTarget, addGraphModelListener, cellsChanged, cloneCell, cloneCell, cloneCell, cloneCells, cloneUserObject, connect, contains, containsEdgeBetween, createEdit, createLayerEdit, createRemoveEdit, edges, edit, edit, fireGraphChanged, getAll, getAttributes, getAttributes, getChild, getChildCount, getConnectionSet, getDescendants, getEdges, getEdges, getEdgesBetween, getGraphModelListeners, getIncomingEdges, getIndexOfChild, getIndexOfRoot, getOpposite, getOutgoingEdges, getParent, getRootAt, getRootCount, getRoots, getRoots, getRoots, getSource, getSourceVertex, getTarget, getTargetVertex, getTopmostCells, getUserObject, getValue, handleAttributes, handleConnection, handleConnectionSet, handleInsert, handleParentMap, handleRemove, hasAncestorIn, insert, isEdge, isGroup, isLeaf, isPort, isVertex, order, remove, removeGraphModelListener, setParent, setSourcePort, setTargetPort, toBack, toFront, valueForCellChanged
 
Methods inherited from class javax.swing.undo.UndoableEditSupport
_postEdit, addUndoableEditListener, beginUpdate, createCompoundEdit, endUpdate, getUndoableEditListeners, getUpdateLevel, postEdit, removeUndoableEditListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jgraph.graph.GraphModel
addUndoableEditListener, removeUndoableEditListener
 

Field Detail

m_jEdgesBeingAdded

final java.util.Set m_jEdgesBeingAdded

m_jEdgesBeingRemoved

final java.util.Set m_jEdgesBeingRemoved

m_jVerticesBeingAdded

final java.util.Set m_jVerticesBeingAdded

m_jVerticesBeingRemoved

final java.util.Set m_jVerticesBeingRemoved

m_jtEdgesBeingAdded

final java.util.Set m_jtEdgesBeingAdded

m_jtEdgesBeingRemoved

final java.util.Set m_jtEdgesBeingRemoved

m_jtVerticesBeingAdded

final java.util.Set m_jtVerticesBeingAdded

m_jtVerticesBeingRemoved

final java.util.Set m_jtVerticesBeingRemoved
Constructor Detail

MyJGraphModelAdapter

public MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph)
Constructs a new JGraph model adapter for the specified JGraphT graph.

Parameters:
jGraphTGraphet - the JGraphT graph for which JGraph model adapter to be created.

MyJGraphModelAdapter

public MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph,
                            java.util.Map defaultVertexAttributes,
                            java.util.Map defaultEdgeAttributes)
Constructs a new JGraph model adapter for the specified JGraphT graph.

Parameters:
jGraphTGraph - the JGraphT graph for which JGraph model adapter to be created.
defaultVertexAttributes - a default map of JGraph attributes to format vertices, or null to use internal defaults.
defaultEdgeAttributes - a default map of JGraph attributes to format edges, or null to use internal defaults.

MyJGraphModelAdapter

public MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph,
                            org.jgraph.graph.AttributeMap defaultVertexAttributes,
                            org.jgraph.graph.AttributeMap defaultEdgeAttributes,
                            MyJGraphModelAdapter.ICellFactory cellFactory)
Constructs a new JGraph model adapter for the specified JGraphT graph.

Parameters:
jGraphTGraph - the JGraphT graph for which JGraph model adapter to be created.
defaultVertexAttributes - a default map of JGraph attributes to format vertices, or null to use internal defaults.
defaultEdgeAttributes - a default map of JGraph attributes to format edges, or null to use internal defaults.
cellFactory - a MyJGraphModelAdapter.ICellFactoryto be used to create the JGraph cells, or null to use internal default factory.

MyJGraphModelAdapter

public MyJGraphModelAdapter(org._3pq.jgrapht.Graph jGraphTGraph,
                            java.util.Map defaultVertexAttributes,
                            java.util.Map defaultEdgeAttributes,
                            MyJGraphModelAdapter.ICellFactory cellFactory)
Constructs a new JGraph model adapter for the specified JGraphT graph.

Parameters:
jGraphTGraph - the JGraphT graph for which JGraph model adapter to be created.
defaultVertexAttributes - a default map of JGraph attributes to format vertices, or null to use internal defaults.
defaultEdgeAttributes - a default map of JGraph attributes to format edges, or null to use internal defaults.
cellFactory - a MyJGraphModelAdapter.ICellFactoryto be used to create the JGraph cells, or null to use internal default factory. ?deprecated will be deleted, use #JGraphModelAdapter(Graph, AttributeMap, AttributeMap, CellFactory) instead.
Method Detail

getEdgeCell

public org.jgraph.graph.DefaultEdge getEdgeCell(org._3pq.jgrapht.Edge jGraphTEdge)
Returns the JGraph edge cell that corresponds to the specified JGraphT edge. If no corresponding cell found, returns null.

Parameters:
jGraphTEdge - a JGraphT edge of the JGraphT graph.
Returns:
the JGraph edge cell that corresponds to the specified JGraphT edge, or null if no corresponding cell found.

getVertexCell

public org.jgraph.graph.DefaultGraphCell getVertexCell(java.lang.Object jGraphTVertex)
Returns the JGraph vertex cell that corresponds to the specified JGraphT vertex. If no corresponding cell found, returns null.

Parameters:
jGraphTVertex - a JGraphT vertex of the JGraphT graph.
Returns:
the JGraph vertex cell that corresponds to the specified JGraphT vertex, or null if no corresponding cell found.

getVertexPort

public org.jgraph.graph.DefaultPort getVertexPort(java.lang.Object jGraphTVertex)
Returns the JGraph port cell that corresponds to the specified JGraphT vertex. If no corresponding port found, returns null.

Parameters:
jGraphTVertex - a JGraphT vertex of the JGraphT graph.
Returns:
the JGraph port cell that corresponds to the specified JGraphT vertex, or null if no corresponding cell found.

createDefaultEdgeAttributes

public static org.jgraph.graph.AttributeMap createDefaultEdgeAttributes(org._3pq.jgrapht.Graph jGraphTGraph)
Creates and returns a map of attributes to be used as defaults for edge attributes, depending on the specified graph.

Parameters:
jGraphTGraph - the graph for which default edge attributes to be created.
Returns:
a map of attributes to be used as default for edge attributes.

createDefaultVertexAttributes

public static org.jgraph.graph.AttributeMap createDefaultVertexAttributes()
Creates and returns a map of attributes to be used as defaults for vertex attributes.

Returns:
a map of attributes to be used as defaults for vertex attributes.

edit

public void edit(java.util.Map attrs)
Applies the specified attributes to the model, as in GraphModel.edit(java.util.Map, org.jgraph.graph.ConnectionSet, org.jgraph.graph.ParentMap, javax.swing.undo.UndoableEdit[]) method.

Parameters:
attrs - the attributes to be applied to the model.

addJGraphEdge

protected boolean addJGraphEdge(org.jgraph.graph.Edge jEdge)
Adds an edge corresponding to the specified JGraph edge to the underlying JGraphT graph. We try to find out to which vertices the edge is connected; if we find only one or none at all, we remove it again from the JGraph graph, because we cannot add such an edge to the JGraphT graph.

This method is to be called only for edges that have already been added to the JGraph graph.

Parameters:
jEdge - the JGraph Edge to be added.
Returns:
true if the edge was successfully added, false otherwise.

addJGraphTEdge

protected void addJGraphTEdge(org._3pq.jgrapht.Edge jtEdge)
Adds the specified JGraphT edge to be reflected by this graph model. To be called only for edges that already exist in the JGraphT graph.

Parameters:
jtEdge - a JGraphT edge to be reflected by this graph model.

addJGraphTVertex

protected void addJGraphTVertex(java.lang.Object jtVertex)
Adds the specified JGraphT vertex to be reflected by this graph model. To be called only for edges that already exist in the JGraphT graph.

Parameters:
jtVertex - a JGraphT vertex to be reflected by this graph model.

addJGraphVertex

protected boolean addJGraphVertex(org.jgraph.graph.GraphCell jVertex)
Add a vertex corresponding to this JGraph vertex to the JGraphT graph. In JGraph, two vertices with the same user object are in principle allowed; in JGraphT, this would lead to duplicate vertices, which is not allowed. So if the vertex exists already, we remove it. This method is to be called only for vertices that have already been added to the JGraph graph.

Parameters:
jVertex - the JGraph vertex to be added.
Returns:
true if the vertex was successfully added, false otherwise.

removeJGraphEdge

protected boolean removeJGraphEdge(org.jgraph.graph.Edge jEdge)
Remove the edge corresponding to this JGraph edge from the JGraphT graph. To be called only for edges that have already been removed from the JGraph graph.

Parameters:
jEdge - the JGraph Edge to be removed. If it is not in m_cellsToEdges, it is silently ignored.
Returns:
true if the edge could successfully be removed, false otherwise.

removeJGraphTEdge

protected void removeJGraphTEdge(org._3pq.jgrapht.Edge jtEdge)
Removes the specified JGraphT edge from being reflected by this graph model. To be called only for edges that have already been removed from the JGraphT graph.

Parameters:
jtEdge - a JGraphT edge to be removed from being reflected by this graph model.

removeJGraphTVertex

protected void removeJGraphTVertex(java.lang.Object jtVertex)
Removes the specified JGraphT vertex from being reflected by this graph model. To be called only for vertices that have already been removed from the JGraphT graph.

Parameters:
jtVertex - a JGraphT vertex to be removed from being reflected by this graph model.

removeJGraphVertex

protected boolean removeJGraphVertex(org.jgraph.graph.GraphCell jVertex)
Remove the vertex corresponding to this JGraph vertex from the JGraphT graph. If any edges are incident with this vertex, we remove them from both graphs first, because otherwise the JGraph graph would leave them intact and the JGraphT graph would throw them out. This method is to be called only for vertices that have already been removed from the JGraph graph.

Parameters:
jVertex - the JGraph vertex to be removed. If it is not in m_cellsToVertices, it is silently ignored.
Returns:
true if the vertex could successfully be removed, false otherwise.

getM_jtGraph

public org._3pq.jgrapht.Graph getM_jtGraph()
Returns:
Returns the m_jtGraph.

isStoreInteraction

public boolean isStoreInteraction()
Returns:
the storeInteraction

setStoreInteraction

public void setStoreInteraction(boolean storeInteraction)
Parameters:
storeInteraction - the storeInteraction to set