Class JGraphModelAdapter<V,E>
- All Implemented Interfaces:
Serializable,org.jgraph.graph.GraphModel
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 referring 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.
- Since:
- Aug 2, 2003
- Author:
- Barak Naveh
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates the JGraph cells that reflect the respective JGraphT elements.static classA simple default cell factory.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
Fields inherited from class org.jgraph.graph.DefaultGraphModel
asksAllowsChildren, attributes, emptyIterator, listenerList, removeEmptyGroups, roots, transAddedCells, transEditAttrs, transEditCS, transEditPM, transRemovedCells, updateLevelFields inherited from class javax.swing.undo.UndoableEditSupport
compoundEdit, listeners, realSource -
Constructor Summary
ConstructorsConstructorDescriptionJGraphModelAdapter(Graph<V, E> jGraphTGraph) Constructs a new JGraph model adapter for the specified JGraphT graph.JGraphModelAdapter(Graph<V, E> jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap defaultEdgeAttributes) Constructs a new JGraph model adapter for the specified JGraphT graph.JGraphModelAdapter(Graph<V, E> jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap defaultEdgeAttributes, JGraphModelAdapter.CellFactory<V, E> cellFactory) Constructs a new JGraph model adapter for the specified JGraphT graph. -
Method Summary
Modifier and TypeMethodDescriptionstatic <V,E> org.jgraph.graph.AttributeMap createDefaultEdgeAttributes(Graph<V, E> 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.AttributeMapCreates and returns a map of attributes to be used as defaults for vertex attributes.Returns the cell factory used to create the JGraph cells.org.jgraph.graph.AttributeMapReturns the default edge attributes used for creating new JGraph edges.org.jgraph.graph.AttributeMapReturns the default vertex attributes used for creating new JGraph vertices.org.jgraph.graph.DefaultEdgegetEdgeCell(E jGraphTEdge) Returns the JGraph edge cell that corresponds to the specified JGraphT edge.org.jgraph.graph.DefaultGraphCellgetVertexCell(Object jGraphTVertex) Returns the JGraph vertex cell that corresponds to the specified JGraphT vertex.org.jgraph.graph.DefaultPortgetVertexPort(Object jGraphTVertex) Returns the JGraph port cell that corresponds to the specified JGraphT vertex.voidsetDefaultEdgeAttributes(org.jgraph.graph.AttributeMap defaultEdgeAttributes) Sets the default edge attributes used for creating new JGraph edges.voidsetDefaultVertexAttributes(org.jgraph.graph.AttributeMap defaultVertexAttributes) Sets the default vertex attributes used for creating new JGraph vertices.Methods inherited from class org.jgraph.graph.DefaultGraphModel
acceptsSource, acceptsTarget, addGraphModelListener, beginUpdate, cellsChanged, cloneCell, cloneCell, cloneCell, cloneCells, cloneUserObject, connect, contains, containsEdgeBetween, createEdit, createLayerEdit, createRemoveEdit, edges, edit, edit, endUpdate, execute, fireGraphChanged, getAll, getAttributes, getAttributes, getChild, getChildCount, getConnectionSet, getDescendants, getEdges, getEdges, getEdgesBetween, getGraphModelListeners, getIncomingEdges, getIndexOfChild, getIndexOfRoot, getOpposite, getOutgoingEdges, getParent, getRootAt, getRootCount, getRoots, getRoots, getRoots, getRootsAsCollection, getSource, getSourceVertex, getTarget, getTargetVertex, getTopmostCells, getUpdateLevel, getUserObject, getValue, handleAttributes, handleConnection, handleConnectionSet, handleInsert, handleParentMap, handleRemove, hasAncestorIn, insert, isEdge, isGroup, isLeaf, isPort, isRemoveEmptyGroups, isVertex, order, remove, removeGraphModelListener, setParent, setRemoveEmptyGroups, setSourcePort, setTargetPort, toBack, toFront, updateTransaction, valueForCellChangedMethods inherited from class javax.swing.undo.UndoableEditSupport
_postEdit, addUndoableEditListener, createCompoundEdit, getUndoableEditListeners, postEdit, removeUndoableEditListener, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jgraph.graph.GraphModel
addUndoableEditListener, removeUndoableEditListener
-
Constructor Details
-
JGraphModelAdapter
Constructs a new JGraph model adapter for the specified JGraphT graph.- Parameters:
jGraphTGraph- the JGraphT graph for which JGraph model adapter to be created.nullis NOT permitted.
-
JGraphModelAdapter
public JGraphModelAdapter(Graph<V, E> jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap 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.nullis NOT permitted.defaultVertexAttributes- a default map of JGraph attributes to format vertices.nullis NOT permitted.defaultEdgeAttributes- a default map of JGraph attributes to format edges.nullis NOT permitted.
-
JGraphModelAdapter
public JGraphModelAdapter(Graph<V, E> jGraphTGraph, org.jgraph.graph.AttributeMap defaultVertexAttributes, org.jgraph.graph.AttributeMap defaultEdgeAttributes, JGraphModelAdapter.CellFactory<V, E> 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.nullis NOT permitted.defaultVertexAttributes- a default map of JGraph attributes to format vertices.nullis NOT permitted.defaultEdgeAttributes- a default map of JGraph attributes to format edges.nullis NOT permitted.cellFactory- aJGraphModelAdapter.CellFactoryto be used to create the JGraph cells.nullis NOT permitted.- Throws:
IllegalArgumentException
-
-
Method Details
-
createDefaultEdgeAttributes
public static <V,E> org.jgraph.graph.AttributeMap createDefaultEdgeAttributes(Graph<V, E> 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.
-
getCellFactory
Returns the cell factory used to create the JGraph cells.- Returns:
- the cell factory used to create the JGraph cells.
-
setDefaultEdgeAttributes
public void setDefaultEdgeAttributes(org.jgraph.graph.AttributeMap defaultEdgeAttributes) Sets the default edge attributes used for creating new JGraph edges.- Parameters:
defaultEdgeAttributes- the default edge attributes to set.
-
getDefaultEdgeAttributes
public org.jgraph.graph.AttributeMap getDefaultEdgeAttributes()Returns the default edge attributes used for creating new JGraph edges.- Returns:
- the default edge attributes used for creating new JGraph edges.
-
setDefaultVertexAttributes
public void setDefaultVertexAttributes(org.jgraph.graph.AttributeMap defaultVertexAttributes) Sets the default vertex attributes used for creating new JGraph vertices.- Parameters:
defaultVertexAttributes- the default vertex attributes to set.
-
getDefaultVertexAttributes
public org.jgraph.graph.AttributeMap getDefaultVertexAttributes()Returns the default vertex attributes used for creating new JGraph vertices.- Returns:
- the default vertex attributes used for creating new JGraph vertices.
-
getEdgeCell
Returns the JGraph edge cell that corresponds to the specified JGraphT edge. If no corresponding cell found, returnsnull.- Parameters:
jGraphTEdge- a JGraphT edge of the JGraphT graph.- Returns:
- the JGraph edge cell that corresponds to the specified JGraphT
edge, or
nullif no corresponding cell found.
-
getVertexCell
Returns the JGraph vertex cell that corresponds to the specified JGraphT vertex. If no corresponding cell found, returnsnull.- Parameters:
jGraphTVertex- a JGraphT vertex of the JGraphT graph.- Returns:
- the JGraph vertex cell that corresponds to the specified JGraphT
vertex, or
nullif no corresponding cell found.
-
getVertexPort
Returns the JGraph port cell that corresponds to the specified JGraphT vertex. If no corresponding port found, returnsnull.- Parameters:
jGraphTVertex- a JGraphT vertex of the JGraphT graph.- Returns:
- the JGraph port cell that corresponds to the specified JGraphT
vertex, or
nullif no corresponding cell found.
-