uavsim.graphics.instruments.automaticdirectionfinder
Class AutomaticDirectionFinder

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

public class AutomaticDirectionFinder
extends A_CircularInstrument<AngleNavigational>

Defines a standard fixed-card or moveable-card directional-gyro instrument.

Author:
Dan Tappan [06.07.11]

Field Summary
private  AngleNavigational _bearingRelative
          the bearing to the station
private  AngleNavigational _heading
          the heading
private  boolean _isMoveableCard
          whether this is a moveable-card ADF
private  Knob _knob
          the heading knob
private static KnobProperties _knobProperties
          the knob properties
private static AngleNavigational AZIMUTH_END
          the end angle of the azimuth numbers
private static AngleNavigational AZIMUTH_START
          the start angle of the azimuth numbers
private static AngleNavigational DRIFT_DEVIATION
          the amount of random needle drift
private static double DRIFT_RANDOM_BUCKET
          the distribution of needle movements as a percent.
private static NeedleDescriptor HEADING_BUG
          the heading bug
private static TextProperties KNOB_LABEL_PROPERTIES
          the knob label properties
private static AngleNavigational KNOB_STEP
          the step value for changing the azimuth
private static TickDescriptor<AngleNavigational> MAJOR_TICKS
          the descriptor for the major ticks
private static TickDescriptor<AngleNavigational> MINOR_TICKS
          the descriptor for the minor ticks
private static NeedleDescriptor NEEDLE_FROM
          the from-needle descriptor
private static NeedleDescriptor NEEDLE_TO
          the to-needle descriptor
private  NumberDescriptor<AngleNavigational> NUMBERS
          the numbers descriptor
private static TextProperties NUMBERS_TEXT
          the text properties of the numbers
 
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
AutomaticDirectionFinder(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor, boolean isMoveableCard)
          Creates an ADF instrument.
 
Method Summary
 AngleNavigational calculateBearingAbsolute()
          Gets the absolute bearing to the station.
 AngleNavigational calculateBearingRelative()
          Gets the relative bearing to the station.
private  void configureKnob()
          Configures the knobs.
private  void configureNumbers()
          Configures the numbers.
private  AngleNavigational drift(AngleNavigational bearing)
          Perturbs a deviation by a random drift.
 AngleNavigational getHeading()
          Gets the heading dialed into the card.
 Knob getKnob()
          Gets the knob.
 void handleControlCallback(ControlCallbackEvent event)
          Handles an event from a registered control.
 boolean isMoveableCard()
          Returns whether this is a moveable-card ADF.
 AngleMathematical mapAngle_(AngleNavigational azimuth)
          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 renderHeadingBug()
          Renders the heading bug.
private  void renderKnob()
          Renders the knob.
private  void renderNeedle()
          Renders the needle.
private  void renderNumbers()
          Renders the numbers.
private  void renderTicks()
          Renders the minor, medium, and major ticks.
 java.lang.String toString()
          
 void update()
          Updates the state of the instrument without rendering it.
 void update(AngleNavigational bearingRelative)
          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, 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

_bearingRelative

private AngleNavigational _bearingRelative
the bearing to the station


_heading

private AngleNavigational _heading
the heading


_isMoveableCard

private final boolean _isMoveableCard
whether this is a moveable-card ADF


_knob

private final Knob _knob
the heading knob


_knobProperties

private static final KnobProperties _knobProperties
the knob properties


AZIMUTH_END

private static final AngleNavigational AZIMUTH_END
the end angle of the azimuth numbers


AZIMUTH_START

private static final AngleNavigational AZIMUTH_START
the start angle of the azimuth numbers


DRIFT_DEVIATION

private static final AngleNavigational DRIFT_DEVIATION
the amount of random needle drift


DRIFT_RANDOM_BUCKET

private static final double DRIFT_RANDOM_BUCKET
the distribution of needle movements as a percent. For example 0.25 says 1/4 of uniformly distributed random numbers indicate a left drift and 1/4 a right drift. The remainder indicates no drift

See Also:
Constant Field Values

HEADING_BUG

private static final NeedleDescriptor HEADING_BUG
the heading bug


KNOB_LABEL_PROPERTIES

private static final TextProperties KNOB_LABEL_PROPERTIES
the knob label properties


KNOB_STEP

private static final AngleNavigational KNOB_STEP
the step value for changing the azimuth


MAJOR_TICKS

private static final TickDescriptor<AngleNavigational> MAJOR_TICKS
the descriptor for the major ticks


MINOR_TICKS

private static final TickDescriptor<AngleNavigational> MINOR_TICKS
the descriptor for the minor ticks


NEEDLE_FROM

private static final NeedleDescriptor NEEDLE_FROM
the from-needle descriptor


NEEDLE_TO

private static final NeedleDescriptor NEEDLE_TO
the to-needle descriptor


NUMBERS

private final NumberDescriptor<AngleNavigational> NUMBERS
the numbers descriptor


NUMBERS_TEXT

private static final TextProperties NUMBERS_TEXT
the text properties of the numbers

Constructor Detail

AutomaticDirectionFinder

public AutomaticDirectionFinder(java.lang.String id,
                                int canvasSize,
                                CoordinateCartesianAbsolute canvasAnchor,
                                boolean isMoveableCard)
Creates an ADF instrument.

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
isMoveableCard - - whether this is a moveable- or fixed-card ADF
Method Detail

calculateBearingAbsolute

public AngleNavigational calculateBearingAbsolute()
Gets the absolute bearing to the station.

Returns:
the bearing

calculateBearingRelative

public AngleNavigational calculateBearingRelative()
Gets the relative bearing to the station.

Returns:
the bearing

configureKnob

private void configureKnob()
Configures the knobs.


configureNumbers

private void configureNumbers()
Configures the numbers.


drift

private AngleNavigational drift(AngleNavigational bearing)
Perturbs a deviation by a random drift. This gives the needles the appearance of picking up spurious signals when they are not tuned to any station.

Parameters:
bearing - - the bearing
Returns:
the bearing deviation

getHeading

public AngleNavigational getHeading()
Gets the heading dialed into the card. For a fixed-card ADF, this is always zero.

Returns:
the heading

getKnob

public Knob getKnob()
Gets the knob. This is valid only for a moveable-card ADF.

Returns:
the azimuth

handleControlCallback

public void handleControlCallback(ControlCallbackEvent event)
Handles an event from a registered control. This performs validation only. Its actions must be defined in overridden methods.

Overrides:
handleControlCallback in class A_Instrument
Parameters:
event - - the callback event

isMoveableCard

public boolean isMoveableCard()
Returns whether this is a moveable-card ADF.

Returns:
the state

mapAngle_

public AngleMathematical mapAngle_(AngleNavigational azimuth)
Returns the angle corresponding to the value of a unit.

Parameters:
azimuth - - 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<AngleNavigational>
Parameters:
graphics - - the graphics context

renderHeadingBug

private void renderHeadingBug()
Renders the heading bug.


renderKnob

private void renderKnob()
Renders the knob.


renderNeedle

private void renderNeedle()
Renders the needle.


renderNumbers

private void renderNumbers()
Renders the numbers.


renderTicks

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


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update()
Updates the state of the instrument without rendering it. This variant is used when there is no active NDB signal, which causes the needle to drift randomly.


update

public void update(AngleNavigational bearingRelative)
Updates the state of the instrument without rendering it. This variant updates the relative bearing from an active NDB signal.

Parameters:
bearingRelative - - the relative bearing to the station