com.miginfocom.ashape.interaction
Interface Interactor

All Superinterfaces:
PropertyProvider
All Known Implementing Classes:
AbstractInteractor, ActivityInteractor, CategoryStaticInteractor, GridRowInteractor, LabelOverrider, MouseKeyInteractor, SimpleOverrider, StaticInteractor, TimerInteractor

public interface Interactor
extends PropertyProvider

An interface that denotes interaction between the interacted and some other funtionality. Central interface to the interaction package.


Field Summary
static char TEMPLATE_CHAR
           
 
Method Summary
 void addInteraction(Interaction interaction)
          Adds an interaction.
 void addOverride(java.lang.String target, PropertyKey property, java.lang.Object id, java.lang.Object o)
          Adds an object to the override map.
 void addOverrideListener(java.beans.PropertyChangeListener l)
          Adds a listener that listens to InteractionEvents.
 void addOverrideListener(java.beans.PropertyChangeListener l, boolean asWeakRef)
          Adds a listener that listens to InteractionEvents.
 java.lang.Object getInteracted()
          Returns the object that this interactor is currently interacting with.
 InteractionBroker getInteractionBroker()
          Returns the interaction broker for this interactor.
 java.util.ArrayList getInteractions()
          Returns the interactions.
 java.lang.Object getOverride(java.lang.String name, PropertyKey property, java.lang.Object def)
          Returns an alternate object for an overriden name/propName combination.
 java.lang.Object getOverrideById(java.lang.Object id, java.lang.Object def)
          Returns the override for the id.
 boolean isOverridden(java.lang.String target, PropertyKey property)
          Returns if the propName for target is currently overridden or not.
 void processEvent(java.awt.event.InputEvent e)
          This is the entrance point for notifying the interactor of events (such as Mouse, MouseMotion and Key events).
 Interaction removeInteraction(Interaction interaction)
          Removes an interaction.
 void removeOverride(java.lang.String target, PropertyKey property, java.lang.Object id)
          Removes an object from the override map.
 void removeOverrideListener(java.beans.PropertyChangeListener l)
          Removes the listener.
 
Methods inherited from interface com.miginfocom.util.PropertyProvider
containsProperty, getProperty
 

Field Detail

TEMPLATE_CHAR

static final char TEMPLATE_CHAR
See Also:
Constant Field Values
Method Detail

getInteractionBroker

InteractionBroker getInteractionBroker()
Returns the interaction broker for this interactor. The broker is normally responsible for effectuating DefaultCommands.

Returns:
The interaction broker for this interactor. May be null if there is not broker.

getInteracted

java.lang.Object getInteracted()
Returns the object that this interactor is currently interacting with.

Returns:
The object that this interactor is currently interacting with. May be null.

getOverride

java.lang.Object getOverride(java.lang.String name,
                             PropertyKey property,
                             java.lang.Object def)
Returns an alternate object for an overriden name/propName combination.

Might for instance return a different color for a background. Normally an Interaction of some kind uses a DefaultCommand to set/reset/add/toggle/cucle an override.

If many overrides are added for the name/propName combination the last added will be returned.

Parameters:
name - Then name of the object (caller) that will be compared to the interaction's target.
property - The property key to return the override for. E.g. AShape.A_PAINT. Not null.
def - The object to return if no overrider is registered for name/propName combination.
Returns:
The new object to use. Might be null.

getOverrideById

java.lang.Object getOverrideById(java.lang.Object id,
                                 java.lang.Object def)
Returns the override for the id.

Parameters:
id - The id of the override to return. Not null.
def - The object to return if no overrider is registered for id.
Returns:
The new object to use. Might be null.

addOverride

void addOverride(java.lang.String target,
                 PropertyKey property,
                 java.lang.Object id,
                 java.lang.Object o)
Adds an object to the override map. Replaces if id exists.

Parameters:
target - The target for the command. Up to the implementation to interpret. Not null.
property - The name of the object that have the object to be overridden. Not null.
id - Id for the override. Not null. Id is uniqe so if an override with this id already exists it will first be removed.
o - The object. May be null, which is not same as NO override.

removeOverride

void removeOverride(java.lang.String target,
                    PropertyKey property,
                    java.lang.Object id)
Removes an object from the override map.

Note that removeOverrideObject(null, null, null) will remove all overrides.

Parameters:
target - The target that should have its override removed. If null should be equal to all targets.
property - The property that should have its override removed. If null should be equal to all propNames.
id - The id for the override to remove. If null should be equal to all id:s.

isOverridden

boolean isOverridden(java.lang.String target,
                     PropertyKey property)
Returns if the propName for target is currently overridden or not.

Parameters:
property - The property that should be checked
target - The target for the command. Up to the implementation to interpret.

addInteraction

void addInteraction(Interaction interaction)
Adds an interaction. No checking if the interaction already exists. Override to catch changes in the interaction list or to only add interactions that are of interest to the implementing class.

Parameters:
interaction - The interaction to add-

removeInteraction

Interaction removeInteraction(Interaction interaction)
Removes an interaction.

Parameters:
interaction - The interaction to remove.
Returns:
The interaction that was removed or null if nothing was changed.

getInteractions

java.util.ArrayList getInteractions()
Returns the interactions. Note, this is the live collection.

Returns:
The interactions, never null.

processEvent

void processEvent(java.awt.event.InputEvent e)
This is the entrance point for notifying the interactor of events (such as Mouse, MouseMotion and Key events). The interactor doesn't register itself for any events since this will make the interaction with the surrounding environment unpredictable. Therefore it is very important that this method be called for any relevant events. The caller can then check if the event was consumed and respond appropriately.
For instance a MouseEvent of type MouseEvent.MOUSE_PRESSED are dispatched to AbstractInteractor.mousePressed(java.awt.event.MouseEvent).
It is also possible to just add the Interactor as a listener for those events but then it there will be much less flexibility for the component that fires the events since it is impossible to know the order in which the listeners are notified.

Parameters:
e - The event, not null.

addOverrideListener

void addOverrideListener(java.beans.PropertyChangeListener l)
Adds a listener that listens to InteractionEvents. Interaction events are normally fired by the Interaction/Interactor/AbstractInteractionBroker framework, used for instance by the AShape framework.
This class is actually a re-dispatcher of these events. It is itself an InteractionListener and registers itself on the interaction observable objects it creates. For instance ActivityViews.

Parameters:
l - The listener to add

addOverrideListener

void addOverrideListener(java.beans.PropertyChangeListener l,
                         boolean asWeakRef)
Adds a listener that listens to InteractionEvents. Interaction events are normally fired by the Interaction/Interactor/AbstractInteractionBroker framework, used for instance by the AShape framework.

Parameters:
l - The listener to add
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

removeOverrideListener

void removeOverrideListener(java.beans.PropertyChangeListener l)
Removes the listener.

Parameters:
l - The listener to remove.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.