com.miginfocom.ashape.interaction
Class MouseInteractionListener

java.lang.Object
  extended by com.miginfocom.ashape.interaction.MouseInteractionListener
All Implemented Interfaces:
SortableListener, java.util.EventListener

public abstract class MouseInteractionListener
extends java.lang.Object
implements java.util.EventListener, SortableListener

A listner that listens for mouse events on an AShape. It has a single method for all interactions, let they be mouse move events or mouse clicks.

Supports sorted listener lists.

See MouseInteractionEvent for sample code on how this listener can be used.

Since:
6.0

Constructor Summary
protected MouseInteractionListener()
          Constructor that defaults to order 0.
protected MouseInteractionListener(int order)
          Constructor.
 
Method Summary
 int getOrder()
          Return the current order.
abstract  void mouseInteracted(MouseInteractionEvent e)
          Called when the interaction occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseInteractionListener

protected MouseInteractionListener()
Constructor that defaults to order 0.


MouseInteractionListener

protected MouseInteractionListener(int order)
Constructor.

Parameters:
order - An interger that will be used for sorting if multiple listeners are added to the same target. A lower value means that it will be notified before listeners with higher numbers.
Method Detail

getOrder

public int getOrder()
Description copied from interface: SortableListener
Return the current order.

Specified by:
getOrder in interface SortableListener
Returns:
An integer that will be used for sorting if multiple listeners are added to the same target. A lower value means that it will be notified before listeners with higher numbers.

mouseInteracted

public abstract void mouseInteracted(MouseInteractionEvent e)
Called when the interaction occurs.

Example code for changing outline color to red:

 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");
         }
 }

Parameters:
e - The event. Never null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.