Hiding Nodes in a Graph Hierarchy that is Managed by Class HierarchyManager
Applies to: yFiles for Java 2.9, 2.8, 2.7, 2.6, 2.5, 2.4, 2.3, 2.2 print article email article

Type: Questions & Answers

Properly hiding nodes in a graph hierarchy that is managed by class HierarchyManager needs graph events to be fired.

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.

Note
Beginning with yFiles version 2.2, class DefaultGraph2DRenderer, which renders the visual representations of graph elements, uses the HierarchyManager object that is associated with a graph to determine the set of nodes to be painted.

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.

Note
As an alternative to firing GraphEvents when using GraphHider, it is also possible to use a customized implementation of interface Graph2DRenderer that does not draw hidden nodes.

Keywords: GraphHider - HierarchyManager - Graph2DRenderer - GraphEvent - hide - hiding - node - nodes - setFireGraphEventsEnabled

Provide feedback:
How useful was this article?    less 1 2 3 4 5 more
Email address (optional):
COPYRIGHT © 2012 yWorks · ALL RIGHTS RESERVED imprint | terms of use | privacy policy | home