com.yworks.yfiles.server.graphml.folding
Class FoldedLayoutGraph

java.lang.Object
  extended byy.base.Graph
      extended byy.layout.LayoutGraph
          extended byy.layout.DefaultLayoutGraph
              extended bycom.yworks.yfiles.server.graphml.flexio.data.StyledLayoutGraph
                  extended bycom.yworks.yfiles.server.graphml.folding.FoldedLayoutGraph
All Implemented Interfaces:
GraphInterface, GraphLayout, ViewStateCreator

public class FoldedLayoutGraph
extends StyledLayoutGraph
implements ViewStateCreator

A LayoutGraph that supports folding operations.

This graph implementation supports folding through the collapse(Node) operation and provides access to dummy states for nodes and edges.

Distinct layouts and styles can be assigned to dummy states. Access to the dummy states is provided through getEdgeViewState(DummyEdgeId) and getNodeViewState(DummyNodeId).

The folded graph also supports the notion of a local root, which is relevant for layout calculations.


Field Summary
 
Fields inherited from class y.layout.DefaultLayoutGraph
edgeLabelFeatureMap, edgeLabelMap, nodeLabelFeatureMap, nodeLabelMap
 
Fields inherited from class y.layout.LayoutGraph
z
 
Fields inherited from class y.base.Graph
AFTER, BEFORE
 
Constructor Summary
FoldedLayoutGraph()
          Creates a new instance of a folded layout graph.
 
Method Summary
 void collapse(Node node)
          Collapse a group node, hiding its children from the current view.
 EdgeViewState createEdgeViewState(DummyEdgeId edgeId)
          Creates an edge view state instance for the provided edge id.
protected  DataMap createEdgeViewStateMap()
          Create the DataMap that stores the EdgeViewState instances for dummy edges.
protected  DataMap createExpansionStateMap()
          Create the DataMap that stores the node expansion state.
 Node createNode()
          Creates a new node, applying the default node size.
 NodeViewState createNodeViewState(DummyNodeId nodeId)
          Creates a node view state instance for the provided node id.
protected  DataMap createNodeViewStateMap()
          Create the DataMap that stores the NodeViewState instances for the collapsed state of group nodes.
 void doLayout(Layouter layouter)
          Calculates a layout for the folded graph view defined by this instance.
 void doLayout(Layouter layouter, Node root, boolean recursive, byte dummyEdgeMode)
          Calculates a layout for the folded graph view defined by this instance.
 void expand(Node node)
          Expands a collapsed group node, revealing its children in the folded graph view defined by this graph.
 EdgeViewState getEdgeViewState(DummyEdgeId edgeId)
          Returns the view state of a dummy edge defined by the provided dummy edge id.
 Node getLocalRoot()
          A non-leaf node that is considered the virtual root node of this graph.
 NodeViewState getNodeViewState(DummyNodeId nodeId)
          Returns the view state of a collapsed group node.
 boolean isExpanded(Node node)
          Returns whether the provided node is currently in expanded state.
 void setEdgeViewState(DummyEdgeId edgeId, EdgeViewState viewState)
          Sets a view state of a dummy edge identified by the provided dummy edge id.
 void setLocalRoot(Node node)
          A non-leaf node that is considered the virtual root node of this graph.
 void setNodeViewState(DummyNodeId dummyNodeId, NodeViewState viewState)
          Sets the view state of a collapsed group node.
 
Methods inherited from class com.yworks.yfiles.server.graphml.flexio.data.StyledLayoutGraph
addLabel, addLabel, getDefaultNodeSize, getLabels, getLabels, getNodeHierarchy, getStyle, getStyle, getUserTag, setDefaultNodeSize, setStyle, setStyle, setUserTag, syncLabels, syncLabels
 
Methods inherited from class y.layout.DefaultLayoutGraph
createEdgeLayout, createGraphCopyFactory, createNodeLayout, getFeature, getFeature, getLabelLayout, getLabelLayout, getLayout, getLayout, setLabelLayout, setLabelLayout, setLabelLayout, setLayout, setLayout
 
Methods inherited from class y.layout.LayoutGraph
getBoundingBox, getCenter, getCenterX, getCenterY, getEdgeLabelLayout, getEdgeLayout, getEdgeList, getHeight, getLocation, getNodeLabelLayout, getNodeLayout, getPath, getPathList, getPointList, getPoints, getRectangle, getSize, getSourcePointAbs, getSourcePointRel, getTargetPointAbs, getTargetPointRel, getWidth, getX, getY, moveBy, setCenter, setCenter, setEndPointsAbs, setLocation, setLocation, setPath, setPath, setPoints, setPoints, setSize, setSize, setSourcePointAbs, setSourcePointRel, setTargetPointAbs, setTargetPointRel
 
Methods inherited from class y.base.Graph
addDataProvider, addGraphListener, changeEdge, changeEdge, changeEdge, clear, contains, contains, containsEdge, createCopy, createEdge, createEdge, createEdgeMap, createGraph, createNodeMap, disposeEdgeMap, disposeNodeMap, E, edgeCount, edgeObjects, edges, fireGraphEvent, firePostEvent, firePostEvent, firePreEvent, firePreEvent, firstEdge, firstNode, firstOutEdge, getDataProvider, getDataProviderKeys, getEdgeArray, getGraphCopyFactory, getGraphListeners, getNodeArray, getRegisteredEdgeMaps, getRegisteredNodeMaps, getSource, getTarget, hasListeners, hide, hide, isEmpty, lastEdge, lastNode, moveSubGraph, moveToFirst, moveToFirst, moveToLast, moveToLast, N, nodeCount, nodeObjects, nodes, printNodeSlotSize, reInsertEdge, reInsertNode, removeDataProvider, removeEdge, removeGraphListener, removeNode, reverseEdge, setGraphCopyFactory, sortEdges, sortEdges, sortNodes, toString, unhide, unhide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FoldedLayoutGraph

public FoldedLayoutGraph()
Creates a new instance of a folded layout graph.

Creates and registers the data providers required for maintaining the expansion state, node- and edge view states and the local root.

{@inheritDoc}

Method Detail

setLocalRoot

public void setLocalRoot(Node node)
A non-leaf node that is considered the virtual root node of this graph.

The local root is considered when a layout is calculated for a folded graph.

Parameters:
node - A group node that will be set as the virtual root node of this graph.

getLocalRoot

public Node getLocalRoot()
A non-leaf node that is considered the virtual root node of this graph.

The local root is considered when a layout is calculated for a folded graph.


createExpansionStateMap

protected DataMap createExpansionStateMap()
Create the DataMap that stores the node expansion state.

The map will be registered as a data provider with this graph, using the FoldedGraphKeys.EXPANSION_STATE_DPKEY key.


createNodeViewStateMap

protected DataMap createNodeViewStateMap()
Create the DataMap that stores the NodeViewState instances for the collapsed state of group nodes.

The map will be registered as a data provider with this graph, using the FoldedGraphKeys.NODE_VIEW_STATES_DPKEY key.


createEdgeViewStateMap

protected DataMap createEdgeViewStateMap()
Create the DataMap that stores the EdgeViewState instances for dummy edges.

The map will be registered as a data provider with this graph, using the FoldedGraphKeys.EDGE_VIEW_STATES_DPKEY key.


getNodeViewState

public NodeViewState getNodeViewState(DummyNodeId nodeId)
Returns the view state of a collapsed group node.

If no view state has been defined for the provided dummy node id yet, a new instance will be created and associated with the id.


setNodeViewState

public void setNodeViewState(DummyNodeId dummyNodeId,
                             NodeViewState viewState)
Sets the view state of a collapsed group node.

Parameters:
dummyNodeId - A dummy node id that identifies the collapsed state of a group node.
viewState - The node view state that describes the appearance of the collapsed group node.

createNodeViewState

public NodeViewState createNodeViewState(DummyNodeId nodeId)
Creates a node view state instance for the provided node id.

This implementation will use the current style and layout of the master node for the dummy node state.

Specified by:
createNodeViewState in interface ViewStateCreator

getEdgeViewState

public EdgeViewState getEdgeViewState(DummyEdgeId edgeId)
Returns the view state of a dummy edge defined by the provided dummy edge id.

If no view state has been defined for the provided dummy edge id yet, a new instance will be created and associated with the id.


setEdgeViewState

public void setEdgeViewState(DummyEdgeId edgeId,
                             EdgeViewState viewState)
Sets a view state of a dummy edge identified by the provided dummy edge id.

Parameters:
edgeId - A dummy edge id that identifies a dummy state of a master edge in a folded graph.
viewState - The edge view state that describes the visual appearance of the dummy edge.

createEdgeViewState

public EdgeViewState createEdgeViewState(DummyEdgeId edgeId)
Creates an edge view state instance for the provided edge id.

This implementation will use the current style of the master edge for the dummy edge state. The source and target port of the edge view state are set to the center of the source and target nodes (i.e., Port instances with offsets (0,0) are used.

Specified by:
createEdgeViewState in interface ViewStateCreator

collapse

public void collapse(Node node)
Collapse a group node, hiding its children from the current view.

Parameters:
node - A group node that will be collapsed.

expand

public void expand(Node node)
Expands a collapsed group node, revealing its children in the folded graph view defined by this graph.

Parameters:
node - A collapsed group node. If the group node is already expanded, this method does nothing.

isExpanded

public boolean isExpanded(Node node)
Returns whether the provided node is currently in expanded state.

See Also:
collapse(Node), expand(Node)

createNode

public Node createNode()
Creates a new node, applying the default node size.


doLayout

public void doLayout(Layouter layouter)
Calculates a layout for the folded graph view defined by this instance.

A FoldingLayoutStage is used to apply the provided layout algorithm to the folded graph view.

Overrides:
doLayout in class StyledLayoutGraph
Parameters:
layouter - The layout algorithm the will be applied to the folded graph.
See Also:
doLayout(Layouter, Node, boolean, byte)

doLayout

public void doLayout(Layouter layouter,
                     Node root,
                     boolean recursive,
                     byte dummyEdgeMode)
Calculates a layout for the folded graph view defined by this instance.

A FoldingLayoutStage is used to apply the provided layout algorithm to the folded graph view.

Parameters:
layouter - The layout algorithm the will be applied to the folded graph.
root - The node that should be considered the virtual local root for the layout calculation. A different local root than local root that is currently set for this graph can be used here.
recursive - Whether to apply a recursive layout calculation to the inner graphs defined by collapsed group nodes.
dummyEdgeMode - The dummy edge mode that should be used for dummy edges created by the folding layout stage.
See Also:
doLayout(Layouter)


Copyright © 2000-2007 yWorks GmbH. All rights reserved