net.nexttext.behaviour.physics
Class StayInWindow

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.physics.PhysicsAction
          extended by net.nexttext.behaviour.physics.StayInWindow
All Implemented Interfaces:
Action

public class StayInWindow
extends PhysicsAction
implements Action

Keep objects inside a window.

By default, StayInWindow bounces objects off the edge of the visible window. It can be configured to change the window size and object behaviour.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
StayInWindow(processing.core.PApplet p)
          Creates a StayInWindow which constraints TextObjects to always remain within the bounds of the PApplet and to bounce off the edges.
StayInWindow(processing.core.PApplet p, boolean bounce)
          Creates a StayInWindow which constraints TextObjects to always remain within the bounds of the PApplet.
StayInWindow(java.awt.Rectangle bounds, boolean bounce)
          Creates a StayInWindow which constraints TextObjects to remain within the bounds of a specific rectangle.
 
Method Summary
 Action.ActionResult behave(TextObject to)
          Constraints the object so that it stays within the visible window.
 void setWindow(java.awt.Rectangle window)
          Redefines the window region to constraint objects to.
 
Methods inherited from class net.nexttext.behaviour.physics.PhysicsAction
applyAcceleration, applyAngularAcceleration, applyAngularForce, applyForce, getAngularVelocity, getMass, getRequiredProperties, getVelocity
 
Methods inherited from class net.nexttext.behaviour.AbstractAction
behave, behave, complete, getDisplayName, makeBehaviour, properties, setDisplayName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.nexttext.behaviour.Action
behave, behave, complete, getRequiredProperties
 

Constructor Detail

StayInWindow

public StayInWindow(processing.core.PApplet p)
Creates a StayInWindow which constraints TextObjects to always remain within the bounds of the PApplet and to bounce off the edges.

Parameters:
p - the parent PApplet

StayInWindow

public StayInWindow(processing.core.PApplet p,
                    boolean bounce)
Creates a StayInWindow which constraints TextObjects to always remain within the bounds of the PApplet.

Parameters:
p - the parent PApplet
bounce - Causes the objects to bounce off the edges if true or to stick to the edges if false.

StayInWindow

public StayInWindow(java.awt.Rectangle bounds,
                    boolean bounce)
Creates a StayInWindow which constraints TextObjects to remain within the bounds of a specific rectangle.

Parameters:
bounds - An arbitrary rectangle
bounce - Causes the objects to bounce off the edges if true or to stick to the edges if false.
Method Detail

setWindow

public void setWindow(java.awt.Rectangle window)
Redefines the window region to constraint objects to.


behave

public Action.ActionResult behave(TextObject to)
Constraints the object so that it stays within the visible window.

The returned ActionResult will include an event when the object encountered one of the window's edges.

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