Packagecom.yworks.graph.model
Interfacepublic interface IGroupedGraph
Implementors GroupedGraph

Provides a hierarchic view over an IGraph.

The nodes in a graph can be put into a hierarchical relationship. This interface provides access to the hierarchy of the nodes and offers methods to modify the graph's node hierarchy.

An implementation of this interface can be queried from IGraph's lookup method, if groupingSupported is set to true.

View the examples

See also

hierarchy
INodeHierarchy
IGraph
DefaultGraph.groupingSupported


Public Properties
 PropertyDefined By
  autoAdjustGroupNodeBounds : Boolean
Gets or sets a property that determines whether the bounds of group nodes should automatically be adjusted whenever the nodes that belong to the group node change their bounds.
IGroupedGraph
  defaultGroupNodeStyle : INodeStyle
Gets or sets the DefaultGroupNodeStyle property.
IGroupedGraph
  graph : IGraph
[read-only] Yields the graph instance that this instance is working on.
IGroupedGraph
  hierarchy : INodeHierarchy
[read-only] Yields the hierarchy of the nodes in this grouped graph.
IGroupedGraph
Public Methods
 MethodDefined By
  
Method to adjust the size of a group node.
IGroupedGraph
  
createGroupNode(parent:INode = null, bounds:IRectangle = null, style:INodeStyle = null):INode
Creates a new group node.
IGroupedGraph
  
createNode(parent:INode, bounds:IRectangle = null, style:INodeStyle = null):INode
Creates a new ordinary node as a direct descendant of parent.
IGroupedGraph
  
Convenience method that yields the parent of a node.
IGroupedGraph
  
groupNodes(children:Iterable, parent:INode = null):INode
Groups the nodes in children into a group node.
IGroupedGraph
  
setParent(node:INode, parent:INode):void
Sets the parent node for a given node.
IGroupedGraph
Property Detail
autoAdjustGroupNodeBoundsproperty
autoAdjustGroupNodeBounds:Boolean

Gets or sets a property that determines whether the bounds of group nodes should automatically be adjusted whenever the nodes that belong to the group node change their bounds.

This behavior is turned on by default and should only be turned off temporarily to allow for programmatic batch updates to the bounds of nodes.

The default value is true.


Implementation
    public function get autoAdjustGroupNodeBounds():Boolean
    public function set autoAdjustGroupNodeBounds(value:Boolean):void
defaultGroupNodeStyleproperty 
defaultGroupNodeStyle:INodeStyle

Gets or sets the DefaultGroupNodeStyle property.


Implementation
    public function get defaultGroupNodeStyle():INodeStyle
    public function set defaultGroupNodeStyle(value:INodeStyle):void
graphproperty 
graph:IGraph  [read-only]

Yields the graph instance that this instance is working on.


Implementation
    public function get graph():IGraph
hierarchyproperty 
hierarchy:INodeHierarchy  [read-only]

Yields the hierarchy of the nodes in this grouped graph.


Implementation
    public function get hierarchy():INodeHierarchy
Method Detail
adjustGroupNodeBounds()method
public function adjustGroupNodeBounds(groupNode:INode):void

Method to adjust the size of a group node.

This will resize to group node bounds such that the node requires the least amount of space. If the node does not have any children, it's bounds will be left unchanged.

Parameters

groupNode:INode — The group node to adjust the size of.

See also

createGroupNode()method 
public function createGroupNode(parent:INode = null, bounds:IRectangle = null, style:INodeStyle = null):INode

Creates a new group node.

If no parent group node is provided, the group node will be a top-level group node in the node hierarchy. If a parent is provided, the created group node will be a direct descendant of parent.

Parameters

parent:INode (default = null) — The node to use as the parent in the grouping hierarchy, or null if a top-level group node should be created.
 
bounds:IRectangle (default = null) — The initial bounds to use for the new group node, or null.
 
style:INodeStyle (default = null) — The style to use for the new group node, or null, if the defaultGroupNodeStyle should be used.

Returns
INode — The newly created group node if no parent node was provided, or parent.
createNode()method 
public function createNode(parent:INode, bounds:IRectangle = null, style:INodeStyle = null):INode

Creates a new ordinary node as a direct descendant of parent.

This method ultimately delegates to the graph's createNode set of methods.

Parameters

parent:INode — The node to use as the parent in the grouping hierarchy.
 
bounds:IRectangle (default = null) — The initial node bounds, or null if default bounds should be used. The values will be copied to the node's layout field.
 
style:INodeStyle (default = null) — the style instance that will be assigned to the newly created instance, or null if the default style should be used.

Returns
INode — The newly created node.

See also

getParent()method 
public function getParent(node:INode):INode

Convenience method that yields the parent of a node.

This method yields the parent node of the current node or the root node if the node is a top level node in the hierarchy.

Parameters

node:INode — The node to yield the parent node.

Returns
INode — The parent of the node or the root node if the node is a top level node.

See also

groupNodes()method 
public function groupNodes(children:Iterable, parent:INode = null):INode

Groups the nodes in children into a group node.

If no parent is provided, the parent group node will be created at the common ancestor level of all nodes in children.

The parent needs to be a group node at the time of the invocation. This operation is basically the same as calling setParent for each node in the children iterable whose parent is not part of the set.

Parameters

children:Iterable — The children to group into the group node.
 
parent:INode (default = null)

Returns
INode — The newly created group node if no parent was provided, or parent.

See also

setParent()method 
public function setParent(node:INode, parent:INode):void

Sets the parent node for a given node.

Use hierarchy's root field to make node a top-level node for this graph.

Parameters

node:INode — The node to assign a new parent.
 
parent:INode — The parent group node to assign to node.

See also

Examples
The following code enables grouping support of a DefaultGraph and uses the functionality of IGroupedGraph.
       var graph:IGraph = graphCanvas.graph;
        
        // Turn on grouping support in DefaultGraph.
        DefaultGraph defaultGraph = graph as DefaultGraph;
        if (defaultGraph != null) {
         defaultGraph.groupingSupported = true;
       }
       
      // Use the grouping support.
       var grouped:IGroupedGraph = graph.lookup( IGroupedGraph ) as IGroupedGraph;
       if (grouped != null) {
         grouped.defaultGroupNodeStyle = new ShapeNodeStyle(null, ShapeNodeShape.roundRectangle, Fills.GREEN );
         var groupNode:INode = grouped.createGroupNode();
         grouped.groupNodes( groupNode, { sourceNode, targetNode } );
        }