com.miginfocom.ashape.interaction
Class SimpleOverrider

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

public abstract class SimpleOverrider
extends StaticInteractor

A simple Interactor that overrides some property for a sub shape (identified by name). Just overide getOverride(Object).


Field Summary
 
Fields inherited from interface com.miginfocom.ashape.interaction.Interactor
TEMPLATE_CHAR
 
Constructor Summary
SimpleOverrider(java.lang.String name, PropertyKey property)
          Constructor.
 
Method Summary
abstract  java.lang.Object getOverride(java.lang.Object def)
          Override this method and return the overridden object If it should be overridden.
 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)
          We doesn't store id here.
 
Methods inherited from class com.miginfocom.ashape.interaction.StaticInteractor
addInteraction, addOverride, addOverrideListener, addOverrideListener, containsProperty, getInteractions, getProperty, isOverridden, processEvent, removeInteraction, removeOverride, removeOverrideListener
 
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
 

Constructor Detail

SimpleOverrider

public SimpleOverrider(java.lang.String name,
                       PropertyKey property)
Constructor.

Parameters:
name - getOverride will only be called for shapes/sub shapes with this name
property - getOverride will only be called for this property. E.g. AShape.A_PAINT.
Method Detail

getOverride

public java.lang.Object getOverride(java.lang.String name,
                                    PropertyKey property,
                                    java.lang.Object def)
Description copied from interface: Interactor
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

public java.lang.Object getOverrideById(java.lang.Object id,
                                        java.lang.Object def)
We doesn't store id here. Always returns def.

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.

getOverride

public abstract java.lang.Object getOverride(java.lang.Object def)
Override this method and return the overridden object If it should be overridden. Otherwise return def.

Parameters:
def - The default object to return if there is no override under current conditions.
Returns:
The new object or def if no override


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.