uavsim.graphics.instruments.horizontalsituationindicator
Class HorizontalSituationIndicator

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

public class HorizontalSituationIndicator
extends A_CircularInstrument<AngleNavigational>

Defines a horizontal situation indicator (HSI).

Author:
Dan Tappan [14.09.11]

Field Summary
private  AngleNavigational _courseDesired
          the desired course as defined by the OBS
private  Deviation _glideslopeDeviation
          the deviation of the glideslope needle from center
private  boolean _isGlideslopeAlive
          whether the glideslope is alive
private  boolean _isLocalizerAlive
          whether the localizer is alive
private  boolean _isToOrFromStation
          whether the CDI is pointing TO a station; otherwise FROM
private  Knob _knobHeading
          the heading knob
private static KnobProperties _knobHeadingProperties
          zzz
private  Knob _knobOBS
          the OBS knob
private static KnobProperties _knobOBSProperties
          the knob properties
private  Deviation _localizerDeviation
          the deviation of the localizer needle from center
private static Ring _ringInner
          zzz
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 NeedleDescriptor COURSE_BUG
          the bug for course and reciprocal course
private static java.awt.Color DEAD_FLAG_COLOR
          the color of the dead flags
private static Deviation DRIFT_DEVIATION
          the amount of randomization in the needle drift
private static double DRIFT_RANDOM_BUCKET
          the distribution of needle movements as a percent.
private static double FLAG_MAGNIFICATION
          the size scale of the flags relative to the instrument size
private static double FLAG_WEIGHT
          the weight scale of the flag text relative to the instrument size
private static CoordinatePolarMathematical FROM_INDICATOR_OFFSET
          the relative position of the FROM indicator relative to the center of the instrument
private static Interval<Deviation> GLIDESLOPE_DEVIATION
          the interval defining the glideslope ticks
private static CoordinatePolarMathematical GLIDESLOPE_FLAG_OFFSET
          the relative position of the glideslope flag indicator relative to the center of the instrument
private static TextProperties GLIDESLOPE_FLAG_TEXT
          the text properties of the glideslope flag
private static java.awt.Color GLIDESLOPE_TICK_COLOR
          the color of the glideslope ticks
private static Scaler GLIDESLOPE_TICK_LENGTH
          the size scale of the glideslope needle relative to the instrument size
private static Scaler GLIDESLOPE_TICK_WEIGHT
          the weight scale of the glideslope needle relative to the instrument size
private static TextProperties KNOB_LABEL_PROPERTIES
          the text properties of the knob label
private static AngleNavigational KNOB_STEP
          the step value for changing the OBS
private static java.awt.Color LIVE_FLAG_COLOR
          the color of the live flags
private static Interval<Deviation> LOCALIZER_DEVIATION
          the interval defining the localizer ticks
private static CoordinatePolarMathematical LOCALIZER_FLAG_OFFSET
          the relative position of the localizer flag indicator relative to the center of the instrument
private static TextProperties LOCALIZER_FLAG_TEXT
          the text properties of the localizer flag
private static java.awt.Color LOCALIZER_TICK_COLOR
          the color of the localizer ticks
private static Scaler LOCALIZER_TICK_LARGE_WEIGHT
          the weight scale of the localizer large tick relative to the instrument size
private static Scaler LOCALIZER_TICK_SMALL_WEIGHT
          the weight scale of the localizer small tick relative to the instrument size
private static TickDescriptor<AngleNavigational> MAJOR_TICKS
          the major-ticks descriptor
private static TickDescriptor<AngleNavigational> MINOR_TICKS
          the minor-ticks descriptor
private static NumberDescriptor<AngleNavigational> NUMBERS
          the numbers descriptor
private static TextProperties NUMBERS_TEXT
          the text properties of the numbers
private static NeedleDescriptor TO_FROM_INDICATOR_OFF
          the dead to-from flag descriptor
private static NeedleDescriptor TO_FROM_INDICATOR_ON
          the alive to-from flag descriptor
private static CoordinatePolarMathematical TO_INDICATOR_OFFSET
          the relative position of the TO indicator relative to the center of the instrument
 
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
HorizontalSituationIndicator(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor)
          Creates a VOR/localizer/glideslope instrument.
 
Method Summary
private  CoordinateCartesianAbsolute calculateGlideslopeCoordinate(Deviation deviation)
          Calculate the end of the glideslope needle based on its deviation from center.
private  CoordinateCartesianAbsolute calculateLocalizerCoordinate(Deviation deviation)
          Calculate the end of the localizer needle based on its deviation from center.
private  void configureKnob()
          Configures the knob.
private  void configureNumbers()
          Configures the numbers.
private  Deviation drift(Deviation deviation)
          Perturbs a deviation by a random drift.
 AngleNavigational getAzimuth()
          Gets the azimuth.
 Deviation getGlideslopeDeviation()
          Gets the glideslope deviation from center.
 Knob getKnobHeading()
          Gets the heading knob.
 Knob getKnobOBS()
          Gets the OBS knob.
 Deviation getLocalizerDeviation()
          Gets the localizer deviation from center.
 void handleControlCallback(ControlCallbackEvent event)
          Handles an event from a registered control.
 boolean isGlideslopeAlive()
          Returns whether the glideslope is alive.
 boolean isLocalizerAlive()
          Returns whether the localizer is alive.
 boolean isToOrFromStation()
          Returns whether the CDI is indicating TO or FROM a station.
 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 renderCourseBugs()
          Renders the course bugs.
private  void renderFlag(CoordinatePolarMathematical originOffset, java.lang.String label, TextProperties textProperties, boolean isAlive)
          Renders a flag.
private  void renderFlags()
          Renders the navigation and glideslope alive flags.
private  void renderGlideslopeTicks()
          Renders the glideslope ticks.
private  void renderKnobs()
          zzz
private  void renderLocalizerTicks()
          Renders the localizer ticks.
private  void renderNumbers()
          Renders the numbers.
private  void renderRingInner()
          Renders the zzz.
private  void renderTicks()
          Renders the minor, medium, and major ticks.
private  void renderToFromIndicator()
          Renders the TO/FROM indicator arrows.
 java.lang.String toString()
          
 void update(boolean isToOrFromStation, Deviation localizerDeviation, boolean isLocalizerAlive)
          Updates the state of the instrument without rendering it.
 void update(boolean isToOrFromStation, Deviation localizerDeviation, boolean isLocalizerAlive, Deviation glideslopeDeviation, boolean isGlideslopeAlive)
          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

_courseDesired

private AngleNavigational _courseDesired
the desired course as defined by the OBS


_glideslopeDeviation

private Deviation _glideslopeDeviation
the deviation of the glideslope needle from center


_isGlideslopeAlive

private boolean _isGlideslopeAlive
whether the glideslope is alive


_isLocalizerAlive

private boolean _isLocalizerAlive
whether the localizer is alive


_isToOrFromStation

private boolean _isToOrFromStation
whether the CDI is pointing TO a station; otherwise FROM


_knobHeading

private final Knob _knobHeading
the heading knob


_knobHeadingProperties

private static final KnobProperties _knobHeadingProperties
zzz


_knobOBS

private final Knob _knobOBS
the OBS knob


_knobOBSProperties

private static final KnobProperties _knobOBSProperties
the knob properties


_localizerDeviation

private Deviation _localizerDeviation
the deviation of the localizer needle from center


_ringInner

private static Ring _ringInner
zzz


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


COURSE_BUG

private static final NeedleDescriptor COURSE_BUG
the bug for course and reciprocal course


DEAD_FLAG_COLOR

private static final java.awt.Color DEAD_FLAG_COLOR
the color of the dead flags


DRIFT_DEVIATION

private static final Deviation DRIFT_DEVIATION
the amount of randomization in the needle drift


DRIFT_RANDOM_BUCKET

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

See Also:
Constant Field Values

FLAG_MAGNIFICATION

private static final double FLAG_MAGNIFICATION
the size scale of the flags relative to the instrument size

See Also:
Constant Field Values

FLAG_WEIGHT

private static final double FLAG_WEIGHT
the weight scale of the flag text relative to the instrument size

See Also:
Constant Field Values

FROM_INDICATOR_OFFSET

private static final CoordinatePolarMathematical FROM_INDICATOR_OFFSET
the relative position of the FROM indicator relative to the center of the instrument


GLIDESLOPE_DEVIATION

private static final Interval<Deviation> GLIDESLOPE_DEVIATION
the interval defining the glideslope ticks


GLIDESLOPE_FLAG_OFFSET

private static final CoordinatePolarMathematical GLIDESLOPE_FLAG_OFFSET
the relative position of the glideslope flag indicator relative to the center of the instrument


GLIDESLOPE_FLAG_TEXT

private static final TextProperties GLIDESLOPE_FLAG_TEXT
the text properties of the glideslope flag


GLIDESLOPE_TICK_COLOR

private static final java.awt.Color GLIDESLOPE_TICK_COLOR
the color of the glideslope ticks


GLIDESLOPE_TICK_LENGTH

private static final Scaler GLIDESLOPE_TICK_LENGTH
the size scale of the glideslope needle relative to the instrument size


GLIDESLOPE_TICK_WEIGHT

private static final Scaler GLIDESLOPE_TICK_WEIGHT
the weight scale of the glideslope needle relative to the instrument size


KNOB_LABEL_PROPERTIES

private static final TextProperties KNOB_LABEL_PROPERTIES
the text properties of the knob label


KNOB_STEP

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


LIVE_FLAG_COLOR

private static final java.awt.Color LIVE_FLAG_COLOR
the color of the live flags


LOCALIZER_DEVIATION

private static final Interval<Deviation> LOCALIZER_DEVIATION
the interval defining the localizer ticks


LOCALIZER_FLAG_OFFSET

private static final CoordinatePolarMathematical LOCALIZER_FLAG_OFFSET
the relative position of the localizer flag indicator relative to the center of the instrument


LOCALIZER_FLAG_TEXT

private static final TextProperties LOCALIZER_FLAG_TEXT
the text properties of the localizer flag


LOCALIZER_TICK_COLOR

private static final java.awt.Color LOCALIZER_TICK_COLOR
the color of the localizer ticks


LOCALIZER_TICK_LARGE_WEIGHT

private static final Scaler LOCALIZER_TICK_LARGE_WEIGHT
the weight scale of the localizer large tick relative to the instrument size


LOCALIZER_TICK_SMALL_WEIGHT

private static final Scaler LOCALIZER_TICK_SMALL_WEIGHT
the weight scale of the localizer small tick relative to the instrument size


MAJOR_TICKS

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


MINOR_TICKS

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


NUMBERS

private static final NumberDescriptor<AngleNavigational> NUMBERS
the numbers descriptor


NUMBERS_TEXT

private static final TextProperties NUMBERS_TEXT
the text properties of the numbers


TO_FROM_INDICATOR_OFF

private static final NeedleDescriptor TO_FROM_INDICATOR_OFF
the dead to-from flag descriptor


TO_FROM_INDICATOR_ON

private static final NeedleDescriptor TO_FROM_INDICATOR_ON
the alive to-from flag descriptor


TO_INDICATOR_OFFSET

private static final CoordinatePolarMathematical TO_INDICATOR_OFFSET
the relative position of the TO indicator relative to the center of the instrument

Constructor Detail

HorizontalSituationIndicator

public HorizontalSituationIndicator(java.lang.String id,
                                    int canvasSize,
                                    CoordinateCartesianAbsolute canvasAnchor)
Creates a VOR/localizer/glideslope 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
Method Detail

calculateGlideslopeCoordinate

private CoordinateCartesianAbsolute calculateGlideslopeCoordinate(Deviation deviation)
Calculate the end of the glideslope needle based on its deviation from center.

Parameters:
deviation - - the deviation
Returns:
the coordinate

calculateLocalizerCoordinate

private CoordinateCartesianAbsolute calculateLocalizerCoordinate(Deviation deviation)
Calculate the end of the localizer needle based on its deviation from center.

Parameters:
deviation - - the deviation
Returns:
the coordinate

configureKnob

private void configureKnob()
Configures the knob.


configureNumbers

private void configureNumbers()
Configures the numbers.


drift

private Deviation drift(Deviation deviation)
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:
deviation - - the actual deviation
Returns:
the perturbed deviation

getAzimuth

public AngleNavigational getAzimuth()
Gets the azimuth.

Returns:
the azimuth

getGlideslopeDeviation

public Deviation getGlideslopeDeviation()
Gets the glideslope deviation from center.

Returns:
the deviation

getKnobHeading

public Knob getKnobHeading()
Gets the heading knob.

Returns:
the azimuth

getKnobOBS

public Knob getKnobOBS()
Gets the OBS knob.

Returns:
the azimuth

getLocalizerDeviation

public Deviation getLocalizerDeviation()
Gets the localizer deviation from center.

Returns:
the deviation

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

isGlideslopeAlive

public boolean isGlideslopeAlive()
Returns whether the glideslope is alive. This is meaningful only for the ILS variant.

Returns:
the state

isLocalizerAlive

public boolean isLocalizerAlive()
Returns whether the localizer is alive.

Returns:
the state

isToOrFromStation

public boolean isToOrFromStation()
Returns whether the CDI is indicating TO or FROM a station. This produces a meaningless result if the localizer is not alive.

Returns:
whether the CDI is TO; otherwise, it is FROM

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

renderCourseBugs

private void renderCourseBugs()
Renders the course bugs.


renderFlag

private void renderFlag(CoordinatePolarMathematical originOffset,
                        java.lang.String label,
                        TextProperties textProperties,
                        boolean isAlive)
Renders a flag.

Parameters:
originOffset - - the relative offset from the center of the instrument
label - - the flag label
textProperties - - the label text properties
isAlive - - whether the flag is alive

renderFlags

private void renderFlags()
Renders the navigation and glideslope alive flags.


renderGlideslopeTicks

private void renderGlideslopeTicks()
Renders the glideslope ticks.


renderKnobs

private void renderKnobs()
zzz


renderLocalizerTicks

private void renderLocalizerTicks()
Renders the localizer ticks.


renderNumbers

private void renderNumbers()
Renders the numbers.


renderRingInner

private void renderRingInner()
Renders the zzz.


renderTicks

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


renderToFromIndicator

private void renderToFromIndicator()
Renders the TO/FROM indicator arrows.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update(boolean isToOrFromStation,
                   Deviation localizerDeviation,
                   boolean isLocalizerAlive)
Updates the state of the instrument without rendering it. This update is for the VOR variant.

Parameters:
isToOrFromStation - - whether the CDI is pointing TO a station; otherwise FROM
localizerDeviation - - the localizer deviation from center
isLocalizerAlive - - whether the localizer is alive

update

public void update(boolean isToOrFromStation,
                   Deviation localizerDeviation,
                   boolean isLocalizerAlive,
                   Deviation glideslopeDeviation,
                   boolean isGlideslopeAlive)
Updates the state of the instrument without rendering it. This update is for the ILS variant.

Parameters:
isToOrFromStation - - whether the CDI is pointing TO a station; otherwise FROM
localizerDeviation - - the localizer deviation from center
isLocalizerAlive - - whether the localizer is alive
glideslopeDeviation - - the glideslope deviation from center
isGlideslopeAlive - - whether the glideslope is alive