NodeRealizer Idiosyncrasies

Troubleshooting

Summary

Considerations regarding a node's size and its location when working with NodeRealizer.
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

Working with NodeRealizer

Abstract class NodeRealizer serves as the basis for node realizer implementations. Among other user interface aspects, a node realizer defines the way a graph element is rendered, i.e., it provides and manages all visual aspects of a node in a Graph2D.
When working with node realizers, some aspects regarding a node's size and its location should be kept in mind.

Setting the node size also changes the coordinates of the node's upper left corner

Abstract class NodeRealizer follows a node center-centric scheme with regard to node size changes, i.e., the coordinates of a node's center stay the same when changing the node's size. As a matter of fact, when calling the NodeRealizer.setSize method, the coordinates of the node's upper left corner change, i.e., the node's location changes.
Consequently, whenever you need to set both size and location of a node (realizer), either first set the size, then the location or use one of NodeRealizer's setFrame methods.

Categories this article belongs to:
yFiles for Java > yFiles Viewer > Displaying and Editing Graphs > Bringing Graph Elements to Life: The Realizer Concept
Applies to:
yFiles for Java 2: 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:
NodeRealizer - node - realizer - Graph2D - setSize - size - coordinates - upper - left - layout - center - setLocation