uavsim.graphics.instruments.clock
Class ClockBasic

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

public class ClockBasic
extends A_CircularInstrument<Time>

Defines an analog clock with a second hand.

Author:
Dan Tappan [06.07.11]

Field Summary
private  Time _time
          the time
private static CircularFaceplateDescriptor<Time> FACEPLATE
          the faceplate descriptor
private static java.awt.Color HAND_PIVOT_COLOR
          the color of the pivot circle at the common base of the hands
private static Scaler HAND_PIVOT_SCALE
          the size scale of the pivot circle relative to the instrument size
private static NeedleDescriptor HOUR_HAND
          the needle for the hour hand
private static TickDescriptor<Time> MAJOR_TICKS
          the major-ticks descriptor
private static TickDescriptor<Time> MINOR_TICKS
          the minor-ticks descriptor
private static NeedleDescriptor MINUTE_HAND
          the needle for the minute hand
private static NumberDescriptor<Time> NUMBERS
          the numbers descriptor
private static TextProperties NUMBERS_TEXT
          the text properties of the numbers
private static NeedleDescriptor SECOND_HAND
          the needle for the second hand
private static Time TIME_END
          the end time on the faceplate
private static Time TIME_START
          the start time on the faceplate
 
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
ClockBasic(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor)
          Creates an analog clock.
 
Method Summary
 Time getTime()
          Gets the time.
 AngleMathematical mapAngle_(Time time)
          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 renderHands()
          Renders the hands.
private  void renderNumbers()
          Renders the numbers.
private  void renderTicks()
          Renders the minor and major ticks.
 java.lang.String toString()
          
 void update(Time time)
          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

_time

private Time _time
the time


FACEPLATE

private static final CircularFaceplateDescriptor<Time> FACEPLATE
the faceplate descriptor


HAND_PIVOT_COLOR

private static final java.awt.Color HAND_PIVOT_COLOR
the color of the pivot circle at the common base of the hands


HAND_PIVOT_SCALE

private static final Scaler HAND_PIVOT_SCALE
the size scale of the pivot circle relative to the instrument size


HOUR_HAND

private static final NeedleDescriptor HOUR_HAND
the needle for the hour hand


MAJOR_TICKS

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


MINOR_TICKS

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


MINUTE_HAND

private static final NeedleDescriptor MINUTE_HAND
the needle for the minute hand


NUMBERS

private static final NumberDescriptor<Time> NUMBERS
the numbers descriptor


NUMBERS_TEXT

private static final TextProperties NUMBERS_TEXT
the text properties of the numbers


SECOND_HAND

private static final NeedleDescriptor SECOND_HAND
the needle for the second hand


TIME_END

private static final Time TIME_END
the end time on the faceplate


TIME_START

private static final Time TIME_START
the start time on the faceplate

Constructor Detail

ClockBasic

public ClockBasic(java.lang.String id,
                  int canvasSize,
                  CoordinateCartesianAbsolute canvasAnchor)
Creates an analog clock.

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

getTime

public Time getTime()
Gets the time.

Returns:
the time

mapAngle_

public AngleMathematical mapAngle_(Time time)
Returns the angle corresponding to the value of a unit.

Parameters:
time - - 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<Time>
Parameters:
graphics - - the graphics context

renderHands

private void renderHands()
Renders the hands.


renderNumbers

private void renderNumbers()
Renders the numbers.


renderTicks

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


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update(Time time)
Updates the state of the instrument without rendering it.

Parameters:
time - - the time