net.nexttext.behaviour.control
Class OnDrag

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.control.Condition
          extended by net.nexttext.behaviour.control.OnDrag
All Implemented Interfaces:
Action, Locatable

public class OnDrag
extends Condition
implements Locatable

A Condition which is true when the TextObject is being dragged by the mouse.

It implements the Locatable interface which returns the location of the mouse offset by the vector between the mouse and the TextObject when the drag started. If the TextObject is moved to this position it is like dragging it with the mouse. The position is that of the last TextObject which was dragged, so it's only appropriate to use this Locatable in the true condition of OnDrag.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
OnDrag(Action trueAction)
          Creates an OnDrag which performs the given Action when the mouse button 1 is pressed.
OnDrag(Action trueAction, Action falseAction)
          Creates an OnDrag which performs one of the given Actions, depending on whether or not the mouse button 1 is pressed.
OnDrag(int buttonToCheck, Action trueAction)
          Creates an OnDrag which performs the given Action when the selected mouse button is pressed.
OnDrag(int buttonToCheck, Action trueAction, Action falseAction)
          Creates an OnDrag which performs one of the given Actions, depending on whether or not the selected mouse button is pressed.
 
Method Summary
 boolean condition(TextObject to)
          Checks whether or not the selected mouse button is pressed over the given TextObject.
 processing.core.PVector getLocation()
          Gets the target position of the dragged TextObject, if it would follow the mouse.
 
Methods inherited from class net.nexttext.behaviour.control.Condition
behave, complete, getRequiredProperties
 
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

OnDrag

public OnDrag(Action trueAction)
Creates an OnDrag which performs the given Action when the mouse button 1 is pressed.

Parameters:
trueAction - the Action to perform when the mouse button 1 is pressed

OnDrag

public OnDrag(Action trueAction,
              Action falseAction)
Creates an OnDrag which performs one of the given Actions, depending on whether or not the mouse button 1 is pressed.

Parameters:
trueAction - the Action to perform when the mouse button 1 is pressed
falseAction - the Action to perform when the mouse button 1 is released

OnDrag

public OnDrag(int buttonToCheck,
              Action trueAction)
Creates an OnDrag which performs the given Action when the selected mouse button is pressed.

Parameters:
buttonToCheck - the mouse button to consider
trueAction - the Action to perform when the selected mouse button is pressed

OnDrag

public OnDrag(int buttonToCheck,
              Action trueAction,
              Action falseAction)
Creates an OnDrag which performs one of the given Actions, depending on whether or not the selected mouse button is pressed.

Parameters:
buttonToCheck - the mouse button to consider
trueAction - the Action to perform when the selected mouse button is pressed
falseAction - the Action to perform when the selected mouse button is released
Method Detail

condition

public boolean condition(TextObject to)
Checks whether or not the selected mouse button is pressed over the given TextObject.

Specified by:
condition in class Condition
Parameters:
to - the TextObject to consider
Returns:
the outcome of the condition

getLocation

public processing.core.PVector getLocation()
Gets the target position of the dragged TextObject, if it would follow the mouse.

Specified by:
getLocation in interface Locatable
Returns:
the target position of the TextObject