com.miginfocom.ashape.interaction
Class StaticInteractor

java.lang.Object
  extended by com.miginfocom.ashape.interaction.StaticInteractor
All Implemented Interfaces:
Interactor, PropertyProvider
Direct Known Subclasses:
CategoryStaticInteractor, SimpleOverrider

public abstract class StaticInteractor
extends java.lang.Object
implements Interactor

A base class for static interactors that only provide a notion of being a simple overrider of static things. For instance an object that translates text templates (E.g. "$startTime$") to some object.


Field Summary
 
Fields inherited from interface com.miginfocom.ashape.interaction.Interactor
TEMPLATE_CHAR
 
Constructor Summary
StaticInteractor()
           
 
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.
 boolean containsProperty(PropertyKey property)
          Return if the provider contains the property.
 java.util.ArrayList getInteractions()
          Returns the interactions.
 java.lang.Object getProperty(PropertyKey property)
          Returns the property for a name.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.miginfocom.ashape.interaction.Interactor
getInteracted, getInteractionBroker, getOverride, getOverrideById
 

Constructor Detail

StaticInteractor

public StaticInteractor()
Method Detail

addInteraction

public final void addInteraction(Interaction interaction)
Description copied from interface: Interactor
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.

Specified by:
addInteraction in interface Interactor
Parameters:
interaction - The interaction to add-

getInteractions

public final java.util.ArrayList getInteractions()
Description copied from interface: Interactor
Returns the interactions. Note, this is the live collection.

Specified by:
getInteractions in interface Interactor
Returns:
The interactions, never null.

isOverridden

public final boolean isOverridden(java.lang.String target,
                                  PropertyKey property)
Description copied from interface: Interactor
Returns if the propName for target is currently overridden or not.

Specified by:
isOverridden in interface Interactor
Parameters:
target - The target for the command. Up to the implementation to interpret.
property - The property that should be checked

processEvent

public final void processEvent(java.awt.event.InputEvent e)
Description copied from interface: Interactor
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.

Specified by:
processEvent in interface Interactor
Parameters:
e - The event, not null.

addOverride

public void addOverride(java.lang.String target,
                        PropertyKey property,
                        java.lang.Object id,
                        java.lang.Object o)
Description copied from interface: Interactor
Adds an object to the override map. Replaces if id exists.

Specified by:
addOverride in interface Interactor
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

public void removeOverride(java.lang.String target,
                           PropertyKey property,
                           java.lang.Object id)
Description copied from interface: Interactor
Removes an object from the override map.

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

Specified by:
removeOverride in interface Interactor
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.

removeInteraction

public final Interaction removeInteraction(Interaction interaction)
Description copied from interface: Interactor
Removes an interaction.

Specified by:
removeInteraction in interface Interactor
Parameters:
interaction - The interaction to remove.
Returns:
The interaction that was removed or null if nothing was changed.

getProperty

public java.lang.Object getProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Returns the property for a name.

Specified by:
getProperty in interface PropertyProvider
Parameters:
property - The property key for the property to return. Not null.
Returns:
The value, may be null.

containsProperty

public boolean containsProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Return if the provider contains the property.

Specified by:
containsProperty in interface PropertyProvider
Parameters:
property - The property key. Not null.
Returns:
If the provider contains the property.

addOverrideListener

public void addOverrideListener(java.beans.PropertyChangeListener l)
Description copied from interface: Interactor
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.

Specified by:
addOverrideListener in interface Interactor
Parameters:
l - The listener to add

addOverrideListener

public void addOverrideListener(java.beans.PropertyChangeListener l,
                                boolean asWeakRef)
Description copied from interface: Interactor
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.

Specified by:
addOverrideListener in interface Interactor
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

public void removeOverrideListener(java.beans.PropertyChangeListener l)
Description copied from interface: Interactor
Removes the listener.

Specified by:
removeOverrideListener in interface Interactor
Parameters:
l - The listener to remove.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.