Packagecom.yworks.graph.model
Classpublic class FoldingManager
InheritanceFoldingManager Inheritance Object

This class adds folding support to IGraph implementations on top of the IGroupedGraph interface.

This implementation manages the varying states nodes and edges can have in different views and during different collapsed/expanded states of the nodes.

Create an instance of this class for a given IGraph and use the createManagedView() methods to create an IGraph implementation that provides a view of a subset of the graph, where group nodes can be collapsed and expanded.

View the examples

See also

com.yworks.graph.model.IFoldedGraph
createManagedView()


Public Properties
 PropertyDefined By
  autoAdjustMasterGroupNodeBounds : Boolean
Gets or sets a property that determines whether the manager should synchronize the autoAdjustGroupNodeBounds property of the masterGroupedGraph with the client views.
FoldingManager
  defaultExpandedPredicate : Function
Gets or sets the predicate function to use by default to determine the expanded state for the views that have been created with the default expanded predicate function.
FoldingManager
  dummyEdgeConverter : IDummyEdgeConverter
Gets or sets the IDummyEdgeConverter implementation that is used to create/convert and modify the DummyEdgeId inside the view instances.
FoldingManager
  dummyNodeConverter : IDummyNodeConverter
The IDummyNodeConverter implementation that is used to create/convert and modify the DummyNodeId inside the view instances.
FoldingManager
  masterGraph : IGraph
[read-only] Yields the master IGraph instance that holds the complete model in expanded group node state.
FoldingManager
  masterGroupedGraph : IGroupedGraph
[read-only] Yields the master IGroupedGraph instance that models the fully expanded grouped graph.
FoldingManager
  masterHierarchy : INodeHierarchy
[read-only] Yields the master INodeIHierarchy instance that contains all nodes in the model, regardless of their (view-local) collapsed state.
FoldingManager
  views : Iterable
[read-only] Yields all currently known views that are managed by this instance.
FoldingManager
Public Methods
 MethodDefined By
  
FoldingManager(masterGraph:IGraph = null)
Creates a manager instance for the given masterGraph to create views on top of it that support folding operations.
FoldingManager
  
createManagedView(root:INode = null, expandedPredicate:Function = null):IFoldedGraph
Creates a separate view instance of the masterGraph which is a synchronized copy of a subset of the items from the master graph.
FoldingManager
  
Determines whether for the given DummyEdgeId this manager has stored associated view local state.
FoldingManager
  
Returns a callback object that can be used to modify the appearance of a given dummy edge without using a IFoldedGraph view.
FoldingManager
  
Returns a callback object that can be used to modify the appearance of a given dummy node without using a IFoldedGraph view.
FoldingManager
  
Return a data container implementation that is not part of any actual IGraph that describes the state of the edge for the given DummyEdgeId.
FoldingManager
  
Provides access to the dummy state of a node for a specific view.
FoldingManager
  
Provides access to the dummy state of a port for a specific view.
FoldingManager
  
Determines whether for the given DummyNodeId this manager has stored associated view local state.
FoldingManager
  
Determines whether for the given DummyNodePortId this manager has stored associated view local state.
FoldingManager
  
setDummyBendTagCore(bendId:BendId, newTag:Object):void
FoldingManager
  
setDummyEdgeLabelTag(edgeLabelId:EdgeLabelId, newTag:Object, enqueueEdit:Boolean):void
FoldingManager
  
setDummyEdgeLabelTagCore(edgeLabelId:EdgeLabelId, newTag:Object):void
FoldingManager
  
setDummyEdgePortTag(portId:DummyEdgePortId, tag:Object, enqueueUnit:Boolean):void
FoldingManager
  
setDummyEdgeTag(edgeId:DummyEdgeId, newTag:Object, enqueueEdit:Boolean):void
FoldingManager
  
setDummyNodeLabelTag(nodeLabelId:NodeLabelId, newTag:Object, enqueueEdit:Boolean):void
FoldingManager
  
setDummyNodeLabelTagCore(nodeLabelId:NodeLabelId, newTag:Object):void
FoldingManager
  
setDummyNodePortTag(nodePortId:DummyNodePortId, tag:Object, enqueueUnit:Boolean):void
FoldingManager
  
setInitiallyExpanded(groupNode:INode, expanded:Boolean):void
Allows for setting the expanded state of a group node from the master graph that will be applied to the group nodes in the default managed views the next time it will become visible in those views.
FoldingManager
Protected Methods
 MethodDefined By
  
isInitiallyExpanded(groupNode:INode):Boolean
Determines whether the given group node from the masterGraph should be displayed in expanded state if it is included in a managed view for the first time.
FoldingManager
  
Callback that can be overridden by subclasses to prepare the IFoldedGraph instance right before it will be initialized with a copy of the elements in the initial graph.
FoldingManager
Public Constants
 ConstantDefined By
  defaultViewName : String = view
[static]
FoldingManager
Property Detail
autoAdjustMasterGroupNodeBoundsproperty
autoAdjustMasterGroupNodeBounds:Boolean

Gets or sets a property that determines whether the manager should synchronize the autoAdjustGroupNodeBounds property of the masterGroupedGraph with the client views.

IGroupedGraph. This property should be disabled to allow for modifying the contents of a collapsed group node without affecting the ancestor group nodes of nodes which would otherwise not be affected by that change.

The default value is adopted from the initial setting of the autoAdjustGroupNodeBounds property of the masterGroupedGraph. If the graph is created using the FoldingManager() constructor, the initial value will be false.


Implementation
    public function get autoAdjustMasterGroupNodeBounds():Boolean
    public function set autoAdjustMasterGroupNodeBounds(value:Boolean):void

See also

defaultExpandedPredicateproperty 
defaultExpandedPredicate:Function

Gets or sets the predicate function to use by default to determine the expanded state for the views that have been created with the default expanded predicate function.

The default value of this predicate is the isInitiallyExpanded() method of this class.


Implementation
    public function get defaultExpandedPredicate():Function
    public function set defaultExpandedPredicate(value:Function):void

See also

dummyEdgeConverterproperty 
dummyEdgeConverter:IDummyEdgeConverter

Gets or sets the IDummyEdgeConverter implementation that is used to create/convert and modify the DummyEdgeId inside the view instances.

The converter instance will be used to create the initial dummy edge appearance using IDummyEdgeConverter#createDummyEdgeAppearance() and to change the appearance using IDummyEdgeConverter#changeDummyEdgeAppearance() as soon as they appear in a view.


Implementation
    public function get dummyEdgeConverter():IDummyEdgeConverter
    public function set dummyEdgeConverter(value:IDummyEdgeConverter):void

See also

dummyNodeConverterproperty 
dummyNodeConverter:IDummyNodeConverter

The IDummyNodeConverter implementation that is used to create/convert and modify the DummyNodeId inside the view instances.

The converter instance will be used to create and convert the appearance of the collapsed dummy group nodes as soon as they appear in a view.


Implementation
    public function get dummyNodeConverter():IDummyNodeConverter
    public function set dummyNodeConverter(value:IDummyNodeConverter):void

See also

masterGraphproperty 
masterGraph:IGraph  [read-only]

Yields the master IGraph instance that holds the complete model in expanded group node state.

This graph contains all non-dummy edges and expanded group nodes, no dummy edges and no collapsed group nodes.


Implementation
    public function get masterGraph():IGraph
masterGroupedGraphproperty 
masterGroupedGraph:IGroupedGraph  [read-only]

Yields the master IGroupedGraph instance that models the fully expanded grouped graph.

This is the instance that is associated with the masterGraph and the masterHierarchy.


Implementation
    public function get masterGroupedGraph():IGroupedGraph
masterHierarchyproperty 
masterHierarchy:INodeHierarchy  [read-only]

Yields the master INodeIHierarchy instance that contains all nodes in the model, regardless of their (view-local) collapsed state.

This is the hierarchy that is associated with the IGroupedGraph that belongs to the masterGraph.


Implementation
    public function get masterHierarchy():INodeHierarchy
viewIdproperty 
viewId:String  [read-only]


Implementation
    yworks_internal function get viewId():String
viewsproperty 
views:Iterable  [read-only]

Yields all currently known views that are managed by this instance.


Implementation
    public function get views():Iterable

See also

Constructor Detail
FoldingManager()Constructor
public function FoldingManager(masterGraph:IGraph = null)

Creates a manager instance for the given masterGraph to create views on top of it that support folding operations.

Use createManagedView() to create a view that supports the IFoldedGraph interface for displaying and working with a collapsible graph structure.

Parameters
masterGraph:IGraph (default = null) — The graph to use as the masterGraph. This instance needs to support the IGroupedGraph interface. If null, a default backing graph implementation is used.

See also

Method Detail
createManagedView()method
public function createManagedView(root:INode = null, expandedPredicate:Function = null):IFoldedGraph

Creates a separate view instance of the masterGraph which is a synchronized copy of a subset of the items from the master graph.

This method will create a new instance of an IGraph that is constructed as a synchronized copy of the masterGraph. That instance can be obtained from the IFoldedGraph#graph property of the returned IFoldedGraph implementation. The graph instance will provide the following instances in its lookup() mechanism:

Note that the entities that are contained in the returned graph instance are not the same instances as the original "master" entities in the masterGraph. However they share the same properties (IVisualStyle, ITagOwner#tag, ILabelModelParameter, and INode.#layout). For collapsed group nodes and edge representatives, there is a separate set of properties available for each possible state combination. The getEdgeViewState() method for edges and the GetNodeViewState() method for nodes provide access to that state while it is not being displayed in a view.

Parameters

root:INode (default = null) — A group node or the root of the masterHierarchy whose contents will be displayed in the view. If no root node is provided, the root is set to the root in the masterHierarchy.
 
expandedPredicate:Function (default = null) — A predicate function that can be provided to the view that will be used as a callback to determine the initial expanded state of group nodes in the view.

If no expandedPredicate is provided, the value of the defaultExpandedPredicate method is lazily evaluated to determine the initial expanded state of the nodes. Changing the dfaultExpandedPredicate property after the creation of the view will still influence the view.

Returns
IFoldedGraph — A new graph instance that represents a synchronized view on the masterGraph.

See also

edgeHasViewState()method 
public function edgeHasViewState(id:DummyEdgeId):Boolean

Determines whether for the given DummyEdgeId this manager has stored associated view local state.

The manager does not necessarily have view local state for dummy elements if that specific state has never been requested by a IFoldedGraph view because it has never been visualized. This method indicates whether there is state information available for the given id.

Parameters

id:DummyEdgeId — The id for which state is requested.

Returns
Boolean — Whether getEdgeViewState( id ) would return existing state information.

See also

getChangeDummyEdgeAppearanceCallback()method 
public function getChangeDummyEdgeAppearanceCallback(edgeId:DummyEdgeId):IChangeDummyEdgeAppearanceCallback

Returns a callback object that can be used to modify the appearance of a given dummy edge without using a IFoldedGraph view.

This method can be used to modify the view state state of a dummy edge, even if there is no view, that is currently displaying this edge. The methods provided by the callback implementation will work on the given DummyEdgeId and will affect all views that display that exact dummy edge. Using the callback is the only way of modifying a dummy edge view state, since the IEdge instance returned by getEdgeViewState() does not belong to an accessible IGraph instance and thus cannot be modified otherwise.

Parameters

edgeId:DummyEdgeId — The id of the dummy edge to modify.

Returns
IChangeDummyEdgeAppearanceCallback — A callback implementation that can be used to modify the edge.

See also

getChangeDummyNodeAppearanceCallback()method 
public function getChangeDummyNodeAppearanceCallback(nodeId:DummyNodeId):IChangeDummyNodeAppearanceCallback

Returns a callback object that can be used to modify the appearance of a given dummy node without using a IFoldedGraph view.

This method can be used to modify the getNodeViewState() state of a dummy node, even if there is no view, that is currently displaying this node. The methods provided by the callback implementation will work on the given DummyNodeId and will affect all views that display that exact dummy node.

Using the callback is the only way of modifying a getNodeViewState(), since the INode instance returned by getNodeViewState() does not belong to an accessible IGraph instance and thus cannot be modified otherwise.

Parameters

nodeId:DummyNodeId — The id of the dummy node to modify.

Returns
IChangeDummyNodeAppearanceCallback — A callback implementation that can be used to modify the node.

See also

getEdgeViewState()method 
public function getEdgeViewState(edgeId:DummyEdgeId):IEdge

Return a data container implementation that is not part of any actual IGraph that describes the state of the edge for the given DummyEdgeId.

This method can be used to query the state of an edge that is either not currently visible in any views or connects to different source and target nodes because of the collapse states of the nodes and their parents in the view. The state can only be modified using the callback provided by getChangeDummyEdgeAppearanceCallback(dummyEdgeId) or by modifying the corresponding item in a IFoldedGraph view.

Parameters

edgeId:DummyEdgeId — The id of the dummy edge for which the view state should be returned.

Returns
IEdge — An implementation of IEdge that can be used to query all properties of the edge.

See also

getNodeViewState()method 
public function getNodeViewState(nodeId:DummyNodeId):INode

Provides access to the dummy state of a node for a specific view.

This method can be used to query the collapsed state of a node in a specific view, even if there is no such view currently present or the node is in fact expanded currently in that view. Note that the instance returned is neither part of the masterGraph nor part of any of the managed views. It serves as a data holder object only and the only way to modify it is using the ChangeDummyNodeAppearanceCallback provided by the getChangeDummyNodeAppearanceCallback() method or directly working on the dummy node in a IFoldedGraph view.

Parameters

nodeId:DummyNodeId — The id for which the state should be returned.

Returns
INode — A state holder implementation of a node, which is not part of any graph and can only be modified through the getChangeDummyNodeAppearanceCallback() function.

See also

getPortViewState()method 
public function getPortViewState(nodePortId:DummyNodePortId):IPort

Provides access to the dummy state of a port for a specific view.

This method can be used to query the state of a port at a collapsed node in a specific view, even if there is no such view currently present or the port's node is in fact expanded currently in that view. Note that the instance returned is neither part of the MasterGraph nor part of any of the managed views. It serves as a data holder object only and the only way to modify it is using the IChangeDummyNodeAppearanceCallback provided by the GetChangeDummyAppearanceCallback(DummyNodeId) method or directly working on the dummy port in a IFoldedGraph view.

Parameters

nodePortId:DummyNodePortId — The id for which the state should be returned.

Returns
IPort — A state holder implementation of a port, which is not part of any graph and can only be modified through the GetChangeDummyAppearanceCallback(DummyNodeId) method.

See also

GetChangeDummyAppearanceCallback(DummyNodeId)
IChangeDummyNodeAppearanceCallback.SetPortStyle
IChangeDummyNodeAppearanceCallback.SetPortLocation
DummyNodePortId
isInitiallyExpanded()method 
protected function isInitiallyExpanded(groupNode:INode):Boolean

Determines whether the given group node from the masterGraph should be displayed in expanded state if it is included in a managed view for the first time.

The createManagedView(INode) factory method use the defaultExpandedPredicate function to determine the initial expanded state of a group node. This method is the initial value of the predicate. This simple implementation will yield true, unless setInitiallyExpanded has been called before for the provided group node, in which case that specific value will be returned.

Parameters

groupNode:INode — The group node in the FoldingManager's masterHierarchy.

Returns
Booleantrue iff the node should be initially displayed in expanded state in the view that queries the initial state.

See also

nodeHasViewState()method 
public function nodeHasViewState(id:DummyNodeId):Boolean

Determines whether for the given DummyNodeId this manager has stored associated view local state.

The manager does not necessarily have view local state for dummy elements if that specific state has never been requested by a IFoldedGraph view because it has never been visualized. This method indicates whether there is state information available for the given id.

Parameters

id:DummyNodeId — The id for which state is requested.

Returns
Boolean — Whether getNodeViewState( id ) would return existing state information.

See also

portHasViewState()method 
public function portHasViewState(id:DummyNodePortId):Boolean

Determines whether for the given DummyNodePortId this manager has stored associated view local state.

The manager does not necessarily have view local state for dummy elements if that specific state has never been requested by a IFoldedGraph view because it has never been visualized. This method indicates whether there is state information available for the given id.

Parameters

id:DummyNodePortId — The id for which state is requested.

Returns
Boolean — Whether getPortViewState( id ) would return existing state information.

See also

prepareFoldedGraph()method 
protected function prepareFoldedGraph(foldedGraph:IFoldedGraph):void

Callback that can be overridden by subclasses to prepare the IFoldedGraph instance right before it will be initialized with a copy of the elements in the initial graph.

Subclasses could override this method to register additional IMapper instances with the graph instance or add IContextLookupChainLinks via the ILookupDecorator of the IFoldedGraph#graph to the instance if they are essential for the initial creation of the elements in the view instance. Overriding methods should always consider to call the base class implementation, first.

Parameters

foldedGraph:IFoldedGraph — The graph view that has just been created but is still empty.

setAutoAdjustGroupNodeBounds()method 
yworks_internal function setAutoAdjustGroupNodeBounds(value:Boolean):void

Parameters

value:Boolean

setDummyBendTagCore()method 
public function setDummyBendTagCore(bendId:BendId, newTag:Object):void

Parameters

bendId:BendId
 
newTag:Object

setDummyEdgeLabelTag()method 
public function setDummyEdgeLabelTag(edgeLabelId:EdgeLabelId, newTag:Object, enqueueEdit:Boolean):void

Parameters

edgeLabelId:EdgeLabelId
 
newTag:Object
 
enqueueEdit:Boolean

setDummyEdgeLabelTagCore()method 
public function setDummyEdgeLabelTagCore(edgeLabelId:EdgeLabelId, newTag:Object):void

Parameters

edgeLabelId:EdgeLabelId
 
newTag:Object

setDummyEdgePortTag()method 
public function setDummyEdgePortTag(portId:DummyEdgePortId, tag:Object, enqueueUnit:Boolean):void

Parameters

portId:DummyEdgePortId
 
tag:Object
 
enqueueUnit:Boolean

setDummyEdgeTag()method 
public function setDummyEdgeTag(edgeId:DummyEdgeId, newTag:Object, enqueueEdit:Boolean):void

Parameters

edgeId:DummyEdgeId
 
newTag:Object
 
enqueueEdit:Boolean

setDummyNodeLabelTag()method 
public function setDummyNodeLabelTag(nodeLabelId:NodeLabelId, newTag:Object, enqueueEdit:Boolean):void

Parameters

nodeLabelId:NodeLabelId
 
newTag:Object
 
enqueueEdit:Boolean

setDummyNodeLabelTagCore()method 
public function setDummyNodeLabelTagCore(nodeLabelId:NodeLabelId, newTag:Object):void

Parameters

nodeLabelId:NodeLabelId
 
newTag:Object

setDummyNodePortTag()method 
public function setDummyNodePortTag(nodePortId:DummyNodePortId, tag:Object, enqueueUnit:Boolean):void

Parameters

nodePortId:DummyNodePortId
 
tag:Object
 
enqueueUnit:Boolean

setInitiallyExpanded()method 
public function setInitiallyExpanded(groupNode:INode, expanded:Boolean):void

Allows for setting the expanded state of a group node from the master graph that will be applied to the group nodes in the default managed views the next time it will become visible in those views.

The isInitiallyExpanded() function will be used as the predicate in the createManagedView() and factory method. This method can be used to set the expanded state that is returned by that method for the given groupNode.

Parameters

groupNode:INode — The group node in the masterHierarchy.
 
expanded:Booleantrue iff the node should be displayed in expanded state the next time it will become visible in the default views.

See also

Constant Detail
defaultViewNameConstant
public static const defaultViewName:String = view

Examples
The following code shows how to create a managed view that can be shown in a GraphCanvasComponent.
     var graphCanvas = new GraphCanvasComponent();
     graphCanvas.graph = new FoldingManager().createManagedView().graph;
     graphCanvas.inputMode = new GraphEditorInputMode();
     

This class can be used to create managed views of the masterGraph, where group nodes can appear as collapsed group nodes with their contents hidden. Edges that connect to elements inside collapsed group nodes can be configured to be represented by dummy edges in the views. The process of converting one or more true edges from the masterGraph to zero or more dummy edges can be customized, as well as the process of converting an expanded group node to a collapsed group node.