Class Turntable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--Turntable
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, RootPaneContainer, Runnable, Serializable

public class Turntable
extends JApplet
implements Runnable

Turntable simulation applet.

See Also:
Serialized Form

Nested Class Summary
 class Turntable.FloatSlider
          Slider that only has values between 0 and 1.
 class Turntable.TurntablePanel
          Draws a diagram of the turntable.
 
Field Summary
private  float angularMomentum
          Angular momentum of system.
private static float DELTA_TIME_PAUSE
          Milliseconds that pass each simulation frame when it is paused.
private static float DELTA_TIME_PLAY
          Milliseconds that pass each simulation frame when it is playing.
private  float deltaTime
          Milliseconds that pass each simulation frame.
private static float FAN_HEIGHT
          Height of fan ellipse.
private static float FAN_WIDTH
          Width of fan ellipse.
private  Turntable.FloatSlider fanAngleSlider
          Fan angle slider.
private  float fanForce
          Force exert by fan.
private  Turntable.FloatSlider fanForceSlider
          Fan force slider.
private  float fanPositionX
          X polar co-ordinate of fan on turntable.
private  float fanPositionY
          Y polar co-ordinate of fan on turntable.
private  Turntable.FloatSlider fanRadiusSlider
          Fan distance from turntable center slider.
private static int FRAME_DELAY
          Millisecond delay between each frame.
private  JTextArea informationText
          Text area containing information about turntable.
private static float MASS_MASS
          Mass of point mass.
private  float massPositionX
          X polar co-ordinate of mass on turntable.
private  float massPositionY
          Y polar co-ordinate of mass on turntable.
private  float massRadius
          Mass representation radius.
private  Turntable.FloatSlider massRadiusSlider
          Mass distance from turntable center slider.
private static float MAX_FAN_FORCE
          Maximum force fan can exert.
private static DecimalFormat numberFormat
          Number format for displaying values.
private  float orientation
          Orientation of the turntable.
private static RenderingHints renderHints
          Rendering hints to turn on antialiasing.
private static String STRING_ALMOST_EQUAL
          Almost equal symbol.
private static String STRING_ANGULAR_ACCELERATION
          Angular acceleration symbol.
private static String STRING_ANGULAR_VELOCITY
          Angular velocity symbol.
private static String STRING_DEGREES
          Degrees symbol.
private static String STRING_DELTA
          Delta symbol.
private static String STRING_INVERSE
          Inverse symbol.
private static String STRING_INVERSE_SQUARED
          Inverse squared symbol.
private static String STRING_SQUARED
          Squared symbol.
private static String STRING_THETA
          Theta symbol.
private static String STRING_TIMES
          Multiplication symbol.
private static String STRING_TORQUE
          Torque symbol.
private  Turntable.TurntablePanel turntableDiagram
          Diagram of turntable.
private  float turntableMomentOfInteria
          Moment of inertia of turntable.
private  float turntableRadius
          Turntable radius.
private  Thread updateThread
          Thread to update simulation.
private  String valueFanAngle
          Value of fan angle.
private  String valueFanForce
          Value of fan force.
private  String valueFanPosition
          Value of fan position.
private  String valueMassPosition
          Value of mass position.
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Turntable()
           
 
Method Summary
 void destroy()
          Stops update thread
static String format(float number)
          Returns formatted number.
 String getAppletInfo()
          Returns applet information
 void init()
          Initialises applet
 void run()
          Updates simulation
 void start()
          Starts update thread
 void stop()
          Stops update thread
 void updateSimulation()
          Updates simulation by one step.
 void updateSliders()
          Updates all slider labels with new values and sets simulation values.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

renderHints

private static RenderingHints renderHints
Rendering hints to turn on antialiasing.


numberFormat

private static DecimalFormat numberFormat
Number format for displaying values.


FRAME_DELAY

private static int FRAME_DELAY
Millisecond delay between each frame.


DELTA_TIME_PLAY

private static float DELTA_TIME_PLAY
Milliseconds that pass each simulation frame when it is playing.


DELTA_TIME_PAUSE

private static float DELTA_TIME_PAUSE
Milliseconds that pass each simulation frame when it is paused.


STRING_DELTA

private static String STRING_DELTA
Delta symbol.


STRING_TORQUE

private static String STRING_TORQUE
Torque symbol.


STRING_ANGULAR_ACCELERATION

private static String STRING_ANGULAR_ACCELERATION
Angular acceleration symbol.


STRING_ANGULAR_VELOCITY

private static String STRING_ANGULAR_VELOCITY
Angular velocity symbol.


STRING_SQUARED

private static String STRING_SQUARED
Squared symbol.


STRING_INVERSE

private static String STRING_INVERSE
Inverse symbol.


STRING_INVERSE_SQUARED

private static String STRING_INVERSE_SQUARED
Inverse squared symbol.


STRING_THETA

private static String STRING_THETA
Theta symbol.


STRING_TIMES

private static String STRING_TIMES
Multiplication symbol.


STRING_ALMOST_EQUAL

private static String STRING_ALMOST_EQUAL
Almost equal symbol.


STRING_DEGREES

private static String STRING_DEGREES
Degrees symbol.


FAN_WIDTH

private static float FAN_WIDTH
Width of fan ellipse.


FAN_HEIGHT

private static float FAN_HEIGHT
Height of fan ellipse.


MASS_MASS

private static float MASS_MASS
Mass of point mass.


MAX_FAN_FORCE

private static float MAX_FAN_FORCE
Maximum force fan can exert.


turntableRadius

private float turntableRadius
Turntable radius.


massRadius

private float massRadius
Mass representation radius.


fanForce

private float fanForce
Force exert by fan.


orientation

private float orientation
Orientation of the turntable.


angularMomentum

private float angularMomentum
Angular momentum of system.


turntableMomentOfInteria

private float turntableMomentOfInteria
Moment of inertia of turntable.


deltaTime

private float deltaTime
Milliseconds that pass each simulation frame.


fanPositionX

private float fanPositionX
X polar co-ordinate of fan on turntable.


fanPositionY

private float fanPositionY
Y polar co-ordinate of fan on turntable.


massPositionX

private float massPositionX
X polar co-ordinate of mass on turntable.


massPositionY

private float massPositionY
Y polar co-ordinate of mass on turntable.


turntableDiagram

private Turntable.TurntablePanel turntableDiagram
Diagram of turntable.


fanForceSlider

private Turntable.FloatSlider fanForceSlider
Fan force slider.


fanAngleSlider

private Turntable.FloatSlider fanAngleSlider
Fan angle slider.


fanRadiusSlider

private Turntable.FloatSlider fanRadiusSlider
Fan distance from turntable center slider.


massRadiusSlider

private Turntable.FloatSlider massRadiusSlider
Mass distance from turntable center slider.


informationText

private JTextArea informationText
Text area containing information about turntable.


valueFanAngle

private String valueFanAngle
Value of fan angle.


valueFanForce

private String valueFanForce
Value of fan force.


valueMassPosition

private String valueMassPosition
Value of mass position.


valueFanPosition

private String valueFanPosition
Value of fan position.


updateThread

private Thread updateThread
Thread to update simulation.

Constructor Detail

Turntable

public Turntable()
Method Detail

init

public void init()
Initialises applet

Overrides:
init in class Applet

format

public static String format(float number)
Returns formatted number.


updateSliders

public void updateSliders()
Updates all slider labels with new values and sets simulation values.


updateSimulation

public void updateSimulation()
Updates simulation by one step.


run

public void run()
Updates simulation

Specified by:
run in interface Runnable

start

public void start()
Starts update thread

Overrides:
start in class Applet

stop

public void stop()
Stops update thread

Overrides:
stop in class Applet

destroy

public void destroy()
Stops update thread

Overrides:
destroy in class Applet

getAppletInfo

public String getAppletInfo()
Returns applet information

Overrides:
getAppletInfo in class Applet