net.nexttext.behaviour.control
Class Condition

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.control.Condition
All Implemented Interfaces:
Action
Direct Known Subclasses:
IsInside, OnButtonDepressed, OnDrag, OnMouseDepressed, OnMouseOver, OnMouseOverApplet

public abstract class Condition
extends AbstractAction

A Condition splits the data flow in two according to the result of the abstract condition() method.

If the condition was evaluated to true, then it will apply the trueAction otherwise it will apply the falseAction.

TODO: Handle object pairs, object arrays.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
Condition(Action trueAction, Action falseAction)
           
 
Method Summary
 Action.ActionResult behave(TextObject to)
          Applies the trueAction if the result of condition() is true and applies the falseAction otherwise.
 void complete(TextObject to)
          The Action has ended, pass it on to both sub-actions.
abstract  boolean condition(TextObject to)
           
 java.util.Map<java.lang.String,Property> getRequiredProperties()
          The properties that this action requires on a TextObject.
 
Methods inherited from class net.nexttext.behaviour.AbstractAction
behave, behave, getDisplayName, makeBehaviour, properties, setDisplayName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition(Action trueAction,
                 Action falseAction)
Method Detail

condition

public abstract boolean condition(TextObject to)
Returns:
the outcome of the condition.

behave

public Action.ActionResult behave(TextObject to)
Applies the trueAction if the result of condition() is true and applies the falseAction otherwise.

Specified by:
behave in interface Action
Overrides:
behave in class AbstractAction
Returns:
the result of the Action that was applied.

complete

public void complete(TextObject to)
The Action has ended, pass it on to both sub-actions.

Specified by:
complete in interface Action
Overrides:
complete in class AbstractAction

getRequiredProperties

public java.util.Map<java.lang.String,Property> getRequiredProperties()
Description copied from class: AbstractAction
The properties that this action requires on a TextObject.

Right now this method always returns an empty map, since basic Actions should be restricted to use only the core set of TextObject properties.

If a subclass of Action requires a set of additional properties then it should override this method and return the appropriate Map containing the property objects.

This method is required by the Action interface.

Specified by:
getRequiredProperties in interface Action
Overrides:
getRequiredProperties in class AbstractAction