y.view
Class Graph2DEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--java.beans.PropertyChangeEvent
              |
              +--y.view.Graph2DEvent
All Implemented Interfaces:
Serializable

public class Graph2DEvent
extends PropertyChangeEvent

An event which indicates that a property associated with a Graph2D or associated with one of its elements has changed.

Unlike GraphEvents, instances of Graph2DEvent do not reflect structural changes of a graph. They are more related to events of type PropertyChangeEvent. They carry a source, an oldValue and a newValue. Additionally they carry a subject, which may be different from the source. The source is always of type Graph2D. The subject may be of any type, although most of the times the subject is of type NodeRealizer, EdgeRealizer, NodeLabel or EdgeLabel, depending on the attribute that has changed in the graph.

If, for example, the fill color of a NodeRealizer changes from Color.yellow to Color.red, then the subject of the emitted Graph2DEvent will be of type NodeRealizer, its property name will be "fillColor" and its old and new value will be Color.yellow, and Color.red.

If, on the other hand, the text of one of the labels associated with an edge changes, then the subject of the event emitted will be of type EdgeLabel and the associated property name will be "text", since the text of an edge label gets ultimately changed by calling method "setText" on an instance of EdgeLabel.

Whenever a Graph2DEvent is emitted, then the associated new value will be already set on the subject.

Property values of primitive type will be marshalled by the corresponding primitive data type wrapper classes Boolean, Double, Integer, etc.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
Graph2DEvent(Graph2D source, Object subject, String propertyName, Object oldValue, Object newValue)
          Creates a new instance of Graph2DEvent.
 
Method Summary
 Graph2D getGraph2D()
          Returns the source of this event.
 String getPropertyName()
          Returns the property name of the feature whose value has been changed.
 Object getSubject()
          Returns the subject of this event.
 
Methods inherited from class java.beans.PropertyChangeEvent
getNewValue, getOldValue, getPropagationId, setPropagationId
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph2DEvent

public Graph2DEvent(Graph2D source,
                    Object subject,
                    String propertyName,
                    Object oldValue,
                    Object newValue)
Creates a new instance of Graph2DEvent.

Parameters:
source - the Graph2D object that is the source emitting this event.
subject - the subject of this event.
propertyName - the name of the changed property
oldValue - the former value of the named property.
newValue - the new value of the named property
Method Detail

getGraph2D

public Graph2D getGraph2D()
Returns the source of this event.


getSubject

public Object getSubject()
Returns the subject of this event. The subject of an event is the actual object whose property has been changed.


getPropertyName

public String getPropertyName()
Returns the property name of the feature whose value has been changed. Property names follow the Java Beans naming conventions. If a feature xyz has been changed by calling the setXzy() method on the subject, then the property name will be "zxy", ie. text changed by a method setText, has the property name "text".

Overrides:
getPropertyName in class PropertyChangeEvent

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003