Property Change Support in Graph2DView
Applies to: yFiles for Java 2.7, yFiles for Java 2.6, yFiles for Java 2.5, yFiles for Java 2.4 print article email article

Type: Questions & Answers

The Graph2DView class provides support for event notification using property change events.

Property change events that are related to the zoom level and the part of the world coordinate space that is shown in the view include the following Graph2DView properties:

Property Name Value Type
Zoom double (boxed as java.lang.Double)
ViewPoint java.awt.geom.Point2D.Double

In a PropertyChangeListener implementation test for these property names. The code snippet outlines a property change listener for the value of the zoom level. Listeners for other properties follow the same general pattern.

// 'view' is of type y.view.Graph2DView.

view.getCanvasComponent().addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      if ("Zoom".equals(evt.getPropertyName())) {
        double zoom = ((Double)evt.getNewValue()).doubleValue();
        // Do something with the value for the zoom level.
      }
    }
});

Property change events that are related to the grid mode of Graph2DView cover these properties:

Property Name Value Type
GridColor java.awt.Color
GridType the constants defined in View2DConstants (boxed as java.lang.Integer)
GridMode boolean (boxed as java.lang.Double)
GridResolution double (boxed as java.lang.Double)
GridCursorActive boolean (boxed as java.lang.Boolean)
GridVisible boolean (boxed as java.lang.Boolean)

Related Reading

In the yFiles for Java Developer's Guide please see the following sections:

Keywords: view - Graph2DView - property - change - event - listener - canvas - component - getCanvasComponent - zoom - viewpoint - grid

Provide feedback:
How useful was this article?    less 1 2 3 4 5 more
Email address (optional):
COPYRIGHT © 2008 yWorks · ALL RIGHTS RESERVED imprint | top | home