net.jimmc.spelsim
Class SpelCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by net.jimmc.spelsim.SpelCanvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible

public class SpelCanvas
extends java.awt.Panel
implements java.lang.Runnable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ALG_FORWARD
           
static int ALG_FORWARD_CIRCULAR
           
static int ALG_TRAPEZOID
           
static int MAX_ALG_VALUE
           
static int VIEW_SCALE_BOUNDING
           
static int VIEW_SCALE_FIXED
           
static int VIEW_SCALE_PLANET
           
 
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
SpelCanvas(SpelSim sim)
           
 
Method Summary
 void addSimListener(ISimListener listener)
           
protected  void drawBrokenElementCount(java.awt.Graphics2D g)
           
protected  void drawScale(java.awt.Graphics2D g, double scale)
          Draw the current scale into the window.
protected  void drawTime(java.awt.Graphics2D g)
          Draw the current time value into the window.
 int getAlgorithm()
           
 java.lang.String getBrokenElementCountString()
           
 Cable getCable()
           
 double getCwDerating()
          Get the CW derating.
 double getDampingFactor()
          Get the damping factor.
 double getGroundDrag()
          Get the ground drag.
 java.lang.String getGroundedElementCountString()
           
 double getMaxRefreshRate()
          Get the maximum refresh rate.
 Planet getPlanet()
           
 java.awt.Dimension getPreferredSize()
           
 java.lang.String getRunStatus()
           
 double getSimStepSize()
           
 double getSimulationSpeed()
          Get the simulation speed.
 java.lang.String getStatusString()
           
 double getTicksPerSecond()
          Get the number of simulation ticks per second.
 double getTime()
           
 void paint(java.awt.Graphics graphics)
           
 void reset()
          Reset the simulation.
 void run()
           
 void setAlgorithm(int alg)
          Set the step integration algorithm to use.
 void setCwDerating(double df)
          Set the CW derating to use.
 void setDampingFactor(double df)
          Set the damping factor to use.
 void setDebugOutput(boolean enabled)
          Set the debug flag.
 void setGroundDrag(double drag)
          Set the ground drag to use.
 void setMaxRefreshRate(double maxPerSecond)
          Set the maximum refresh rate.
 void setPerspective(boolean perspective)
          Set the perspective to use.
 void setSimEvents(SimEvent[] simEvents)
          Set the simulation events.
 void setSimStepSize(double simSeconds)
          Set the size of each simulation step in sim-seconds.
 void setTicksPerSecond(double d)
          Set the number of simulation ticks we perform per second.
 void setViewScale(int viewScale)
          Set the scale/view to use.
protected  void simulateEvents()
           
protected  void simulateOneStep()
          Simulate one clock tick.
 void start()
           
 void step()
           
 void stop()
           
protected  void waitForTick()
          Wait for the next simulation tick.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, firePropertyChange, firePropertyChange, firePropertyChange, 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, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, 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

VIEW_SCALE_FIXED

public static final int VIEW_SCALE_FIXED
See Also:
Constant Field Values

VIEW_SCALE_BOUNDING

public static final int VIEW_SCALE_BOUNDING
See Also:
Constant Field Values

VIEW_SCALE_PLANET

public static final int VIEW_SCALE_PLANET
See Also:
Constant Field Values

ALG_FORWARD

public static final int ALG_FORWARD
See Also:
Constant Field Values

ALG_FORWARD_CIRCULAR

public static final int ALG_FORWARD_CIRCULAR
See Also:
Constant Field Values

ALG_TRAPEZOID

public static final int ALG_TRAPEZOID
See Also:
Constant Field Values

MAX_ALG_VALUE

public static final int MAX_ALG_VALUE
See Also:
Constant Field Values
Constructor Detail

SpelCanvas

public SpelCanvas(SpelSim sim)
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Container

setSimStepSize

public void setSimStepSize(double simSeconds)
Set the size of each simulation step in sim-seconds.


getSimStepSize

public double getSimStepSize()

setTicksPerSecond

public void setTicksPerSecond(double d)
Set the number of simulation ticks we perform per second.


getTicksPerSecond

public double getTicksPerSecond()
Get the number of simulation ticks per second.


getSimulationSpeed

public double getSimulationSpeed()
Get the simulation speed. This is the ratio of simulation time to real time.


setDampingFactor

public void setDampingFactor(double df)
Set the damping factor to use.


getDampingFactor

public double getDampingFactor()
Get the damping factor.


setCwDerating

public void setCwDerating(double df)
Set the CW derating to use.


getCwDerating

public double getCwDerating()
Get the CW derating.


setGroundDrag

public void setGroundDrag(double drag)
Set the ground drag to use.


getGroundDrag

public double getGroundDrag()
Get the ground drag.


setMaxRefreshRate

public void setMaxRefreshRate(double maxPerSecond)
Set the maximum refresh rate. We will not update the screen any more often than this many times per second.


getMaxRefreshRate

public double getMaxRefreshRate()
Get the maximum refresh rate.


setPerspective

public void setPerspective(boolean perspective)
Set the perspective to use.

Parameters:
perspective - True to use the planet's perspective, false to use sidereal perspective.

setViewScale

public void setViewScale(int viewScale)
Set the scale/view to use.

Parameters:
viewScale - One of the VIEW_SCALE_* constants.

setAlgorithm

public void setAlgorithm(int alg)
Set the step integration algorithm to use.

Parameters:
alg - One of the ALG_* constants.

getAlgorithm

public int getAlgorithm()

setDebugOutput

public void setDebugOutput(boolean enabled)
Set the debug flag.

Parameters:
enabled - True to print debug output.

setSimEvents

public void setSimEvents(SimEvent[] simEvents)
Set the simulation events.


addSimListener

public void addSimListener(ISimListener listener)

start

public void start()

stop

public void stop()

step

public void step()

reset

public void reset()
Reset the simulation.


run

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

simulateOneStep

protected void simulateOneStep()
Simulate one clock tick.


simulateEvents

protected void simulateEvents()

waitForTick

protected void waitForTick()
Wait for the next simulation tick.


paint

public void paint(java.awt.Graphics graphics)
Overrides:
paint in class java.awt.Container

drawScale

protected void drawScale(java.awt.Graphics2D g,
                         double scale)
Draw the current scale into the window.


drawTime

protected void drawTime(java.awt.Graphics2D g)
Draw the current time value into the window.

Parameters:
g - The unmodified Graphics for our drawing window

getRunStatus

public java.lang.String getRunStatus()

getTime

public double getTime()

getBrokenElementCountString

public java.lang.String getBrokenElementCountString()

getGroundedElementCountString

public java.lang.String getGroundedElementCountString()

getStatusString

public java.lang.String getStatusString()

drawBrokenElementCount

protected void drawBrokenElementCount(java.awt.Graphics2D g)

getCable

public Cable getCable()

getPlanet

public Planet getPlanet()