gishur.core.event
Class GishurEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--java.awt.AWTEvent
              |
              +--gishur.core.event.GishurEvent
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ConsumableEvent, DrawEvent

public abstract class GishurEvent
extends java.awt.AWTEvent

Base class for all events defined in the Gishur package. GishurEvents are based on AWTEvents and can so dispatched by standard AWT Components. GishurEvent assumes a few things about standard AWT events, so if that changes, an update of GishurEvent should be enough to correct the problem. GishurEvent mirrors the event masks for standard awt events as int values in order to enable correct event enabeling. Gishur events use the upper 20 bits of the event-id as event mask to check fast, if a event is enabled or not. This is enough for 20 types of events, the other 12 bits of the 32 bit integer are used to specify the type of the event. This system works until the maximum reserved id for awt-events is smaller than 4096 (at this time (JDK 1.2) its 1999). AWT event masks can be much greater! To ensure that they fit into an integer, Gishur uses the event mask defined by this class rather than the event masks defined by AWTEvent. The enable/disable check for internal awt events is performed awt-compatibel, so this should work anyway.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Field Summary
static int AWT_ACTION_EVENT_MASK
          The event mask for selecting action events.
static int AWT_ADJUSTMENT_EVENT_MASK
          The event mask for selecting adjustment events.
static int AWT_COMPONENT_EVENT_MASK
          The event mask for selecting component events.
static int AWT_CONTAINER_EVENT_MASK
          The event mask for selecting container events.
static int AWT_FOCUS_EVENT_MASK
          The event mask for selecting focus events.
static int AWT_ITEM_EVENT_MASK
          The event mask for selecting item events.
static int AWT_KEY_EVENT_MASK
          The event mask for selecting key events.
static int AWT_MOUSE_EVENT_MASK
          The event mask for selecting mouse events.
static int AWT_MOUSE_MOTION_EVENT_MASK
          The event mask for selecting mouse motion events.
static int AWT_TEXT_EVENT_MASK
          The event mask for selecting text events.
static int AWT_WINDOW_EVENT_MASK
          The event mask for selecting window events.
static int GISHUR_EVENT_MASK
          Mask for the mask-part of all gishur events - the mask bits of every GishurEvent should be in that range (value is 0xfffff000).
static int GISHUR_ID_MASK
          Mask for the type-part of an event id - this should be the complement of GISHUR_EVENT_MASK.
static int MAX_EVENT_TYPES
          Maximum amount of event types (=number of set bits in GISHUR_EVENT_MASK).
static int MIN_GISHUR_MASK
          This is the minimum id of a GishurEvent.
 
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
GishurEvent(java.awt.Event event)
          Constructs an GishurEvent object from the parameters of a 1.0-style event.
GishurEvent(java.lang.Object source, int id)
          Constructs an GishurEvent object with the specified source object and type.
 
Method Summary
static boolean isMaskedBy(int id, int mask)
          Returns true, if the given event type is masked by the given event mask.
 
Methods inherited from class java.awt.AWTEvent
consume, finalize, getID, isConsumed, 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

GISHUR_EVENT_MASK

public static final int GISHUR_EVENT_MASK
Mask for the mask-part of all gishur events - the mask bits of every GishurEvent should be in that range (value is 0xfffff000).

GISHUR_ID_MASK

public static final int GISHUR_ID_MASK
Mask for the type-part of an event id - this should be the complement of GISHUR_EVENT_MASK.

MIN_GISHUR_MASK

public static final int MIN_GISHUR_MASK
This is the minimum id of a GishurEvent. This bit should be left shifted to create various event masks. The maximum number of bits to shift is given by MAX_EVENT_TYPES-1.

MAX_EVENT_TYPES

public static final int MAX_EVENT_TYPES
Maximum amount of event types (=number of set bits in GISHUR_EVENT_MASK).

AWT_COMPONENT_EVENT_MASK

public static final int AWT_COMPONENT_EVENT_MASK
The event mask for selecting component events.

AWT_CONTAINER_EVENT_MASK

public static final int AWT_CONTAINER_EVENT_MASK
The event mask for selecting container events.

AWT_FOCUS_EVENT_MASK

public static final int AWT_FOCUS_EVENT_MASK
The event mask for selecting focus events.

AWT_KEY_EVENT_MASK

public static final int AWT_KEY_EVENT_MASK
The event mask for selecting key events.

AWT_MOUSE_EVENT_MASK

public static final int AWT_MOUSE_EVENT_MASK
The event mask for selecting mouse events.

AWT_MOUSE_MOTION_EVENT_MASK

public static final int AWT_MOUSE_MOTION_EVENT_MASK
The event mask for selecting mouse motion events.

AWT_WINDOW_EVENT_MASK

public static final int AWT_WINDOW_EVENT_MASK
The event mask for selecting window events.

AWT_ACTION_EVENT_MASK

public static final int AWT_ACTION_EVENT_MASK
The event mask for selecting action events.

AWT_ADJUSTMENT_EVENT_MASK

public static final int AWT_ADJUSTMENT_EVENT_MASK
The event mask for selecting adjustment events.

AWT_ITEM_EVENT_MASK

public static final int AWT_ITEM_EVENT_MASK
The event mask for selecting item events.

AWT_TEXT_EVENT_MASK

public static final int AWT_TEXT_EVENT_MASK
The event mask for selecting text events.
Constructor Detail

GishurEvent

public GishurEvent(java.awt.Event event)
Constructs an GishurEvent object from the parameters of a 1.0-style event.
Parameters:
event - the old-style event

GishurEvent

public GishurEvent(java.lang.Object source,
                   int id)
Constructs an GishurEvent object with the specified source object and type.
Parameters:
source - the object where the event originated
Method Detail

isMaskedBy

public static boolean isMaskedBy(int id,
                                 int mask)
Returns true, if the given event type is masked by the given event mask. This is the case, iff the id has a valid mask part contained by the mask. A valid id should have only one single bit in the mask part (see GISHUR_EVENT_MASK).
Parameters:
id - the id to test
mask - the event mask