Events and Listeners

The listeners that are provided with package y.view allow for simple notification support with graphical property changes and also selection state modifications. They complement the event notification mechanism from package y.base which governs all structural graph changes.

Graphical Property Changes

Interface Graph2DListener notifies interested parties of Graph2D property changes. The information is conveyed using objects of type Graph2DEvent, and covers non-structural properties, i.e., label text changes, and realizer type changes.

To receive notifications, Graph2DListener implementations have to be properly registered with the Graph2D object. Figure 6.62, “Context for using Graph2DListener” gives an overview on interface Graph2DListener's role.

Figure 6.62. Context for using Graph2DListener

Context for using Graph2DListener.

Note that the returned property name of Graph2DEvent's getPropertyName() method follows the Java Beans naming convention for properties and applies to the event's subject which is returned by method getSubject().

Selection State Changes

Interface Graph2DSelectionListener notifies interested parties of selection state changes with Graph2D elements. The information is conveyed using objects of type Graph2DSelectionEvent, which provide various methods to detect the specific type of elements.

To receive notifications, Graph2DSelectionListener implementations have to be properly registered with the Graph2D object. Figure 6.63, “Context for using Graph2DSelectionListener” gives an overview on interface Graph2DSelectionListener's role.

Figure 6.63. Context for using Graph2DSelectionListener

Context for using Graph2DSelectionListener.

Note that changing the selection state of NodeRealizer and EdgeRealizer objects generates events only when they are bound to a graph element that resides in a Graph2D. The same holds true for changing the selection state of Bend objects. Events are generated only when the edge that is bound to its EdgeRealizer object resides in a Graph2D.