Where to Find Up-to-date yFiles Information

This page is from the outdated yFiles for Java 2.13 documentation. You can find the most up-to-date documentation for all yFiles products on the yFiles documentation overview page.

Please see the following links for more information about the yFiles product family of diagramming programming libraries and corresponding yFiles products for modern web apps, for cross-platform Java(FX) applications, and for applications for the Microsoft .NET environment.

More about the yFiles product family Close X

Node Realizers

Graph hierarchies make use of special proxy elements that indicate either the grouping of a collection of nodes, or the nesting of another graph structure. These proxies are called group nodes and folder nodes, respectively, and are rendered by specialized node realizers.

Classes GroupNodeRealizer and GenericGroupNodeRealizer

Classes GroupNodeRealizer and GenericGroupNodeRealizer each provide the visual presentation for both group nodes and folder nodes. Common to the presentation of group and folder nodes is a title bar that presents the node's label, their differences are summarized in Table 7.2, “Group node and folder node rendering and behavior”.

Table 7.2. Group node and folder node rendering and behavior

Group node Folder node
displays open state icon (stylized minus sign) displays closed state icon (stylized plus sign)
size is automatically determined to entirely enclose its grouped nodes; if size constraints are specified (see below), they are respected accordingly size is controlled normally; if size constraints are specified (see below), they are respected accordingly
is not responsible for drawing its grouped nodes optionally displays a scaled version of the nested graph structure

The tutorial demo application CustomGroupVisualizationDemo.java demonstrates how to customize the visual representation of group and folder nodes using GenericGroupNodeRealizer.

A group node realizer, i.e., either a GroupNodeRealizer or a GenericGroupNodeRealizer instance, can be in one of two states, namely open or closed, where

  • open means that the realizer renders a group node, and
  • closed means that it renders a folder node.

The respective state a group node realizer is in, is directly reflected by the displayed state icon.

Using the services of static inner class GroupNodeRealizer.StateChangeListener a group node realizer's state can automatically be updated. In addition, the current state can also be controlled using the following methods:

boolean isGroupClosed()
void setGroupClosed(boolean closed)
Description Getter and setter methods for group node realizer state in class GroupNodeRealizer. The same methods are available in class GenericGroupNodeRealizer as well.

Figure 7.5. Group node realizer classes

Group node realizer classes.

Resizing Policy

Class GroupNodeRealizer implements interface AutoBoundsFeature, which by default is enabled whenever a GroupNodeRealizer instance is in open state, i.e., a group node is rendered. Similarly, class GenericGroupNodeRealizer has an AutoBoundsFeature implementation in its configuration that is also in enabled state.

Auto bounds feature is responsible for adjusting the size and location of the rendered group node. It automatically determines the group node's bounds on the basis of the enclosing rectangle of the grouped nodes that a group node contains. At the same time, changes to the bounds using the appropriate methods are completely ignored.

Note

Auto bounds feature applies to group nodes only, and is of no relevance to folder nodes.

To explicitly change a group node's bounds, the auto bounds feature has to be disabled so that the change can have effect, and again enabled afterwards. The group node's bounds are then adopted as long as the enclosing rectangle of the grouped nodes is entirely contained. If it is not, then the bounds are reset to this rectangle.

Group nodes additionally also support specifying minimum size and maximum size constraints for their visual representation. Both size constraints are respected when a node is resized interactively by a user, i.e., when view mode class HotSpotMode handles the node resizing mouse gesture.

When a layout is calculated, minimum size constraints are respected by several yFiles layout algorithms that handle grouped graphs. Proper setup of all relevant data for layout calculation is handled by class GroupLayoutConfigurator.

By default, there are no size constraints specified for group nodes. However, the following setter method can be used to implicitly specify a minimum size constraint that is the union of the enclosing rectangle of the grouped nodes that a group node contains and the sizes of the first (text) label and the state icon. Both methods below are available in classes GroupNodeRealizer and DefaultGenericAutoBoundsFeature.

boolean isConsiderNodeLabelSize()
void setConsiderNodeLabelSize(boolean considerNodeLabelSize)
Description Node label size support in class GroupNodeRealizer. The same methods are available in class DefaultGenericAutoBoundsFeature as well.

DefaultGenericAutoBoundsFeature is part of the default GenericGroupNodeRealizer configuration as the GenericNodeRealizer.GenericSizeConstraintProvider implementation from which a SizeConstraintProvider instance is created.

Interface AutoBoundsFeature

Interface AutoBoundsFeature serves as a means to have the size and location of a node realizer's rendering be controlled by factors other than explicit assignment. In particular, it is responsible for updating the bounds whenever such a factor changes. Also, direct manipulation of the bounds using the respective node realizer methods is ignored.

AutoBoundsFeature allows the definition of a minimal bounds for its node realizer, and defines the notion of insets that are used to compensate for any width and height that exceeds this minimal bounds.

Note that the AutoBoundsFeature implementation that is returned by GenericGroupNodeRealizer is created from the GenericGroupNodeRealizer.GenericAutoBoundsFeature implementation found in the realizer's configuration. By default, this implementation is of type DefaultGenericAutoBoundsFeature.