android.world
Class BigBang

java.lang.Object
  extended by android.world.BigBang

public class BigBang
extends java.lang.Object

A Class representing a World 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

For Android phones we have a few more options like orientation sensor(s) that we can tap into. Orientation changes of a device can be received by installing an orientation handler:

Event NameBigBang MethodHandler SignatureRequired?
Orientationorientation(handler)World apply(World w, float x, float y, float z)no


Key and Mouse events are also handled slightly different, as most devices do not have hardware keyboards, and generate Touch events without the typical "move" events (only Down, Drag and Up events).


Field Summary
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_MENU
          Menu Key event String.
static java.lang.String KEY_SEARCH
          Search Key event String
static java.lang.String LONG_MOUSE_DOWN
          Mouse down (button-down) 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_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(android.app.Activity act)
          Construct and start the animation/interaction system.
 java.lang.Object bigBangFullscreen(android.app.Activity act)
          Construct and start the animation/interaction system with the Android device in FULLSCREEN mode.
 java.lang.Object bigBangLandscape(android.app.Activity act)
          Construct and start the animation/interaction system with the Android device in LANDSCAPE mode.
 java.lang.Object bigBangLandscapeFullscreen(android.app.Activity act)
          Construct and start the animation/interaction system with the Android device in LANDSCAPE mode.
 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 orientation(java.lang.Object orientation)
          Install an Orientation Handler into this BigBang.
 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

MOUSE_DOWN

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


LONG_MOUSE_DOWN

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


MOUSE_UP

public static java.lang.String MOUSE_UP
Mouse up (button-up) 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_MENU

public static java.lang.String KEY_MENU
Menu Key event String. The menu key will usually be intercepted to open a save dialog to enable the capture of application/game screen-shots.


KEY_SEARCH

public static java.lang.String KEY_SEARCH
Search Key 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.


orientation

public BigBang orientation(java.lang.Object orientation)
Install an Orientation Handler into this BigBang. The Orientation handler requires an apply method [World Float Float Float -> World], though the requirement is checked dynamically when this method is called. On Android systems, the Orientation handler is called when the device orientation is updated or changed. The three floats passed to the handler method represent the device's current orientation (angles in radians) in the device's three dimensions, X, Y, and Z.

The three dimensional vector represents the direction of gravitational force (i.e., the ground) as compared to the device at rest (e.g., flat on a level table) where Z points directly at the ground. The X and Y vectors are in the device's screen coordinates, and Z typically points out the back of the device.


bigBang

public java.lang.Object bigBang(android.app.Activity act)
Construct and start the animation/interaction system. For the Android version the client must pass the initiating Activity in order to connect the handlers to the necessary events. The method returns the initial World (for no good reason) since the Activity.onCreate(...), must return before the application may start.


bigBangLandscape

public java.lang.Object bigBangLandscape(android.app.Activity act)
Construct and start the animation/interaction system with the Android device in LANDSCAPE mode.


bigBangFullscreen

public java.lang.Object bigBangFullscreen(android.app.Activity act)
Construct and start the animation/interaction system with the Android device in FULLSCREEN mode.


bigBangLandscapeFullscreen

public java.lang.Object bigBangLandscapeFullscreen(android.app.Activity act)
Construct and start the animation/interaction system with the Android device in LANDSCAPE mode.