edu.umd.cs.jazz.event
Class ZGroupEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--java.awt.AWTEvent
              |
              +--edu.umd.cs.jazz.event.ZGroupEvent
All Implemented Interfaces:
java.io.Serializable, ZEvent

public class ZGroupEvent
extends java.awt.AWTEvent
implements ZEvent, java.io.Serializable

ZGroupEvent is an event which indicates that a group node has changed.

Group events are provided for notification purposes ONLY; Jazz will automatically handle changes to the group contents internally so that the program works properly regardless of whether the program is receiving these events or not.

This event is generated by a ZGroup when a node is added or removed from it. The event is passed to every ZGroupListener or ZGroupAdapter object which registered to receive such events using the group's addGroupListener method. (ZGroupAdapter objects implement the ZGroupListener interface.) Each such listener object gets this ZGroupEvent when the event occurs.

ZGroupEvents now contains a method isModificationEvent() to distinguish a modification event from a true node addition or removal. A modification event is one in which a node changes position in a single scenegraph or between two different scenegraphs. A true addition or removal event is one in which a node is first added to or removed from a scenegraph. For example, the following bit of code checks to see if a given node has been deleted from its parent by checking to see if the event is a modification event.

     public void nodeRemoved(ZGroupEvent e) {
         if (e.getChild() == myNode &&
             !e.isModificationEvent()) {
             // myNode was *truly* deleted from the scenegraph
         }
     }
 

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Ben Bederson
See Also:
ZGroupAdapter, ZGroupListener, Serialized Form

Field Summary
static int GROUP_FIRST
          The first number in the range of ids used for group events.
static int GROUP_LAST
          The last number in the range of ids used for group events.
static int NODE_ADDED
          This event indicates that a node was added to the group.
static int NODE_REMOVED
          This event indicates that a node was removed from the group.
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
  ZGroupEvent(ZGroup source, int id, ZNode child, boolean modification)
          Deprecated. as of Jazz 1.1, use createNodeAddedEvent() or createNodeRemovedEvent() instead.
protected ZGroupEvent(ZGroup source, int id, ZNode child, boolean modification, java.lang.Object dummy)
           
 
Method Summary
 void consume()
          Consume this event.
static ZGroupEvent createNodeAddedEvent(ZGroup source, ZNode child, boolean modification)
          Factory method to create a ZGroupEvent with a NODE_ADDED ID.
static ZGroupEvent createNodeRemovedEvent(ZGroup source, ZNode child, boolean modification)
          Factory method to create a ZGroupEvent with a NODE_REMOVED ID.
 void dispatchTo(java.lang.Object listener)
          Calls appropriate method on the listener based on this events ID.
 ZNode getChild()
          Returns the ZNode that was affected by the event.
 ZGroup getGroup()
          Returns the originator of the event.
 java.lang.Class getListenerType()
          Returns the ZGroupLister class.
 boolean isConsumed()
          True if this event has been consumed.
 boolean isModificationEvent()
          True if this event is a modification.
 void setSource(java.lang.Object aSource)
          Set the souce of this event.
 
Methods inherited from class java.awt.AWTEvent
finalize, getID, paramString, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GROUP_FIRST

public static final int GROUP_FIRST
The first number in the range of ids used for group events.

GROUP_LAST

public static final int GROUP_LAST
The last number in the range of ids used for group events.

NODE_ADDED

public static final int NODE_ADDED
This event indicates that a node was added to the group.

NODE_REMOVED

public static final int NODE_REMOVED
This event indicates that a node was removed from the group.
Constructor Detail

ZGroupEvent

public ZGroupEvent(ZGroup source,
                   int id,
                   ZNode child,
                   boolean modification)
Deprecated. as of Jazz 1.1, use createNodeAddedEvent() or createNodeRemovedEvent() instead.

Constructs a ZGroupEvent object.
Parameters:
source - the ZGroup object that originated the event
id - an integer indicating the type of event
child - the node that was added or removed
modification - is this event a modification?

ZGroupEvent

protected ZGroupEvent(ZGroup source,
                      int id,
                      ZNode child,
                      boolean modification,
                      java.lang.Object dummy)
Method Detail

createNodeAddedEvent

public static ZGroupEvent createNodeAddedEvent(ZGroup source,
                                               ZNode child,
                                               boolean modification)
Factory method to create a ZGroupEvent with a NODE_ADDED ID.
Parameters:
source - the ZGroup object that originated the event
child - the node that was added or removed
modification - is this event a modification?

createNodeRemovedEvent

public static ZGroupEvent createNodeRemovedEvent(ZGroup source,
                                                 ZNode child,
                                                 boolean modification)
Factory method to create a ZGroupEvent with a NODE_REMOVED ID.
Parameters:
source - the ZGroup object that originated the event
child - the node that was added or removed
modification - is this event a modification?

getGroup

public ZGroup getGroup()
Returns the originator of the event.
Returns:
the ZGroup object that originated the event.

getChild

public ZNode getChild()
Returns the ZNode that was affected by the event.
Returns:
the ZNode object that was added or removed

isModificationEvent

public boolean isModificationEvent()
True if this event is a modification. A modification event is one in which a node changes position in a single scenegraph or between two different scenegraphs. A non-modification event is one in which a node is first added to, or removed from, a scenegraph.
Returns:
Does this event represent a modification?

isConsumed

public boolean isConsumed()
True if this event has been consumed.
Specified by:
isConsumed in interface ZEvent
Overrides:
isConsumed in class java.awt.AWTEvent

consume

public void consume()
Consume this event.
Overrides:
consume in class java.awt.AWTEvent

dispatchTo

public void dispatchTo(java.lang.Object listener)
Calls appropriate method on the listener based on this events ID.
Specified by:
dispatchTo in interface ZEvent

getListenerType

public java.lang.Class getListenerType()
Returns the ZGroupLister class.
Specified by:
getListenerType in interface ZEvent

setSource

public void setSource(java.lang.Object aSource)
Set the souce of this event. As the event is fired up the tree the source of the event will keep changing to reflect the scenegraph object that is firing the event.
Specified by:
setSource in interface ZEvent


Copyright © 2001 by University of Maryland, College Park, MD 20742, USA All rights reserved.