|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.event.ZMouseFilter
ZMouseFilter is used by ZFilteredEventHandler to filter (accept or reject) mouse events. It is intended to separate event test code from event handlers so that it's easy to change the events that drive a event handlers behavior without needing to subclass or modifying the event handler.
An events type, click count, and modifier field can be used to filter the event. The filter can optionally consume any events that it accepts. This consuming behavior is off by default.
// ZMouseFilter examples.
ZMouseFilter filter = new ZMouseFilter();
// A new filter accepts all events.
filter.setAndMask(InputEvent.BUTTON1_MASK);
// The filter will now only accept events that have the button1 modifier
filter.setNotMask(InputEvent.SHIFT_MASK);
// The filter will now only accept events that have the button1 modifier
// and do not have the shift modifier.
filter.rejectAllEventTypes();
// The filter will now reject all events based on the type of the event. The
// andMask and notMask set previously are still preserved.
filter.setAcceptsMousePressed(true);
// The filter will now only accept mouse pressed events
// that have the button1 modifier
// and do not have the shift modifier.
filter.setAndMask(0); // don't require any modifiers for acceptance.
filter.setNotMask(0); // don't reject on the presence of any modifiers.
filter.acceptAllEventTypes(); // don't reject based on event type.
filter.setOrMask(InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK);
// The filter will now accept any event that has either the button1 modifier or
// the button2 modifier or both.
filter.setOrMask(ALL_MODIFIERS_MASK);
// The filter will now accept all events once again.
ZFilteredEventHandler
Field Summary | |
static int |
ALL_MODIFIERS_MASK A mask containing all modifiers. |
Constructor Summary | |
ZMouseFilter() Constructs a new ZMouseFilter that accepts all events. |
|
ZMouseFilter(int aAndMask) Constructs a new ZMouseFilter that accepts only events that have all the modifiers that are specified in the AND mask parameter. |
|
ZMouseFilter(int aAndMask, int aNotMask) Constructs a new ZMouseFilter that accepts only events that have all the modifiers that are specified in the AND mask parameter, and none of the modifiers specified in the NOT mask parameter. |
Method Summary | |
boolean |
accept(ZMouseEvent aEvent) Return true if the event should be accepted, false if it should not. |
void |
acceptAllClickCounts() Make it so that this event filter accepts all click counts. |
void |
acceptAllEventTypes() Make the filter accept all event types. |
void |
acceptEverything() Make the filter accept all events. |
boolean |
getAcceptsMouseClicked() Returns true if the filter is accepting mouse clicked events. |
boolean |
getAcceptsMouseDragged() Returns true if the filter is accepting mouse dragged events. |
boolean |
getAcceptsMouseEntered() Returns true if the filter is accepting mouse entered events. |
boolean |
getAcceptsMouseExited() Returns true if the filter is accepting mouse exited events. |
boolean |
getAcceptsMouseMoved() Returns true if the filter is accepting mouse moved events. |
boolean |
getAcceptsMousePressed() Returns true if the filter is accepting mouse pressed events. |
boolean |
getAcceptsMouseReleased() Returns true if the filter is accepting mouse released events. |
boolean |
getConsumes() Returns true if this event filter consumes accepted events. |
void |
rejectAllClickCounts() Make it so that this event filter rejects all click counts. |
void |
rejectAllEventTypes() Make the filter reject all event types. |
void |
setAcceptClickCount(short aClickCount) Set the click count to be accepted. |
void |
setAcceptsMouseClicked(boolean aBoolean) Set if the filter is accepting mouse clicked events. |
void |
setAcceptsMouseDragged(boolean aBoolean) Set if the filter is accepting mouse dragged events. |
void |
setAcceptsMouseEntered(boolean aBoolean) Set if the filter is accepting mouse entered events. |
void |
setAcceptsMouseExited(boolean aBoolean) Set if the filter is accepting mouse exited events. |
void |
setAcceptsMouseMoved(boolean aBoolean) Set if the filter is accepting mouse moved events. |
void |
setAcceptsMousePressed(boolean aBoolean) Set if the filter is accepting mouse pressed events. |
void |
setAcceptsMouseReleased(boolean aBoolean) Set if the filter is accepting mouse released events. |
void |
setAndMask(int aAndMask) Set the AND bitmask. |
void |
setConsumes(boolean aBoolean) Make it so that this event filter consumes all events that it accepts. |
void |
setNotMask(int aNotMask) Set the NOT bitmask. |
void |
setOrMask(int aOrMask) Set the OR bitmask. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int ALL_MODIFIERS_MASK
Constructor Detail |
public ZMouseFilter()
public ZMouseFilter(int aAndMask)
aAndMask
- a bitmask specifying the flags that must be present for the event to be accepted.public ZMouseFilter(int aAndMask, int aNotMask)
aAndMask
- a bitmask specifying the flags that must be present for the event to be accepted.aNotMask
- a bitmask specifying the flags that must not be present for the event to be accepted.Method Detail |
public void setAndMask(int aAndMask)
aAndMask
- a bitmask specifying the flags that must be present for the event to be accepted.public void setOrMask(int aOrMask)
aOrMask
- a bitmask specifying the OR flags, at least one must be present in an event for the event to be accepted by the filter.public void setNotMask(int aNotMask)
aNotMask
- a bitmask specifying the flags that must not be present for the event to be accepted.public void setAcceptClickCount(short aClickCount)
aClickCount
- the click count required of an event for it to be accepted.public void acceptAllClickCounts()
public void rejectAllClickCounts()
public void setConsumes(boolean aBoolean)
aBoolean
- true if this filter consumes accepted events.public boolean getConsumes()
public boolean getAcceptsMouseClicked()
public void setAcceptsMouseClicked(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse clicked events.public boolean getAcceptsMouseEntered()
public void setAcceptsMouseEntered(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse entered events.public boolean getAcceptsMouseExited()
public void setAcceptsMouseExited(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse exited events.public boolean getAcceptsMousePressed()
public void setAcceptsMousePressed(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse pressed events.public boolean getAcceptsMouseReleased()
public void setAcceptsMouseReleased(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse released events.public boolean getAcceptsMouseDragged()
public void setAcceptsMouseDragged(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse dragged events.public boolean getAcceptsMouseMoved()
public void setAcceptsMouseMoved(boolean aBoolean)
aBoolean
- true if the filter is accepting mouse moved events.public void rejectAllEventTypes()
public void acceptAllEventTypes()
public void acceptEverything()
public boolean accept(ZMouseEvent aEvent)
If the event is accepted and this filter is consuming then this method will consume the event.
aEvent
- the event under consideration by the filter.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |