uavsim.graphics.instruments.vorlocalizerglideslope
Class VORLocalizerGlideslope

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

public class VORLocalizerGlideslope
extends A_CircularInstrument<AngleNavigational>

Defines a standard directional-gyro instrument.

Author:
Dan Tappan [07.07.11]

Field Summary
private  AngleNavigational _courseDesired
          the desired course as defined by the OBS
private  AttitudePitch _glideslopeCorrectionAngle
          the correction angle to get the glideslope on course
private  boolean _hasGlideslope
          whether this instrument has a glideslope indicator
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 _knob
          the OBS knob
private static KnobProperties _knobProperties
          the knob properties
private  AttitudeYaw _localizerCorrectionAngle
          the correction angle to get the localizer on course
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 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<AttitudePitch> GLIDESLOPE_DEVIATION
          the interval defining the glideslipe ticks
private static AttitudePitch GLIDESLOPE_DRIFT
          the amount of random needle drift
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 NeedleDescriptor GLIDESLOPE_NEEDLE
          the glideslope-needle descriptor
private static Scaler GLIDESLOPE_NEEDLE_BASE
          the position scale of the glideslope needle base relative to the instrument center
private static double GLIDESLOPE_SCALE
          the scale to adjust the glideslope correction angle into a needle deflection
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<AttitudeYaw> LOCALIZER_DEVIATION
          the interval defining the localizer ticks
private static AttitudeYaw LOCALIZER_DRIFT
          the amount of random needle drift
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 NeedleDescriptor LOCALIZER_NEEDLE
          the localizer-needle descriptor
private static Scaler LOCALIZER_NEEDLE_BASE
          the position scale of the localizer needle relative to the instrument center
private static double LOCALIZER_SCALE
          the scale to adjust the localizer correction angle into a needle deflection
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
VORLocalizerGlideslope(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor, boolean hasGlideslope)
          Creates a VOR/localizer/glideslope instrument.
 
Method Summary
private  CoordinateCartesianAbsolute calculateGlideslopeCoordinate(AttitudePitch angle)
          Calculate the end of the glideslope needle based on its correction angle from center.
private  CoordinateCartesianAbsolute calculateLocalizerCoordinate(AttitudeYaw angle, boolean isILSMode)
          Calculate the end of the localizer needle based on its correction angle from center.
private  void configureKnob()
          Configures the knob.
private  void configureNumbers()
          Configures the numbers.
private  AttitudePitch drift(AttitudePitch correctionAngle)
          Perturbs a correction angle by a random drift.
private  AttitudeYaw drift(AttitudeYaw correctionAngle)
          Perturbs a correction angle by a random drift.
 AngleNavigational getCourseDesired()
          Gets the desired course set the OBS.
 AttitudePitch getGlideslopeCorrectionAngle()
          Gets the correction angle to get the glideslope on course.
 Knob getKnob()
          Gets the knob.
 AttitudeYaw getLocalizerCorrectionAngle()
          Gets the correction angle to get the localizer on course.
 void handleControlCallback(ControlCallbackEvent event)
          Handles an event from a registered control.
 boolean hasGlideslope()
          Returns whether the instrument has a glideslope.
 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 renderGlideslopeNeedle()
          Renders the needle.
private  void renderGlideslopeTicks()
          Renders the glideslope ticks.
private  void renderKnob()
          Renders the OBS knob.
private  void renderLocalizerNeedle()
          Renders the needle.
private  void renderLocalizerTicks()
          Renders the localizer ticks.
private  void renderNumbers()
          Renders the numbers.
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()
          Updates the state of the instrument without rendering it.
 void update(AttitudeYaw correctionAngleLocalizer, AttitudePitch correctionAngleGlideslope)
          Updates the state of the instrument without rendering it.
 void update(AttitudeYaw correctionAngle, boolean isToOrFromStation)
          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


_glideslopeCorrectionAngle

private AttitudePitch _glideslopeCorrectionAngle
the correction angle to get the glideslope on course


_hasGlideslope

private final boolean _hasGlideslope
whether this instrument has a glideslope indicator


_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


_knob

private final Knob _knob
the OBS knob


_knobProperties

private static final KnobProperties _knobProperties
the knob properties


_localizerCorrectionAngle

private AttitudeYaw _localizerCorrectionAngle
the correction angle to get the localizer on course


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_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<AttitudePitch> GLIDESLOPE_DEVIATION
the interval defining the glideslipe ticks


GLIDESLOPE_DRIFT

private static final AttitudePitch GLIDESLOPE_DRIFT
the amount of random needle drift


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_NEEDLE

private static final NeedleDescriptor GLIDESLOPE_NEEDLE
the glideslope-needle descriptor


GLIDESLOPE_NEEDLE_BASE

private static final Scaler GLIDESLOPE_NEEDLE_BASE
the position scale of the glideslope needle base relative to the instrument center


GLIDESLOPE_SCALE

private static final double GLIDESLOPE_SCALE
the scale to adjust the glideslope correction angle into a needle deflection

See Also:
Constant Field Values

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<AttitudeYaw> LOCALIZER_DEVIATION
the interval defining the localizer ticks


LOCALIZER_DRIFT

private static final AttitudeYaw LOCALIZER_DRIFT
the amount of random needle drift


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_NEEDLE

private static final NeedleDescriptor LOCALIZER_NEEDLE
the localizer-needle descriptor


LOCALIZER_NEEDLE_BASE

private static final Scaler LOCALIZER_NEEDLE_BASE
the position scale of the localizer needle relative to the instrument center


LOCALIZER_SCALE

private static final double LOCALIZER_SCALE
the scale to adjust the localizer correction angle into a needle deflection

See Also:
Constant Field Values

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

VORLocalizerGlideslope

public VORLocalizerGlideslope(java.lang.String id,
                              int canvasSize,
                              CoordinateCartesianAbsolute canvasAnchor,
                              boolean hasGlideslope)
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
hasGlideslope - - whether glideslope is implemented; without it, this is a VOR and localizer instrument
Method Detail

calculateGlideslopeCoordinate

private CoordinateCartesianAbsolute calculateGlideslopeCoordinate(AttitudePitch angle)
Calculate the end of the glideslope needle based on its correction angle from center.

Parameters:
angle - - the the correction angle
Returns:
the coordinate

calculateLocalizerCoordinate

private CoordinateCartesianAbsolute calculateLocalizerCoordinate(AttitudeYaw angle,
                                                                 boolean isILSMode)
Calculate the end of the localizer needle based on its correction angle from center.

Parameters:
angle - - the correction angle
isILSMode - - whether the instrument is in ILS mode, which increases the sensitivity of the needle by LOCALIZER_ILS_SENSITIVITY
Returns:
the coordinate

configureKnob

private void configureKnob()
Configures the knob.


configureNumbers

private void configureNumbers()
Configures the numbers.


drift

private AttitudePitch drift(AttitudePitch correctionAngle)
Perturbs a correction angle by a random drift. This gives the needles the appearance of picking up spurious signals when they are not tuned to any station.

Parameters:
correctionAngle - - the true correction angle
Returns:
the perturbed angle

drift

private AttitudeYaw drift(AttitudeYaw correctionAngle)
Perturbs a correction angle by a random drift. This gives the needles the appearance of picking up spurious signals when they are not tuned to any station.

Parameters:
correctionAngle - - the true correction angle
Returns:
the perturbed angle

getCourseDesired

public AngleNavigational getCourseDesired()
Gets the desired course set the OBS.

Returns:
the course

getGlideslopeCorrectionAngle

public AttitudePitch getGlideslopeCorrectionAngle()
Gets the correction angle to get the glideslope on course. This is valid only if there is a glideslope.

Returns:
the angle

getKnob

public Knob getKnob()
Gets the knob.

Returns:
the azimuth

getLocalizerCorrectionAngle

public AttitudeYaw getLocalizerCorrectionAngle()
Gets the correction angle to get the localizer on course.

Returns:
the angle

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

hasGlideslope

public boolean hasGlideslope()
Returns whether the instrument has a glideslope. The VOR-only variant does not.

Returns:
the state

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.


renderGlideslopeNeedle

private void renderGlideslopeNeedle()
Renders the needle.


renderGlideslopeTicks

private void renderGlideslopeTicks()
Renders the glideslope ticks.


renderKnob

private void renderKnob()
Renders the OBS knob.


renderLocalizerNeedle

private void renderLocalizerNeedle()
Renders the needle.


renderLocalizerTicks

private void renderLocalizerTicks()
Renders the localizer ticks.


renderNumbers

private void renderNumbers()
Renders the numbers.


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()
Updates the state of the instrument without rendering it. This variant induces random drift in the localizer and glideslope needles to simulate loss of signal.


update

public void update(AttitudeYaw correctionAngleLocalizer,
                   AttitudePitch correctionAngleGlideslope)
Updates the state of the instrument without rendering it. This update is for the ILS variant.

Parameters:
correctionAngleLocalizer - - the localizer deviation from center
correctionAngleGlideslope - - the glideslope deviation from center

update

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

Parameters:
correctionAngle - - the correction angle necessary to go from the radial the UAV is on to the UAV it wants to be on
isToOrFromStation - - whether the UAV is going to or from the station