com.jgraph.layout
Class JGraphExampleLayoutCache

java.lang.Object
  extended by org.jgraph.graph.GraphLayoutCache
      extended by com.jgraph.layout.JGraphExampleLayoutCache
All Implemented Interfaces:
java.io.Serializable, org.jgraph.graph.CellMapper

public class JGraphExampleLayoutCache
extends org.jgraph.graph.GraphLayoutCache

A class that encapsulates autolayout functionality for manual changes. This layout cache overrides the edit method to add layout results for the given change which are then passed to the superclass' edit method. This way a manual change and layout result is merged into one call on the model, thus resulting in correct undo and redo in the command history.
To morph into the new geometry this cache needs a reference to the hosting graph, which it calls to perform the animation. After morphing, which is asynchronous in order to not block the UI dispatcher thread, the graph invokes edit on the cache again. The autolayout-switch is used avoid infinite recursion for this second call.

See Also:
Serialized Form

Nested Class Summary
 class JGraphExampleLayoutCache.JGraphMoveSelectionFacade
          An example of how to override the graph facade to control the cells that are moveable by graph layouts.
 
Nested classes/interfaces inherited from class org.jgraph.graph.GraphLayoutCache
org.jgraph.graph.GraphLayoutCache.GraphLayoutCacheEdit
 
Constructor Summary
JGraphExampleLayoutCache()
           
JGraphExampleLayoutCache(org.jgraph.graph.GraphModel model, org.jgraph.graph.CellViewFactory factory, org.jgraph.graph.CellView[] cellViews, org.jgraph.graph.CellView[] hiddenCellViews, boolean partial)
          Required for XML persistence
JGraphExampleLayoutCache(JGraphExampleGraph graph)
          Constructs a new example layout cache for the specified example graph.
 
Method Summary
 void configureLayout()
          Displays the properties of the current layoutin dialog.
 void edit(java.util.Map attributes, org.jgraph.graph.ConnectionSet cs, org.jgraph.graph.ParentMap pm, javax.swing.undo.UndoableEdit[] e)
          Overrides the superclass' method to invoke autolayout.
 java.awt.geom.Rectangle2D getBounds(java.lang.Object cell, java.util.Map nested)
           
 boolean getPartial()
          Required for XML persistence
 void layout(java.util.Map nestedMap)
          Layouts the graph using the current layout.
 void setGraph(JGraphExampleGraph graph)
          Setting the graph after loading from file.
 
Methods inherited from class org.jgraph.graph.GraphLayoutCache
addGraphLayoutCacheListener, cellViewsChanged, collapse, createNestedMap, edit, edit, editCell, expand, getAllDescendants, getAllViews, getBounds, getCells, getCells, getCellViews, getCollapseXScale, getCollapseYScale, getFactory, getGraphLayoutCacheListeners, getHiddenCellViews, getHiddenMapping, getIncomingEdges, getLocalAttributes, getMapping, getMapping, getMapping, getModel, getNeighbours, getOutgoingEdges, getPorts, getRoots, getRoots, getVisibleCells, getVisibleSet, graphChanged, hideCells, insert, insert, insert, insert, insertClones, insertEdge, insertGroup, insertViews, isAllAttributesLocal, isAutoSizeOnValueChange, isHidesDanglingConnections, isHidesExistingConnections, isMovesChildrenOnExpand, isMovesParentsOnCollapse, isPartial, isReconnectsEdgesToVisibleParent, isRemembersCellViews, isResizesParentsOnCollapse, isSelectsAllInsertedCells, isSelectsLocalInsertedCells, isShowsChangedConnections, isShowsExistingConnections, isShowsInsertedConnections, isShowsInvisibleEditedCells, isVisible, putMapping, refresh, refresh, reload, remove, remove, removeCells, removeGraphLayoutCacheListener, removeMapping, removeViewLocalAttribute, setAllAttributesLocal, setAutoSizeOnValueChange, setCollapsedState, setCollapseXScale, setCollapseYScale, setFactory, setHiddenSet, setHidesDanglingConnections, setHidesExistingConnections, setLocalAttributes, setModel, setMovesChildrenOnExpand, setMovesParentsOnCollapse, setReconnectsEdgesToVisibleParent, setRemembersCellViews, setResizesParentsOnCollapse, setSelectsAllInsertedCells, setSelectsLocalInsertedCells, setShowsChangedConnections, setShowsExistingConnections, setShowsInsertedConnections, setShowsInvisibleEditedCells, setVisible, setVisible, setVisible, setVisible, setVisible, setVisibleImpl, setVisibleSet, showCells, toBack, toFront, toggleCollapsedState, translateViews, ungroup, update, update, update, valueForCellChanged
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGraphExampleLayoutCache

public JGraphExampleLayoutCache()

JGraphExampleLayoutCache

public JGraphExampleLayoutCache(JGraphExampleGraph graph)
Constructs a new example layout cache for the specified example graph. In contrast to the default implementation, where these two are not related, here, they are closely coupled as one is used to be notified of changes BEFORE they are applied to the model (override edit method), whereas the other is used to animate these changes (requires JComponent).

Parameters:
graph - the graph this layout cache is to associated with

JGraphExampleLayoutCache

public JGraphExampleLayoutCache(org.jgraph.graph.GraphModel model,
                                org.jgraph.graph.CellViewFactory factory,
                                org.jgraph.graph.CellView[] cellViews,
                                org.jgraph.graph.CellView[] hiddenCellViews,
                                boolean partial)
Required for XML persistence

Parameters:
model - the model that constitues the data source
Method Detail

setGraph

public void setGraph(JGraphExampleGraph graph)
Setting the graph after loading from file.


edit

public void edit(java.util.Map attributes,
                 org.jgraph.graph.ConnectionSet cs,
                 org.jgraph.graph.ParentMap pm,
                 javax.swing.undo.UndoableEdit[] e)
Overrides the superclass' method to invoke autolayout.

Overrides:
edit in class org.jgraph.graph.GraphLayoutCache

layout

public void layout(java.util.Map nestedMap)
Layouts the graph using the current layout. The specified map constitutes a previous (manual) change that should be reflected by the facade. The result of the layout is subsequently merged with the map and passed to the morpher only if the layout provided additional cell locations.

This may run asynchronously, eg. the method may return when the layout is still running. The graph will remain disabled until the layout terminates or it stopped by the user, but the user interface will not be blocked while the layout is running. Instead, a progress dialog will inform the user of the current progress.

Parameters:
nestedMap - the nested map constituting a manual change

getBounds

public java.awt.geom.Rectangle2D getBounds(java.lang.Object cell,
                                           java.util.Map nested)

getPartial

public boolean getPartial()
Required for XML persistence

Overrides:
getPartial in class org.jgraph.graph.GraphLayoutCache
Returns:
whether or not the cache is partial

configureLayout

public void configureLayout()
Displays the properties of the current layoutin dialog.