com.miginfocom.ashape.interaction
Class MouseInteractionEvent

java.lang.Object
  extended by java.util.EventObject
      extended by com.miginfocom.ashape.interaction.MouseInteractionEvent
All Implemented Interfaces:
java.io.Serializable

public class MouseInteractionEvent
extends java.util.EventObject

An event that encapsulates every known detail of a mouse interaction. The infomation that this event holds is vast. You can with this event know exactly what part of an AShape (which sub shape) was mouse-overed and what (for instance) ActivityView was interacted with.

Here is some sample code showing how to change the outline color for the standard AShape gotten from AShapeUtil.createDefault(int) during a mouse-over:

defaultAShape.addMouseListener(new MouseInteractionListener() {
        public void mouseInteracted(MouseInteractionEvent e) {

                if (e.getEventKey() == MouseKeyInteractor.MOUSE_OVER_CHANGE) {
                        String shapeName = AShapeUtil.DEFAULT_OUTLINE_SHAPE_NAME;
                        if (e.isShapeInList(shapeName, MouseKeyInteractor.PROP_MOUSE_OVER_LIST)) {
                                e.getMouseKeyInteractor().addOverride(shapeName, AShape.A_PAINT, "myid", Color.RED);
                        } else {
                                e.getMouseKeyInteractor().removeOverrideById("myid");
                        }
                }
        }
});
 

Since:
6.0
See Also:
Serialized Form

Field Summary
static int LEVEL_ABORT_PROCESSING
          The event is marked as handleded and will not continue to generate the automatic interactions events that are installed on the MouseKeyInteractor.
static int LEVEL_HANDELED
          The event is marked as handleded but the event notifications will be continued as normal.
static int LEVEL_NO_INTERACTIONS
          The event is marked as handleded and will not continue to generate the automatic interactions events that are installed on the MouseKeyInteractor.
static int LEVEL_NOT_CONSUMED
          The event is not consumed in any way.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
MouseInteractionEvent(java.awt.event.MouseEvent originalEvent, MouseKeyInteractor mouseKeyInteractor, PropertyKey eventKey)
          Constructor.
 
Method Summary
 int getConsumeLevel()
          Returns the level at which this event has been consumed.
 PropertyKey getEventKey()
          What type of event that this is.
 MouseKeyInteractor getMouseKeyInteractor()
          Returns the MouseKeyInteractor that holds the information about a great deal of things connected to what exact shape was interacted with and for instance what object it was decorating (normally an ActivityView).
 java.awt.event.MouseEvent getOriginalEvent()
          The original event that started this interaction event.
 boolean isShapeInList(java.lang.String name, PropertyKey listKey)
          Returns if the the AShape named "name" is in the list denoted by listKey in the MouseKeyInteractor.
 void raiseConsumeLevel(int newLevel)
          The listener can only raise the level of how "much" this event has been consumed.
 java.lang.String toString()
           
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEVEL_NOT_CONSUMED

public static final int LEVEL_NOT_CONSUMED
The event is not consumed in any way. This is the base level.

See Also:
Constant Field Values

LEVEL_HANDELED

public static final int LEVEL_HANDELED
The event is marked as handleded but the event notifications will be continued as normal.

See Also:
Constant Field Values

LEVEL_NO_INTERACTIONS

public static final int LEVEL_NO_INTERACTIONS
The event is marked as handleded and will not continue to generate the automatic interactions events that are installed on the MouseKeyInteractor. Listeners will all be notified though.

See Also:
Constant Field Values

LEVEL_ABORT_PROCESSING

public static final int LEVEL_ABORT_PROCESSING
The event is marked as handleded and will not continue to generate the automatic interactions events that are installed on the MouseKeyInteractor. When this listeners has been notified no more listeners will be notified and thus the notification chain will be aborted.

See Also:
Constant Field Values
Constructor Detail

MouseInteractionEvent

public MouseInteractionEvent(java.awt.event.MouseEvent originalEvent,
                             MouseKeyInteractor mouseKeyInteractor,
                             PropertyKey eventKey)
Constructor.

Parameters:
originalEvent - See getOriginalEvent()
mouseKeyInteractor - See getMouseKeyInteractor()
eventKey - See getEventKey().
Method Detail

getEventKey

public PropertyKey getEventKey()
What type of event that this is. One of:
MouseKeyInteractor.MOUSE_ENTER
MouseKeyInteractor.MOUSE_EXIT
MouseKeyInteractor.MOUSE_OVER_CHANGE
MouseKeyInteractor.MOUSE_OVER_TOPMOST_CHANGE
MouseKeyInteractor.MOUSE_PRESS
MouseKeyInteractor.MOUSE_RELEASE
MouseKeyInteractor.MOUSE_POPUP_TRIGGER
MouseKeyInteractor.MOUSE_CLICK
MouseKeyInteractor.MOUSE_DOUBLE_CLICK
MouseKeyInteractor.MOUSE_DRAG
MouseKeyInteractor.MOUSE_MOVE

Returns:
The key. E.g. MouseKeyInteractor.MOUSE_CLICK.

getMouseKeyInteractor

public MouseKeyInteractor getMouseKeyInteractor()
Returns the MouseKeyInteractor that holds the information about a great deal of things connected to what exact shape was interacted with and for instance what object it was decorating (normally an ActivityView).

You can use this interactor to install overrides that will change the appearence for the AShape only for that instance. There is code in the class JavaDoc for this.

Note that there are several lists that are updated with the names of the current shapes or sub shapes that corresponds to the event. For instance the MouseKeyInteractor.PROP_MOUSE_OVER_LIST key can be used to get a list of names (String) that the mouse is currently over (given that those sub shapes report their hit areas. See AShape.A_REPORT_HIT_AREA.

Use:

        MouseKeyInteractor inter = e.getMouseKeyInteractor();
        java.util.List moList = (java.util.List) inter.getProperty(MouseKeyInteractor.PROP_MOUSE_OVER_LIST);
 
to get the list.

Returns:
The interactor associated with the AShape.

getOriginalEvent

public java.awt.event.MouseEvent getOriginalEvent()
The original event that started this interaction event. Note that the ID of it might not the exactly what is expected. For instance MouseEvent.MOUSE_MOVED might have spurred an MouseKeyInteractor.MOUSE_ENTER and a MouseKeyInteractor.MOUSE_OVER_CHANGE event.

Returns:
The original event. Not null.

getConsumeLevel

public int getConsumeLevel()
Returns the level at which this event has been consumed. One of:
LEVEL_NOT_CONSUMED, LEVEL_HANDELED, LEVEL_NO_INTERACTIONS and LEVEL_ABORT_PROCESSING.

Returns:
The level at which this event has been consumed.

raiseConsumeLevel

public void raiseConsumeLevel(int newLevel)
The listener can only raise the level of how "much" this event has been consumed. The levels are (in order):
LEVEL_NOT_CONSUMED, LEVEL_HANDELED, LEVEL_NO_INTERACTIONS and LEVEL_ABORT_PROCESSING.

Parameters:
newLevel - The new level. If less than or equal to the current level nothing will be changed.

isShapeInList

public boolean isShapeInList(java.lang.String name,
                             PropertyKey listKey)
Returns if the the AShape named "name" is in the list denoted by listKey in the MouseKeyInteractor.

This is a convenience method for:

        java.util.List moList = (java.util.List) getMouseKeyInteractor().getProperty(listKey);
        return moList != null && moList.contains(name);

Parameters:
name - The name of the shape or sub-shape.
listKey - The key that denotes the list to check. E.g. MouseKeyInteractor.PROP_MOUSE_OVER_LIST.
Returns:
If the the AShape named "name" is in the list denoted by listKey in the MouseKeyInteractor.

toString

public java.lang.String toString()
Overrides:
toString in class java.util.EventObject


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.