|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides utility functions to query and modify the the node hierarchy of a grouped
LayoutGraph
.
Internally, the hierarchy is managed using data providers that can be obtained from the graph using the following keys:
GroupingKeys.NODE_ID_DPKEY
- Stores an id for each node. In a yFiles FLEX server component,
the NODE_ID_DPKEY data provider is the same instance as the
AbstractGraphRoundtripSupport.NODE_2_ID_DPKEY
data provider.GroupingKeys.PARENT_NODE_ID_DPKEY
- Stores the parent node id for each grouped node.GroupingKeys.GROUP_DPKEY
- Stores whether a node is considered a group node.
A group node may have children.
LayoutGraph
Method Summary | |
void |
enableGrouping()
Adds the DataProviders that are required for working with hierarchic layout graphs
and calls transferMapperIDs() . |
NodeList |
getChildren(Node parent)
Returns a list of all child nodes of the given parent node. |
NodeList |
getNeighbors(Node node)
Returns a list containing the given node and all it's neighbor nodes. |
NodeList |
getNodes()
Returns a node cursor that allows for breadth-first iteration over the node hierarchy of the provided graph. |
Node |
getParent(Node child)
Gets the parent node of the provided node. |
NodeList |
getTopLevelNodes()
Returns a cursor over all top level nodes of the provided graph, i.e., all nodes for which NodeHierarchy.getParent( node ) yields null . |
boolean |
isGroupNode(Node node)
Whether the given node is considered a group node. |
void |
setGroupNode(Node node,
boolean isGroupNode)
Sets whether the provided node should be considered a group node. |
void |
setParent(NodeList children,
Node parent)
Adds all nodes contained in the provided NodeList as children
of the provided parent node. |
void |
setParent(Node child,
Node parent)
Sets the parent node for a given node. |
void |
transferMapperIDs()
Replaces the DataProvider for grouping keys with the id data provider used by yFiles FLEX. |
Method Detail |
public Node getParent(Node child)
null
is returned.
child
- The child node.
null
if child
is a top-level node.public void setParent(Node child, Node parent)
child
a top-level node, pass null
as the
parent
.
Calls enableGrouping()
to make sure that the graph instance supports hierarchies.
child
- The node to assign a new parent.parent
- The parent node to assign to child
.
java.lang.UnsupportedOperationException
- if parent
is a child of child
, or parent
equals child
.public void setParent(NodeList children, Node parent)
NodeList
as children
of the provided parent node.
children
- A list of nodes to be added as children of the provided parent node.parent
- The parent node.public void setGroupNode(Node node, boolean isGroupNode)
node
- A node.isGroupNode
- Whether to consider the given node a group node.public boolean isGroupNode(Node node)
This method may return true
, even if the given node doesn't have any child nodes.
node
- A node.
public NodeList getChildren(Node parent)
parent
- A parent node.
public NodeList getNeighbors(Node node)
If the given node is top-level, all top-level nodes are returned. Otherwise all child nodes of the given node's parent node are returned.
node
- The node to get the neighbors for.
public void enableGrouping()
DataProviders
that are required for working with hierarchic layout graphs
and calls transferMapperIDs()
.
GroupingKeys
,
transferMapperIDs()
public NodeList getNodes()
public NodeList getTopLevelNodes()
NodeHierarchy.getParent( node )
yields null
.
public void transferMapperIDs()
After using this function, graph.getDataProvider( GroupingKeys.NODE_ID_DPKEY )
and
graph.getDataProvider(AbstractGraphRoundtripSupport.NODE_2_ID_DPKEY )
will yield the same instance.
This instance will automatically generate ids for newly created nodes.
Clients should only call this function if the graph is read directly using a GraphML I/O handler instance.
AbstractGraphRoundtripSupport.NODE_2_ID_DPKEY
,
GroupingKeys.NODE_ID_DPKEY
,
GroupingKeys.PARENT_NODE_ID_DPKEY
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |