examples.sensor
Class MarblesBoard

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by examples.sensor.MarblesBoard
All Implemented Interfaces:
java.lang.Runnable

public class MarblesBoard
extends javax.microedition.lcdui.Canvas
implements java.lang.Runnable


Nested Class Summary
(package private) static class MarblesBoard.Marble
           
 
Field Summary
(package private)  double[] avgX
           
(package private)  double[] avgY
           
(package private)  double[] avgZ
           
(package private) static double MARBLE_MASS
          Marble mass in kg.
(package private) static double ROLLING_FRICTION
           
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
MarblesBoard()
           
 
Method Summary
 void accelerate(double x, double y, double z)
          Accelerate the board.
 void paint(javax.microedition.lcdui.Graphics g)
           
 void resetBoard()
           
 void run()
           
 void start()
           
 void stop()
           
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getHeight, getKeyCode, getKeyName, getWidth, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getTicker, getTitle, isShown, removeCommand, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLLING_FRICTION

static final double ROLLING_FRICTION
See Also:
Constant Field Values

MARBLE_MASS

static final double MARBLE_MASS
Marble mass in kg. This demo is optimized for marbles with equal masses.

See Also:
Constant Field Values

avgX

double[] avgX

avgY

double[] avgY

avgZ

double[] avgZ
Constructor Detail

MarblesBoard

public MarblesBoard()
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

resetBoard

public void resetBoard()

start

public void start()

stop

public void stop()

run

public void run()
Specified by:
run in interface java.lang.Runnable

paint

public void paint(javax.microedition.lcdui.Graphics g)
Specified by:
paint in class javax.microedition.lcdui.Canvas

accelerate

public void accelerate(double x,
                       double y,
                       double z)
Accelerate the board. This method uses simple smoothing algorithm to remove jittering.

Parameters:
x - X acceleration in in m/s^2
y - Y acceleration in in m/s^2
z - Z acceleration in in m/s^2