universe.world
Class BigBang<Msg extends java.io.Serializable>

java.lang.Object
  extended by universe.world.BigBang<Msg>

public class BigBang<Msg extends java.io.Serializable>
extends java.lang.Object

A Class representing the creation of a World/System that communicates by passing messages of some type (Msg), and the related methods and Function-Objects (call-backs) for drawing the world and handling various events. Handlers are parameterized so they are statically checked.

The name and types of handlers are given in the table below:

Event NameBigBang MethodHandler SignatureRequired?
OnDrawonDraw(OnDraw)Scene apply(World<Msg> w)yes
OnTickonTick(OnTick<Msg>) or
onTick(OnTick<Msg>, double)
World apply(World<Msg> w)no
OnMouseonMouse(OnMouse<Msg>)World<Msg> apply(World<Msg> w, int x, int y, String what)no
OnKeyonKey(OnKey<Msg>)World<Msg> apply(World<Msg> w, String key)no
OnReleaseonRelease(OnRelease<Msg>)World<Msg> apply(World<Msg> w, String key)no
StopWhenstopWhen(StopWhen)boolean apply(World<Msg> w)no
LastScenelastScene(LastScene)Scene apply(World<Msg> w)no


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(World<Msg> initial)
           
 
Method Summary
 World<Msg> bigBang()
          Construct and run the animation/interaction system.
 World<Msg> bigBang(java.lang.String title)
          Open a window and run the animation with the given title
 BigBang<Msg> lastScene(LastScene lastscene)
          Install a LastScene Handler into this BigBang.
 BigBang<Msg> name(java.lang.String name)
          Install the name of this client, to be used with the Universe server
 BigBang<Msg> onDraw(OnDraw ondraw)
          Install a Draw Handler into this BigBang.
 BigBang<Msg> onKey(OnKey<Msg> onkey)
          Install a Key Handler into this BigBang.
 BigBang<Msg> onMouse(OnMouse<Msg> onmouse)
          Install a Mouse Handler into this BigBang.
 BigBang<Msg> onReceive(OnReceive<Msg> onreceive)
           
 BigBang<Msg> onRelease(OnRelease<Msg> onrelease)
          Install a Key Release Handler into this BigBang.
 BigBang<Msg> onTick(OnTick<Msg> ontick)
          Install a Tick Handler at a tick rate of 1/20th of a second.
 BigBang<Msg> onTick(OnTick<Msg> ontick, double time)
          Install a Tick Handler into this BigBang at the given tick rate (per-seconds).
 BigBang<Msg> register(java.lang.String server)
          Install the name of the Universe server to connect to once bigBang is called
 BigBang<Msg> stopWhen(StopWhen 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(World<Msg> initial)
Method Detail

onDraw

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


onTick

public BigBang<Msg> onTick(OnTick<Msg> ontick)
Install a Tick Handler at a tick rate of 1/20th of a second.


onTick

public BigBang<Msg> onTick(OnTick<Msg> 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<Msg> -> World<Msg>], though the requirement is checked dynamically when this method is called.


onMouse

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


onKey

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


onRelease

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


onReceive

public BigBang<Msg> onReceive(OnReceive<Msg> onreceive)

stopWhen

public BigBang<Msg> stopWhen(StopWhen 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<Msg> lastScene(LastScene 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.


register

public BigBang<Msg> register(java.lang.String server)
Install the name of the Universe server to connect to once bigBang is called


name

public BigBang<Msg> name(java.lang.String name)
Install the name of this client, to be used with the Universe server


bigBang

public World<Msg> 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 Windqow is opened as a Modal dialog, so control does not return to the bigband caller until the window is closed.


bigBang

public World<Msg> bigBang(java.lang.String title)
Open a window and run the animation with the given title