Hiding Nodes in a Graph Hierarchy that is Managed by Class HierarchyManager
Questions & AnswersSummary
Properly hiding nodes in a graph hierarchy that is managed by class
HierarchyManager
needs graph events to be fired.
Description
In a graph hierarchy, i.e., a graph with support for grouping and nesting, class
HierarchyManager is responsible for maintaining the underlying model, and managing all changes relevant to it. To this end, HierarchyManager strongly relies on graph events.
When using the services of class GraphHider or method Graph.hide() to hide nodes, however, there are no graph events fired that indicate modifications of the graph structure. Hence HierarchyManager cannot reflect the change, and the nodes are still in the model.
To make sure that HierarchyManager gets proper notification whenever nodes are hidden from the graph structure, there are several possibilities to have graph events appropriately fired:
- When using the services of class GraphHider to hide nodes, it should be configured via the setter method setFireGraphEventsEnabled(boolean).
- Instead of hiding nodes from the graph, they should be removed using method Graph.removeNode(). Note that removing a node is the same as hiding it, however, proper graph events are fired.
- Instead of unhiding nodes from the graph, they should be reinserted using method Graph.reInsertNode(). Note that reinserting a node is the same as unhiding it, however, proper graph events are fired.
Categories this article belongs to:
yFiles for Java > yFiles Viewer > Graph Hierarchies > Managing Graph Hierarchies
Applies to:
yFiles for Java 2: 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18
Keywords:
GraphHider - HierarchyManager - Graph2DRenderer - GraphEvent - hide - hiding - node - nodes - setFireGraphEventsEnabled