Class BasicEvent
- java.lang.Object
-
- java.util.EventObject
-
- de.sciss.app.BasicEvent
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
DocumentEvent,NumberEvent,ParamField.Event,PathEvent,ProcessingThread.Event
public abstract class BasicEvent extends java.util.EventObjectBasicEventis the superclass of all events to be processed throughEventManagers. It subclasesjava.util.EventObjectand thus inherits an eventsourceobject.The source is usually the object that caused the event to be dispatched, see the Timeline's setPosition for an example of the source usage. This allows objects which both dispatch and receive events to recognize if the event was fired by themselves, in which case they might optimize graphical updates or simply ignore the event, or by other objects.
Furthermore, a time tag (
getWhen()) can be read to find out when the event was generated.If events are dispatched at a heavy frequency, the
incorporatemethod can help to shrink the queue by fusing events of the same type.- See Also:
EventManager, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BasicEvent(java.lang.Object source, int id, long when)Constructs a newBasicEvent.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intgetID()Requests an identifier specifying the exact type of action that was performed.longgetWhen()State whens the event has been generated, a timestamp specifying system time millisecs as returned bySystem.currentTimeMillis().abstract booleanincorporate(BasicEvent oldEvent)Asks the event to incorporate the action described by another (older) event.
-
-
-
Constructor Detail
-
BasicEvent
public BasicEvent(java.lang.Object source, int id, long when)Constructs a newBasicEvent.- Parameters:
source- SinceBasicEventis a subclass ofjava.util.EventObject, the given 'source' is directly passed to the superclass and can be queried withgetSource(). Thesourcedescribes the object that originated an action.id- type of action depending on the concrete subclass. Generally theidis used to distinguish between different method calls on the registered listeners, hence will be usually ignored by the listeners themselves.when- When the event was generated. SeegetWhen().
-
-
Method Detail
-
getID
public int getID()
Requests an identifier specifying the exact type of action that was performed.- Returns:
- a subclass specific identifier
-
getWhen
public long getWhen()
State whens the event has been generated, a timestamp specifying system time millisecs as returned bySystem.currentTimeMillis().- Returns:
- time when the event was generated
-
incorporate
public abstract boolean incorporate(BasicEvent oldEvent)
Asks the event to incorporate the action described by another (older) event. This method has been created to reduce overhead; when many events are added to the event queue of an ELM, this allows to fuse two adjectant events. The idea is mainly based on thereplaceEdit()method of thejavax.swing.undo.UndoableEditinterface; a pendant of a symmetricaddEdit()like method is not provided because it seems to be unnecessary.Implementation notes : the
oldEventshould generally only be incorporated if it refers to the same source object (getSource()) and has the same ID (getD()). the timestamp of the current event should not be modified.- Parameters:
oldEvent- the most recent event in the queue which might be incorporated by this new event.- Returns:
trueif this object was able to incorporate the older event. in this case theoldEventis removed from the event queue.falsestates that theoldEventwas incompatible and should remain in the queue.- See Also:
UndoableEdit.replaceEdit( UndoableEdit )
-
-