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

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.folding.FoldingSupport

public class FoldingSupport
extends java.lang.Object

This class provides static utility methods for working with folded graph structures. Class FoldedLayoutGraph provides this functionality in a more convenient way.


Method Summary
static EdgeViewState getEdgeViewState(Graph graph, DummyEdgeId dummyEdgeId)
          Returns the view state of a dummy edge identified by the provided dummy edge id.
static Node getLocalRoot(Graph graph)
          Returns the node that is currently considered the virtual root node of the folded graph.
static NodeViewState getNodeViewState(Graph graph, DummyNodeId dummyNodeId)
          Returns the view state of a collapsed group node.
protected static java.lang.Object getPortOwner(com.yworks.yfiles.server.graphml.folding.DummyEdgePortId dummyEdgePortId)
           
static PortViewState getPortViewState(Graph graph, DummyNodePortId dummyNodePortId)
          Returns the view state of a node port defined by the provided dummy node port id.
static boolean isExpanded(Graph graph, Node node)
          Returns whether the provided node is currently in expanded state.
static void setEdgeViewState(Graph graph, DummyEdgeId dummyEdgeId, EdgeViewState edgeViewState)
          Sets a view state of a dummy edge identified by the provided dummy edge id.
static void setExpanded(Graph graph, Node node, boolean expanded)
          Set the expanded state of the provided node.
static void setLocalRoot(Graph graph, Node node)
          Set the virtual root node of the folded graph view defined by the provided graph to the provided non-leaf node.
static void setNodeViewState(Graph graph, DummyNodeId dummyNodeId, NodeViewState nodeViewState)
          Sets the view state of a collapsed group node.
static void setPortViewState(Graph graph, DummyNodePortId dummyNodePortId, PortViewState portViewState)
          Sets a view state of a node port identified by the provided dummy node port id.
static void validateFoldingState(Graph graph)
          Make sure that there are NodeViewState, EdgeViewState and PortViewState instances available for all dummy nodes, dummy edges and dummy node ports induced by the collapsed/expanded states of the graph's nodes.
static void validateFoldingState(Graph graph, ViewStateCreator viewStateCreator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNodeViewState

public static NodeViewState getNodeViewState(Graph graph,
                                             DummyNodeId dummyNodeId)
Returns the view state of a collapsed group node.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.NODE_VIEW_STATES_DPKEY.
dummyNodeId - A dummy node id that identifies the collapsed state of a group node.
Returns:
The node view state, or null, if no dummy node state is available for the provided node id.
See Also:
FoldedGraphKeys.NODE_VIEW_STATES_DPKEY

setNodeViewState

public static void setNodeViewState(Graph graph,
                                    DummyNodeId dummyNodeId,
                                    NodeViewState nodeViewState)
Sets the view state of a collapsed group node.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.NODE_VIEW_STATES_DPKEY.
dummyNodeId - A dummy node id that identifies the collapsed state of a group node.
nodeViewState - The node view state that describes the appearance of the collapsed group node.

getEdgeViewState

public static EdgeViewState getEdgeViewState(Graph graph,
                                             DummyEdgeId dummyEdgeId)
Returns the view state of a dummy edge identified by the provided dummy edge id.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.EDGE_VIEW_STATES_DPKEY.
dummyEdgeId - A dummy edge id that identifies a dummy state of a master edge in a folded graph.
Returns:
The edge view state, or null, if no dummy edge state is available for the provided edge id.
See Also:
FoldedGraphKeys.EDGE_VIEW_STATES_DPKEY

setEdgeViewState

public static void setEdgeViewState(Graph graph,
                                    DummyEdgeId dummyEdgeId,
                                    EdgeViewState edgeViewState)
Sets a view state of a dummy edge identified by the provided dummy edge id.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.EDGE_VIEW_STATES_DPKEY.
dummyEdgeId - A dummy edge id that identifies a dummy state of a master edge in a folded graph.
edgeViewState - The edge view state that describes the visual appearance of the dummy edge.

getPortViewState

public static PortViewState getPortViewState(Graph graph,
                                             DummyNodePortId dummyNodePortId)
Returns the view state of a node port defined by the provided dummy node port id.

If no view state has been defined for the provided dummy node port id yet, null is returned.


setPortViewState

public static void setPortViewState(Graph graph,
                                    DummyNodePortId dummyNodePortId,
                                    PortViewState portViewState)
Sets a view state of a node port identified by the provided dummy node port id.

A node view state for the port owner has to be set before to be able to set the port view state.

Parameters:
dummyNodePortId - A dummy node port id that identifies a dummy state of a node port in a folded graph.
portViewState - The port view state that describes the visual appearance of the dummy node port.

isExpanded

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

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.NODE_VIEW_STATES_DPKEY.

setExpanded

public static void setExpanded(Graph graph,
                               Node node,
                               boolean expanded)
Set the expanded state of the provided node.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.NODE_VIEW_STATES_DPKEY.
expanded - If false, the node will be considered collapsed, i.e. the node's descendants will not be visible in the folded graph view defined by the provided graph instance.

setLocalRoot

public static void setLocalRoot(Graph graph,
                                Node node)
Set the virtual root node of the folded graph view defined by the provided graph to the provided non-leaf node.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.LOCAL_ROOT_DPKEY.
node - A non-leaf node that will be considered the virtual root node.

getLocalRoot

public static Node getLocalRoot(Graph graph)
Returns the node that is currently considered the virtual root node of the folded graph.

Parameters:
graph - A folded graph that has a data provider registered for the FoldedGraphKeys.LOCAL_ROOT_DPKEY.
Returns:
The node that is considered the graph's virtual root node or null, if no local root has been set.

validateFoldingState

public static void validateFoldingState(Graph graph)
Make sure that there are NodeViewState, EdgeViewState and PortViewState instances available for all dummy nodes, dummy edges and dummy node ports induced by the collapsed/expanded states of the graph's nodes.

If a NodeViewState, EdgeViewState or PortViewState instance is missing and the graph instance implements the ViewStateCreator interface, the factory methods of this interface are used to create the missing instances. Otherwise, default instances will be created.

See Also:
ViewStateCreator

validateFoldingState

public static void validateFoldingState(Graph graph,
                                        ViewStateCreator viewStateCreator)

getPortOwner

protected static java.lang.Object getPortOwner(com.yworks.yfiles.server.graphml.folding.DummyEdgePortId dummyEdgePortId)


Copyright © 2000-2013 yWorks GmbH. All rights reserved