world
Class BigBang

java.lang.Object
  extended by world.BigBang

public class BigBang
extends java.lang.Object

A Class representing the creation of a World/System of some type, and the related methods and Function Objects (call-backs) for drawing the world and handling various events. As handlers are installed, each is checked for a corresponding apply method with the appropriate signature.

The initial value of the World assigns a (minimum) type, which is used to search/check all of the handlers. Functions that produce a world deserve special attention, since they may return a super-type of the initial World (e.g., initial EmptyScene, with an tick handler that returns a Scene). The name and types of handlers are given in the table below:

Event NameBigBang MethodHandler SignatureRequired?
OnDrawonDraw(handler)Scene apply(World w)yes
OnTickonTick(handler) or
onTick(handler, double)
World apply(World w)no
OnMouseonMouse(handler)World apply(World w, int x, int y, String what)no
OnKeyonKey(handler)World apply(World w, String key)no
OnReleaseonRelease(handler)World apply(World w, String key)no
StopWhenstopWhen(handler)boolean apply(World w)no
LastScenelastScene(handler)Scene apply(World w)no

If a matching method is not found when installing handlers, a RuntimeException is thrown, describing the offense.


Field Summary
static double DEFAULT_TICK_RATE
          Default Tick rate for the world: ~33 frames per second
static java.lang.String KEY_ARROW_DOWN
          Key arrow-down event String
static java.lang.String KEY_ARROW_LEFT
          Key arrow-left event String
static java.lang.String KEY_ARROW_RIGHT
          Key arrow-right event String
static java.lang.String KEY_ARROW_UP
          Key arrow-up event String
static java.lang.String KEY_ESCAPE
          Key escape event String
static java.lang.String MOUSE_DOWN
          Mouse down (button-down) event String
static java.lang.String MOUSE_DRAG
          Mouse down & move (drag) event String
static java.lang.String MOUSE_ENTER
          Mouse window enter (enter) event String
static java.lang.String MOUSE_LEAVE
          Mouse window leave (leave) event String
static java.lang.String MOUSE_MOVE
          Mouse motion (move) event String
static java.lang.String MOUSE_UP
          Mouse up (button-up) event String
 
Constructor Summary
BigBang(java.lang.Object initial)
          Create a new BigBang with a value of the initial World
 
Method Summary
 java.lang.Object bigBang()
          Construct and run the animation/interaction system.
 java.lang.Object bigBang(java.lang.String title)
          Open a window and run the animation with the given title
 BigBang lastScene(java.lang.Object lastscene)
          Install a LastScene Handler into this BigBang.
 BigBang onDraw(java.lang.Object ondraw)
          Install a Draw Handler into this BigBang.
 BigBang onKey(java.lang.Object onkey)
          Install a Key Handler into this BigBang.
 BigBang onMouse(java.lang.Object onmouse)
          Install a Mouse Handler into this BigBang.
 BigBang onRelease(java.lang.Object onrelease)
          Install a Key Release Handler into this BigBang.
 BigBang onTick(java.lang.Object ontick)
          Install a Tick Handler at a tick rate of 1/20th of a second.
 BigBang onTick(java.lang.Object ontick, double time)
          Install a Tick Handler into this BigBang at the given tick rate (per-seconds).
 BigBang stopWhen(java.lang.Object stopwhen)
          Install a StopWhen Handler into this BigBang.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TICK_RATE

public static double DEFAULT_TICK_RATE
Default Tick rate for the world: ~33 frames per second


MOUSE_DOWN

public static java.lang.String MOUSE_DOWN
Mouse down (button-down) event String


MOUSE_UP

public static java.lang.String MOUSE_UP
Mouse up (button-up) event String


MOUSE_ENTER

public static java.lang.String MOUSE_ENTER
Mouse window enter (enter) event String


MOUSE_LEAVE

public static java.lang.String MOUSE_LEAVE
Mouse window leave (leave) event String


MOUSE_MOVE

public static java.lang.String MOUSE_MOVE
Mouse motion (move) event String


MOUSE_DRAG

public static java.lang.String MOUSE_DRAG
Mouse down & move (drag) event String


KEY_ARROW_UP

public static java.lang.String KEY_ARROW_UP
Key arrow-up event String


KEY_ARROW_DOWN

public static java.lang.String KEY_ARROW_DOWN
Key arrow-down event String


KEY_ARROW_LEFT

public static java.lang.String KEY_ARROW_LEFT
Key arrow-left event String


KEY_ARROW_RIGHT

public static java.lang.String KEY_ARROW_RIGHT
Key arrow-right event String


KEY_ESCAPE

public static java.lang.String KEY_ESCAPE
Key escape event String

Constructor Detail

BigBang

public BigBang(java.lang.Object initial)
Create a new BigBang with a value of the initial World

Method Detail

onDraw

public BigBang onDraw(java.lang.Object ondraw)
Install a Draw Handler into this BigBang. The Draw handler requires an apply method [World -> Scene], though the requirement is checked dynamically when this method is called.


onTick

public BigBang onTick(java.lang.Object ontick)
Install a Tick Handler at a tick rate of 1/20th of a second.


onTick

public BigBang onTick(java.lang.Object ontick,
                      double time)
Install a Tick Handler into this BigBang at the given tick rate (per-seconds). The Tick handler requires an apply method [World -> World], though the requirement is checked dynamically when this method is called.


onMouse

public BigBang onMouse(java.lang.Object onmouse)
Install a Mouse Handler into this BigBang. The Mouse handler requires an apply method [World -> World], though the requirement is checked dynamically when this method is called.


onKey

public BigBang onKey(java.lang.Object onkey)
Install a Key Handler into this BigBang. The Key handler requires an apply method [World String -> World], though the requirement is checked dynamically when this method is called.


onRelease

public BigBang onRelease(java.lang.Object onrelease)
Install a Key Release Handler into this BigBang. The Key Release handler requires an apply method [World String -> World], though the requirement is checked dynamically when this method is called.


stopWhen

public BigBang stopWhen(java.lang.Object stopwhen)
Install a StopWhen Handler into this BigBang. The StopWhen handler requires an apply method [World -> Boolean], though the requirement is checked dynamically when this method is called. The StopWhen handler, if installed is call to determine whether or not the World/animation/events should be stopped. When/if the handler returns true then all events stop being received and the LastScene handler is given a chance to draw the final World.


lastScene

public BigBang lastScene(java.lang.Object lastscene)
Install a LastScene Handler into this BigBang. The LastScene handler requires an apply method [World -> Scene], though the requirement is checked dynamically when this method is called. After the animation is stopped (StopWhen) the final World is drawn using the LstScene Handler.


bigBang

public java.lang.Object bigBang()
Construct and run the animation/interaction system. For the Swing version the method returns the final value of the World after the animation has completed. The Window is opened as a Modal dialog, so control does not return to the bigband caller until the window is closed.


bigBang

public java.lang.Object bigBang(java.lang.String title)
Open a window and run the animation with the given title