public class GroupingSupport extends Object
An instance of this class which is configured for a given IGraph
instance can be obtained via
IGraph.getGroupingSupport()
.
Constructor and Description |
---|
GroupingSupport(IGraph graph)
Creates a new instance which operates on the given
graph . |
Modifier and Type | Method and Description |
---|---|
RectD |
calculateMinimumEnclosedArea(INode groupNode)
Calculates the minimum area to enclose by the given group node with respect to its
IGroupBoundsCalculator . |
void |
enlargeAllGroupNodes()
Enlarges all group nodes in the graph so that the
minimum enclosed area is
respected. |
void |
enlargeAllGroupNodes(IInputModeContext context)
Enlarges all group nodes in the graph in an interactive scenario, so that the
minimum enclosed area
is respected. |
void |
enlargeGroupNode(IInputModeContext context,
INode node,
boolean ancestors)
Enlarges the group nodes in an interactive scenario, using
IReshapeHandler implementations of the group nodes to
perform the actual resizing. |
void |
enlargeGroupNode(INode groupNode,
boolean ancestors)
Enlarges the given group node to ensure that the
minimum enclosed area is
inside of its bounds. |
IEnumerable<INode> |
getDescendants(INode node)
Returns all descendants of the provided node that are part of the grouped graph.
|
IEnumerable<INode> |
getDescendantsBottomUp(INode node)
Returns all descendants of the provided node that are part of the grouped graph.
|
INode |
getNearestCommonAncestor(INode... nodes)
Determines the nearest common ancestor of the provided nodes in the graph.
|
INode |
getNearestCommonAncestor(Iterable<INode> nodes)
Determines the nearest common ancestor of the provided nodes in the graph.
|
List<INode> |
getPathToRoot(INode node)
Gets the path to root traversing all
parents of the given item. |
boolean |
hasGroupNodes()
Whether there are group nodes in the graph.
|
boolean |
isDescendant(INode node,
INode ancestor)
Determines whether
ancestor is an ancestor of node in the grouped graph. |
public GroupingSupport(IGraph graph)
graph
.graph
- The graph to operate on.public final RectD calculateMinimumEnclosedArea(INode groupNode)
IGroupBoundsCalculator
.groupNode
- The group node to calculate the minimum enclosed area of.RectD.EMPTY
if the node is not a group node, or if it
hasn't any children.public final void enlargeAllGroupNodes()
minimum enclosed area
is
respected.enlargeGroupNode(INode, boolean)
public final void enlargeAllGroupNodes(IInputModeContext context)
minimum enclosed area
is respected.
This method should be used in an interactive editing scenario. It records an ICompoundEdit
to support
undoability and uses the IReshapeHandler
for the resizing of the nodes. That way, e.g. orthogonally edited edges
will be properly reshaped.
context
- The context to use for the IReshapeHandler
s.enlargeGroupNode(IInputModeContext, INode, boolean)
public final void enlargeGroupNode(IInputModeContext context, INode node, boolean ancestors)
IReshapeHandler
implementations of the group nodes to
perform the actual resizing.
This method should be used in an interactive editing scenario. It records an ICompoundEdit
to support
undoability and uses the IReshapeHandler
for the resizing of the nodes. That way, e.g. orthogonally edited edges
will be properly reshaped.
context
- The context to use for the IReshapeHandler
s.node
- The node to enlarge appropriately.ancestors
- if set to true
ancestors the ancestor group nodes will be adjusted, too, if necessary.IReshapeHandler
public final void enlargeGroupNode(INode groupNode, boolean ancestors)
minimum enclosed
area is
inside of its bounds.
This method can be used to resize a group node and all of its parent group nodes to fully contain its children, e.g. after a child node has changed its bounds. Note that this method will only enlarge the bounds of the group nodes, it will never reduce the size of a group node.
groupNode
- The group node to resize.ancestors
- if set to true
all ancestor group nodes will be resized, too, if necessaryenlargeGroupNode(IInputModeContext, INode, boolean)
public final IEnumerable<INode> getDescendants(INode node)
The enumeration will be top down, i.e. all of a node's ancestors will be enumerated before the respective node.
node
- The root node to get the descendants from.public final IEnumerable<INode> getDescendantsBottomUp(INode node)
The enumeration will be bottom up, i.e. all of a node's children will be enumerated before the respective node.
node
- The root node to get the descendants from.public final INode getNearestCommonAncestor(INode... nodes)
nodes
- The nodes to find the nearest common ancestor of.public final INode getNearestCommonAncestor(Iterable<INode> nodes)
nodes
- The nodes to find the nearest common ancestor of.public final List<INode> getPathToRoot(INode node)
parents
of the given item.node
- The node to start.public final boolean hasGroupNodes()