|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.undo.UndoableEditSupport
org.jgraph.graph.DefaultGraphModel
org._3pq.jgrapht.ext.JGraphModelAdapter
An adapter that reflects a JGraphT graph as a JGraph graph. This adapter is useful when using JGraph in order to visualize JGraphT graphs. For more about JGraph see http://jgraph.sourceforge.net
Modifications made to the underlying JGraphT graph are reflected to this
JGraph model if and only if the underlying JGraphT graph is a ListenableGraph
. If the underlying JGraphT graph is
not ListenableGraph, then this JGraph model represent a snapshot if
the graph at the time of its creation.
Changes made to this JGraph model are also reflected back to the underlying JGraphT graph. To avoid confusion, variables are prefixed according to the JGraph/JGraphT object(s) they are refering to.
KNOWN BUGS: There is a small issue to be aware of. JGraph allows 'dangling edges' incident with just one vertex; JGraphT doesn't. Such a configuration can arise when adding an edge or removing a vertex. The code handles this by removing the newly-added dangling edge or removing all edges incident with the vertex before actually removing the vertex, respectively. This works very well, only it doesn't play all that nicely with the undo-manager in the JGraph: for the second situation where you remove a vertex incident with some edges, if you undo the removal, the vertex is 'unremoved' but the edges aren't.
Nested Class Summary | |
static interface |
JGraphModelAdapter.CellFactory
Creates the JGraph cells that reflect the respective JGraphT elements. |
class |
JGraphModelAdapter.DefaultCellFactory
A simple default cell factory. |
Nested classes inherited from class org.jgraph.graph.DefaultGraphModel |
org.jgraph.graph.DefaultGraphModel.EmptyIterator, org.jgraph.graph.DefaultGraphModel.GraphModelEdit, org.jgraph.graph.DefaultGraphModel.GraphModelLayerEdit |
Field Summary |
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 | |
JGraphModelAdapter(Graph jGraphTGraph)
Constructs a new JGraph model adapter for the specified JGraphT graph. |
|
JGraphModelAdapter(Graph jGraphTGraph,
org.jgraph.graph.AttributeMap defaultVertexAttributes,
org.jgraph.graph.AttributeMap defaultEdgeAttributes,
JGraphModelAdapter.CellFactory cellFactory)
Constructs a new JGraph model adapter for the specified JGraphT graph. |
|
JGraphModelAdapter(Graph jGraphTGraph,
java.util.Map defaultVertexAttributes,
java.util.Map defaultEdgeAttributes)
Constructs a new JGraph model adapter for the specified JGraphT graph. |
|
JGraphModelAdapter(Graph jGraphTGraph,
java.util.Map defaultVertexAttributes,
java.util.Map defaultEdgeAttributes,
JGraphModelAdapter.CellFactory cellFactory)
Deprecated. will be deleted, use #JGraphModelAdapter(Graph,
AttributeMap, AttributeMap, CellFactory) instead. |
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(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(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(Edge jGraphTEdge)
Returns the JGraph edge cell that corresponds to the specified JGraphT edge. |
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. |
protected boolean |
removeJGraphEdge(org.jgraph.graph.Edge jEdge)
Remove the edge corresponding to this JGraph edge from the JGraphT graph. |
protected void |
removeJGraphTEdge(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. |
Methods inherited from class org.jgraph.graph.DefaultGraphModel |
acceptsSource, acceptsTarget, addGraphModelListener, cloneCells, connect, contains, createAttributes, createCellEdit, createEdit, createInsertEdit, createLayerEdit, createRemoveEdit, edges, edit, fireGraphChanged, getAttributes, getAttributes, getChild, getChildCount, getDescendantList, getDescendants, getEdges, getGraphModelListeners, getIndexOfChild, getIndexOfRoot, getParent, getRootAt, getRootCount, getRoots, getSource, getSourceVertex, getTarget, getTargetVertex, handleAttributes, handleConnection, handleConnectionSet, handleInsert, handleParentMap, handleRemove, insert, isEdge, isLeaf, isPort, remove, removeGraphModelListener, toBack, toFront |
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 |
Constructor Detail |
public JGraphModelAdapter(Graph jGraphTGraph)
jGraphTGraph
- the JGraphT graph for which JGraph model adapter to
be created.public JGraphModelAdapter(Graph jGraphTGraph, java.util.Map defaultVertexAttributes, java.util.Map defaultEdgeAttributes)
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.public JGraphModelAdapter(Graph jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap defaultEdgeAttributes, JGraphModelAdapter.CellFactory cellFactory)
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 JGraphModelAdapter.CellFactory
to be used to create the JGraph
cells, or null
to use internal default factory.public JGraphModelAdapter(Graph jGraphTGraph, java.util.Map defaultVertexAttributes, java.util.Map defaultEdgeAttributes, JGraphModelAdapter.CellFactory cellFactory)
#JGraphModelAdapter(Graph,
AttributeMap, AttributeMap, CellFactory)
instead.
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 JGraphModelAdapter.CellFactory
to be used to create the JGraph
cells, or null
to use internal default factory.Method Detail |
public org.jgraph.graph.DefaultEdge getEdgeCell(Edge jGraphTEdge)
null
.
jGraphTEdge
- a JGraphT edge of the JGraphT graph.
null
if no corresponding cell found.public org.jgraph.graph.DefaultGraphCell getVertexCell(java.lang.Object jGraphTVertex)
null
.
jGraphTVertex
- a JGraphT vertex of the JGraphT graph.
null
if no corresponding cell found.public org.jgraph.graph.DefaultPort getVertexPort(java.lang.Object jGraphTVertex)
null
.
jGraphTVertex
- a JGraphT vertex of the JGraphT graph.
null
if no corresponding cell found.public static org.jgraph.graph.AttributeMap createDefaultEdgeAttributes(Graph jGraphTGraph)
jGraphTGraph
- the graph for which default edge attributes to be
created.
public static org.jgraph.graph.AttributeMap createDefaultVertexAttributes()
public void edit(java.util.Map attrs)
GraphModel.edit(java.util.Map,
org.jgraph.graph.ConnectionSet, org.jgraph.graph.ParentMap,
javax.swing.undo.UndoableEdit[])
method.
attrs
- the attributes to be applied to the model.protected boolean addJGraphEdge(org.jgraph.graph.Edge jEdge)
This method is to be called only for edges that have already been added to the JGraph graph.
jEdge
- the JGraph Edge to be added.
protected void addJGraphTEdge(Edge jtEdge)
jtEdge
- a JGraphT edge to be reflected by this graph model.protected void addJGraphTVertex(java.lang.Object jtVertex)
jtVertex
- a JGraphT vertex to be reflected by this graph model.protected boolean addJGraphVertex(org.jgraph.graph.GraphCell jVertex)
jVertex
- the JGraph vertex to be added.
protected boolean removeJGraphEdge(org.jgraph.graph.Edge jEdge)
jEdge
- the JGraph Edge to be removed. If it is not in
m_cellsToEdges, it is silently ignored.
protected void removeJGraphTEdge(Edge jtEdge)
jtEdge
- a JGraphT edge to be removed from being reflected by this
graph model.protected void removeJGraphTVertex(java.lang.Object jtVertex)
jtVertex
- a JGraphT vertex to be removed from being reflected by
this graph model.protected boolean removeJGraphVertex(org.jgraph.graph.GraphCell jVertex)
jVertex
- the JGraph vertex to be removed. If it is not in
m_cellsToVertices, it is silently ignored.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |