uavsim.graphics.instruments.tachometer
Class Tachometer

java.lang.Object
  extended by uavsim.graphics.instruments.A_Instrument
      extended by uavsim.graphics.instruments.A_CircularInstrument<RevolutionsPerMinute>
          extended by uavsim.graphics.instruments.tachometer.Tachometer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener, I_AngleMapper<RevolutionsPerMinute>

public class Tachometer
extends A_CircularInstrument<RevolutionsPerMinute>

Defines a tachometer.

Author:
Dan Tappan [21.06.11]

Field Summary
private  RevolutionsPerMinute _rpm
          the RPM
private static CircularFaceplateDescriptor<RevolutionsPerMinute> FACEPLATE
          the faceplate descriptor
private static ArcDescriptor<RevolutionsPerMinute> GREEN_ARC
          the arc descriptor for the green arc
private static TickDescriptor<RevolutionsPerMinute> MAJOR_TICKS
          the major-ticks descriptor
private static TickDescriptor<RevolutionsPerMinute> MINOR_TICKS
          the minor-ticks descriptor
private static NeedleDescriptor NEEDLE
          the needle descriptor
private static NumberDescriptor<RevolutionsPerMinute> NUMBERS
          the numbers descriptor
private static TextProperties NUMBERS_TEXT
          the text properties of the numbers
private static ArcDescriptor<RevolutionsPerMinute> RED_ARC
          the arc descriptor for the red arc
private static RevolutionsPerMinute RPM_MAX
          the maximum RPM
private static RevolutionsPerMinute RPM_MIN
          the minimum RPM
 
Fields inherited from class uavsim.graphics.instruments.A_CircularInstrument
_ringSize, DISK_COLOR, MOUNT_RING_COLOR, MOUNT_RING_INNER_SCALE
 
Fields inherited from class uavsim.graphics.instruments.A_Instrument
_canvasAnchor, _canvasSize, _graphics, _id
 
Constructor Summary
Tachometer(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor)
          Creates a tachometer.
 
Method Summary
 RevolutionsPerMinute getRevolutionsPerMinute()
          Gets the RPM.
 AngleMathematical mapAngle_(RevolutionsPerMinute rpm)
          Returns the angle corresponding to the value of a unit.
 void render(java.awt.Graphics graphics)
          Renders the current state of the instrument.
private  void renderArcs()
          Renders the arcs.
private  void renderNeedle()
          Renders the needle.
private  void renderNumbers()
          Renders the numbers.
private  void renderTicks()
          Renders the major and minor ticks.
 java.lang.String toString()
          
 void update(RevolutionsPerMinute rpm)
          Updates the state of the instrument without rendering it.
 
Methods inherited from class uavsim.graphics.instruments.A_CircularInstrument
mapAngle, renderDisk, renderMountRing
 
Methods inherited from class uavsim.graphics.instruments.A_Instrument
getAnchor, getCanvasSize, getGraphics, getID, getParentComponent, handleControlCallback, hasControls, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, refresh, registerControl, setCanvasAnchor, setCanvasSize, setParentComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_rpm

private RevolutionsPerMinute _rpm
the RPM


FACEPLATE

private static final CircularFaceplateDescriptor<RevolutionsPerMinute> FACEPLATE
the faceplate descriptor


GREEN_ARC

private static final ArcDescriptor<RevolutionsPerMinute> GREEN_ARC
the arc descriptor for the green arc


MAJOR_TICKS

private static final TickDescriptor<RevolutionsPerMinute> MAJOR_TICKS
the major-ticks descriptor


MINOR_TICKS

private static final TickDescriptor<RevolutionsPerMinute> MINOR_TICKS
the minor-ticks descriptor


NEEDLE

private static final NeedleDescriptor NEEDLE
the needle descriptor


NUMBERS

private static final NumberDescriptor<RevolutionsPerMinute> NUMBERS
the numbers descriptor


NUMBERS_TEXT

private static final TextProperties NUMBERS_TEXT
the text properties of the numbers


RED_ARC

private static final ArcDescriptor<RevolutionsPerMinute> RED_ARC
the arc descriptor for the red arc


RPM_MAX

private static final RevolutionsPerMinute RPM_MAX
the maximum RPM


RPM_MIN

private static final RevolutionsPerMinute RPM_MIN
the minimum RPM

Constructor Detail

Tachometer

public Tachometer(java.lang.String id,
                  int canvasSize,
                  CoordinateCartesianAbsolute canvasAnchor)
Creates a tachometer.

Parameters:
id - - the unique instrument identifier
canvasSize - - the square size of the instrument footprint in pixels
canvasAnchor - - the anchor position for the center of the canvas in pixels
Method Detail

getRevolutionsPerMinute

public RevolutionsPerMinute getRevolutionsPerMinute()
Gets the RPM.

Returns:
the rpm

mapAngle_

public AngleMathematical mapAngle_(RevolutionsPerMinute rpm)
Returns the angle corresponding to the value of a unit.

Parameters:
rpm - - the unit
Returns:
the angle

render

public void render(java.awt.Graphics graphics)
Renders the current state of the instrument.

Overrides:
render in class A_CircularInstrument<RevolutionsPerMinute>
Parameters:
graphics - - the graphics context

renderArcs

private void renderArcs()
Renders the arcs.


renderNeedle

private void renderNeedle()
Renders the needle.


renderNumbers

private void renderNumbers()
Renders the numbers.


renderTicks

private void renderTicks()
Renders the major and minor ticks.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update(RevolutionsPerMinute rpm)
Updates the state of the instrument without rendering it.

Parameters:
rpm - - the rpm