com.miginfocom.ashape.interaction
Class DefaultInteractionBroker

java.lang.Object
  extended by com.miginfocom.ashape.interaction.AbstractInteractionBroker
      extended by com.miginfocom.ashape.interaction.DefaultInteractionBroker
All Implemented Interfaces:
InteractionBroker
Direct Known Subclasses:
GridRowInteractionBroker

public class DefaultInteractionBroker
extends AbstractInteractionBroker

A default broker of DefaultCommands.

The commands handles are the static Strings starting with CMD_.


Field Summary
static PropertyKey CMD_ADD_OVERRIDE
          Sets an override.
static PropertyKey CMD_ANIMATOR_CONTROL
          Sends control commands to an Animator.
static PropertyKey CMD_CONSUME
          Consumes the mouse event so that it doesn't get redispatched to the underlying JComonent.
static PropertyKey CMD_CYCLE_OVERRIDE
          Cycle override value between a number of objects.
static PropertyKey CMD_FIRE_INTERACTION_EVENT
          Fires an InteractionEvent if the sent in JComponent implements InteractionListener.
static PropertyKey CMD_REMOVE_OVERRIDE
          Removes the overrided object so it is no longer overridden.
static PropertyKey CMD_SET_CURSOR
          A command to set a new cursor.
static PropertyKey CMD_SET_CURSOR_FROM_ASHAPE
          A command to set a new cursor retrieved from the arguments in the DefaultCommand.
static PropertyKey CMD_SET_OVERRIDE
          Add an override.
static PropertyKey CMD_TOGGLE_OVERRIDE
          Toggles the override on/off.
 
Constructor Summary
DefaultInteractionBroker(javax.swing.JComponent comp, InteractionListener iListener)
          Constructor
DefaultInteractionBroker(javax.swing.JComponent comp, InteractionListener[] iListeners)
          Constructor
 
Method Summary
 javax.swing.JComponent getComponent()
          Returns the component to use for interactions
 boolean handleCommand(Interactor interactor, Command cmd, java.awt.event.InputEvent e)
          Handels one command.
 
Methods inherited from class com.miginfocom.ashape.interaction.AbstractInteractionBroker
handleCommands
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CMD_SET_CURSOR_FROM_ASHAPE

public static final PropertyKey CMD_SET_CURSOR_FROM_ASHAPE
A command to set a new cursor retrieved from the arguments in the DefaultCommand.

DefaultCommand.propertyNameThe property name used to get a java.util.List of AShape names from the given Interactor (via the PropertyProvider interface).
The first one of these ahsapes that has a non-null AShape.A_MOUSE_CURSOR set will be providing that cursor to be set in the JComponent that the ActivityView resides in.
It is normally one of MouseKeyInteractor.PROP_MOUSE_MOVE_LIST, MouseKeyInteractor.PROP_MOUSE_DRAG_LIST or MouseKeyInteractor.PROP_MOUSE_OVER_LIST. DefaultCommand.value A RootAShape that contains the ashapes that has cursors set. DefaultCommand.target Not used.

See Also:
Cursor, GfxUtil.getCursor(Object), AShape.A_MOUSE_CURSOR

CMD_SET_CURSOR

public static final PropertyKey CMD_SET_CURSOR
A command to set a new cursor.

DefaultCommand.propertyName Not used. DefaultCommand.value The cursor to set. Can be a Cursor, String, Integer or null. Interpreted by Cursor. DefaultCommand.target Not used.

See Also:
Cursor, CMD_SET_CURSOR_FROM_ASHAPE, GfxUtil.getCursor(Object)

CMD_ADD_OVERRIDE

public static final PropertyKey CMD_ADD_OVERRIDE
Sets an override. An overrider if a value that is supposed to override another value.

What differs this from CMD_SET_OVERRIDE is that this will add the override, effectively 'hiding' any other set for the name/target combination. The last added override will be the effective one.

Note that the Interactor.getOverride(java.lang.String, com.miginfocom.util.PropertyKey, java.lang.Object) has to be called to get which objects that are overridden. AbstractInteractor.getOverride(java.lang.String, PropertyKey, java.lang.Object) calls this method.

When setting an override as a result of some trigger/condition that override isn't automatically removed when that condition isn't true anymore. Normally an intraction that removes the override has to be registered as well.

DefaultCommand.propertyName is the TYPE of value to override. It is to the interpreter to interpret this value. E.g. AShape.A_PAINT.
DefaultCommand.value the new value.
DefaultCommand.target the target name to set the override for.

See Also:
CMD_REMOVE_OVERRIDE

CMD_SET_OVERRIDE

public static final PropertyKey CMD_SET_OVERRIDE
Add an override. An overrider if a value that is supposed to override another value.

What differs this from CMD_ADD_OVERRIDE is that this command will first remove any overrides for the name/target combination, making this the only override.

Note that the Interactor.getOverride(java.lang.String, com.miginfocom.util.PropertyKey, java.lang.Object) has to be called to get which objects that are overridden. AbstractInteractor.getOverride(java.lang.String, PropertyKey, java.lang.Object) calls this method.

When setting an override as a result of some trigger/condition that override isn't automatically removed when that condition isn't true anymore. Normally an intraction that removes the override has to be registered as well.

DefaultCommand.propertyName is the TYPE of value to override. It is to the interpreter to interpret this value. E.g. AShape.A_PAINT.
DefaultCommand.value the new value.
DefaultCommand.target the target name to set the override for.

See Also:
CMD_REMOVE_OVERRIDE

CMD_REMOVE_OVERRIDE

public static final PropertyKey CMD_REMOVE_OVERRIDE
Removes the overrided object so it is no longer overridden.

DefaultCommand.propertyName The override type to remove. If null all names are considered a 'hit'.
DefaultCommand.value Optional ID for the override to remove. If null all IDs are considered a 'hit'.
DefaultCommand.target the target name to remove the override for If null all targets are considered a 'hit'.

See Also:
CMD_ADD_OVERRIDE

CMD_TOGGLE_OVERRIDE

public static final PropertyKey CMD_TOGGLE_OVERRIDE
Toggles the override on/off.

DefaultCommand.propertyName The override type to toggle.
DefaultCommand.value the value to use if toggling "on".
DefaultCommand.target the target name to toggle the override for.

See Also:
CMD_ADD_OVERRIDE

CMD_CYCLE_OVERRIDE

public static final PropertyKey CMD_CYCLE_OVERRIDE
Cycle override value between a number of objects.

DefaultCommand.propertyName The override type to toggle.
DefaultCommand.value A List of object to cycle. MUST contain at least one object and not null!
DefaultCommand.target the target name to cycle the override for.

See Also:
CMD_ADD_OVERRIDE

CMD_ANIMATOR_CONTROL

public static final PropertyKey CMD_ANIMATOR_CONTROL
Sends control commands to an Animator.

DefaultCommand.propertyNameThe name of the Animator to control.
DefaultCommand.valueThe command sent to the Animator. E.g. OverrideAnimator.FORWARD
DefaultCommand.target the target name to animate.


CMD_FIRE_INTERACTION_EVENT

public static final PropertyKey CMD_FIRE_INTERACTION_EVENT
Fires an InteractionEvent if the sent in JComponent implements InteractionListener.

DefaultCommand.propertyName valuePair is set in the InteractionEvent. DefaultCommand.value valuePair is set in the InteractionEvent. DefaultCommand.target Stored in the InteractionEvent for use by the listener.


CMD_CONSUME

public static final PropertyKey CMD_CONSUME
Consumes the mouse event so that it doesn't get redispatched to the underlying JComonent.

DefaultCommand.propertyName is not used.
DefaultCommand.value is not used.
DefaultCommand.target is not used.

Constructor Detail

DefaultInteractionBroker

public DefaultInteractionBroker(javax.swing.JComponent comp,
                                InteractionListener iListener)
Constructor

Parameters:
comp - The component to use for setting new cursors among other things. Will be kept in a WeakReference and might be null.
iListener - The listener to InteractionEvents. Will be kept in a WeakReference and might be null.
See Also:
getComponent()

DefaultInteractionBroker

public DefaultInteractionBroker(javax.swing.JComponent comp,
                                InteractionListener[] iListeners)
Constructor

Parameters:
comp - The component to use for setting new cursors among other things. Will be kept in a WeakReference and might be null.
iListeners - The listeners to InteractionEvents. Will be kept in WeakReferences and might be null.
See Also:
getComponent()
Method Detail

handleCommand

public boolean handleCommand(Interactor interactor,
                             Command cmd,
                             java.awt.event.InputEvent e)
Description copied from class: AbstractInteractionBroker
Handels one command.

Specified by:
handleCommand in class AbstractInteractionBroker
Parameters:
interactor - The interactor the the interaction originated from
cmd - The command that is to be executed
e - The event that started the interaction, if any.
Returns:
IF the command was handled.

getComponent

public javax.swing.JComponent getComponent()
Returns the component to use for interactions

Returns:
The component to use for interactions. Can be null anytime since the reference is kept in a WeakReference


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.