uavsim.graphics.instruments.gpsmap
Class GPSMap

java.lang.Object
  extended by uavsim.graphics.instruments.A_Instrument
      extended by uavsim.graphics.instruments.A_RectangularInstrument
          extended by uavsim.graphics.instruments.gpsmap.GPSMap
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener, I_WorldMappable

public class GPSMap
extends A_RectangularInstrument
implements I_WorldMappable

Defines a basic moving-map GPS overlain with a navigation chart.

Author:
Dan Tappan [16.07.11]

Field Summary
private  PushButton _buttonOrientation
          the orientation button
private static ButtonProperties _buttonOrientationProperties
          the orientation-button properties
private  PushButton _buttonPower
          the power button
private static ButtonProperties _buttonPowerProperties
          the power-button properties
private  PushButton _buttonZoomIn
          the zoom-in button
private static ButtonProperties _buttonZoomInProperties
          the zoom-in-button properties
private  PushButton _buttonZoomOut
          the zoom-out button
private static ButtonProperties _buttonZoomOutProperties
          the zoom-out-button properties
private  NavigationChart _chart
          the navigation chart
private  boolean _isMapUpNorth
          whether the display is in north-up mode or heading-up mode
private  boolean _isPowerOn
          whether the power is on
private  CoordinateCartesianAbsolute _mapCenter
          the pixel center of the map
private  Interval<Latitude> _mapLatitudeInterval
          the vertical interval of the map scale
private  Interval<Longitude> _mapLongitudeInterval
          the horizontal interval of the map scale
private  Size _mapSize
          the pixel size of the map
private  CoordinateWorld _selectedCoordinate
          the word coordinate referenced by the mouse position
private  SevenDOFDescriptor _spatialDescriptor
          the spatial descriptor
private  java.util.List<CoordinateWorld3D> _track
          the track history
private  int _trackSampleCountdown
          the countdown to triggering a track sample
private  double _zoom
          the zoom factor.
private static double[][] AIRPLANE
          the polygon description of the airplane
private static java.awt.Color AIRPLANE_COLOR
          the color of the airplane glyph
private static Scaler AIRPLANE_SCALE
          the size scale of the airplane relative to the instrument size
private static CoordinateCartesianRelative ALTITUDE_ANCHOR_SCALE
          the anchor position of the altitude text relative to the center of the instrument
private static TextProperties ALTITUDE_TEXT
          the text properties of the altitude
private static CoordinateCartesianRelative BEARING_ANCHOR_SCALE
          the anchor position of the bearing text relative to the center of the instrument
private static TextProperties BUTTON_LABEL_PROPERTIES
          the text properties of the knob label
private static CoordinateCartesianRelative COORDINATES_CURRENT_ANCHOR_SCALE
          the anchor position of the actual-coordinates text relative to the center of the instrument
private static CoordinateCartesianRelative COORDINATES_SELECTED_ANCHOR_SCALE
          the anchor position of the selected-coordinates text relative to the center of the instrument
private static TextProperties COORDINATES_TEXT
          the text properties of the coordinates
private static TextProperties DISTANCE_TEXT
          the text properties of the distance
private static RectangularFaceplaceDescriptor FACEPLATE
          the faceplace
private static java.awt.Color GRID_COLOR
          the color of the latitude/longitude grid
private static CoordinateCartesianRelative HEADING_ANCHOR_SCALE
          the anchor position of the heading text relative to the center of the instrument
private static TextProperties HEADING_TEXT
          the text properties of the heading
private static CoordinateCartesianRelative MAP_WINDOW_ANCHOR_SCALE
          the anchor position of the map window relative to the center of the instrument
private static java.awt.Color MAP_WINDOW_OUTLINE_COLOR
          the color of the window outline
private static Scaler MAP_WINDOW_OUTLINE_SCALE
          the size scale of the map-window outline relative to the instrument size
private static java.awt.Color MAP_WINDOW_POWER_OFF_BODY_COLOR
          the color of the power button in off mode
static java.awt.Color MAP_WINDOW_POWER_ON_BODY_COLOR
          the color of the power button in on mode
private static ScalerPair MAP_WINDOW_SIZE_SCALE
          the size scale of the window relative to the instrument size
private static java.awt.Color NORTH_INDICATOR_COLOR
          the color of the barb indicating north
private static CoordinateWorld NORTH_INDICATOR_PRIMARY_OFFSET
          the length of the north-indicator barb
private static CoordinateWorld NORTH_INDICATOR_SECONDARY_OFFSET
          the length of the shortened north-indicator barb that is hidden by the regular one.
(package private)  int PROFILE_SAMPLE_WINDOW_SIZE
          the number of altitude previous samples to display in the profile view
(package private)  double PROFILE_VERTICAL_SIZE
          the vertical size of the profile view relative to the map vertical size
private static java.awt.Color TRACK_HORIZONTAL_COLOR
          the color of the horizontal track
private static int TRACK_SAMPLE_RATE
          the sample rate as a function of calls to update() for recording track entries
private static java.awt.Color TRACK_VERTICAL_COLOR
          the color of the vertical track
private static double ZOOM_DEFAULT
          the default zoom factor
private static double ZOOM_MAX
          the maximum zoom factor
private static double ZOOM_MIN
          the minimum zoom factor
private static double ZOOM_STEP
          the zoom step
 
Fields inherited from class uavsim.graphics.instruments.A_RectangularInstrument
_faceplaceDescriptor, _faceSize
 
Fields inherited from class uavsim.graphics.instruments.A_Instrument
_canvasAnchor, _canvasSize, _graphics, _id
 
Constructor Summary
GPSMap(java.lang.String id, int canvasSize, CoordinateCartesianAbsolute canvasAnchor, NavigationChart chart)
          Creates a GPS map.
 
Method Summary
private  void configureControls()
          Configures the control.s
 NavigationChart getChart()
          Gets the navigation chart.
 SevenDOFDescriptor getSpatialDescriptor()
          Gets the spatial descriptor of the aircraft.
 void handleControlCallback(ControlCallbackEvent event)
          Handles an event from a registered control.
 CoordinateWorld mapWindowCoordinateToWorldCoordinate_(CoordinateCartesianAbsolute coordinateWindow)
          Translates a window coordinate in pixels to a world coordinate in latitude and longitude.
 CoordinateCartesianAbsolute mapWorldCoordinateToWindowCoordinate_(CoordinateWorld coordinateWorld)
          Translates a world coordinate in latitude and longitude to a window coordinate in pixels.
 double mapWorldDistanceToWindowDistance_(Latitude distance)
          Computes a world distance in latitude to a window distance in pixels.
 void mouseMoved(java.awt.event.MouseEvent event)
          
 void render(java.awt.Graphics graphics)
          Renders the current state of the instrument.
private  void renderAirplane()
          Renders the needle.
private  void renderChart(boolean areDetailsVisible)
          Renders the chart.
private  void renderControls()
          Renders the controls.
private  void renderGrid()
          Renders the latitude/longitude grid.
private  void renderInfo()
          Renders the text information.
private  void renderMapFrame()
          Renders the map frame.
private  void renderMapWindow()
          Renders the map window.
private  void renderNorthIndicator(CoordinateWorld coordinate)
          Renders the barb indicate north from the aircraft.
private  void renderTrackHorizontal()
          Renders the aircraft horizontal track.
private  void renderTrackVertical()
          Renders the aircraft vertical track.
private  void sampleTrack()
          Records a entry in the track history at the defined sample rate.
 java.lang.String toString()
          
 void update(SevenDOFDescriptor spatialDescriptor)
          Updates the state of the instrument without rendering it.
private  void updateMapScale()
          Updates the map scale.
 
Methods inherited from class uavsim.graphics.instruments.A_RectangularInstrument
getFaceSize, renderBox
 
Methods inherited from class uavsim.graphics.instruments.A_Instrument
getAnchor, getCanvasSize, getGraphics, getID, getParentComponent, hasControls, mouseClicked, mouseDragged, mouseEntered, mouseExited, 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

_buttonOrientation

private final PushButton _buttonOrientation
the orientation button


_buttonOrientationProperties

private static final ButtonProperties _buttonOrientationProperties
the orientation-button properties


_buttonPower

private final PushButton _buttonPower
the power button


_buttonPowerProperties

private static final ButtonProperties _buttonPowerProperties
the power-button properties


_buttonZoomIn

private final PushButton _buttonZoomIn
the zoom-in button


_buttonZoomInProperties

private static final ButtonProperties _buttonZoomInProperties
the zoom-in-button properties


_buttonZoomOut

private final PushButton _buttonZoomOut
the zoom-out button


_buttonZoomOutProperties

private static final ButtonProperties _buttonZoomOutProperties
the zoom-out-button properties


_chart

private final NavigationChart _chart
the navigation chart


_isMapUpNorth

private boolean _isMapUpNorth
whether the display is in north-up mode or heading-up mode


_isPowerOn

private boolean _isPowerOn
whether the power is on


_mapCenter

private CoordinateCartesianAbsolute _mapCenter
the pixel center of the map


_mapLatitudeInterval

private Interval<Latitude> _mapLatitudeInterval
the vertical interval of the map scale


_mapLongitudeInterval

private Interval<Longitude> _mapLongitudeInterval
the horizontal interval of the map scale


_mapSize

private Size _mapSize
the pixel size of the map


_selectedCoordinate

private CoordinateWorld _selectedCoordinate
the word coordinate referenced by the mouse position


_spatialDescriptor

private SevenDOFDescriptor _spatialDescriptor
the spatial descriptor


_track

private final java.util.List<CoordinateWorld3D> _track
the track history


_trackSampleCountdown

private int _trackSampleCountdown
the countdown to triggering a track sample


_zoom

private double _zoom
the zoom factor. The units are related to twice the degrees longitude scaled horizontally to window


AIRPLANE

private static final double[][] AIRPLANE
the polygon description of the airplane


AIRPLANE_COLOR

private static final java.awt.Color AIRPLANE_COLOR
the color of the airplane glyph


AIRPLANE_SCALE

private static final Scaler AIRPLANE_SCALE
the size scale of the airplane relative to the instrument size


ALTITUDE_ANCHOR_SCALE

private static final CoordinateCartesianRelative ALTITUDE_ANCHOR_SCALE
the anchor position of the altitude text relative to the center of the instrument


ALTITUDE_TEXT

private static final TextProperties ALTITUDE_TEXT
the text properties of the altitude


BEARING_ANCHOR_SCALE

private static final CoordinateCartesianRelative BEARING_ANCHOR_SCALE
the anchor position of the bearing text relative to the center of the instrument


BUTTON_LABEL_PROPERTIES

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


COORDINATES_CURRENT_ANCHOR_SCALE

private static final CoordinateCartesianRelative COORDINATES_CURRENT_ANCHOR_SCALE
the anchor position of the actual-coordinates text relative to the center of the instrument


COORDINATES_SELECTED_ANCHOR_SCALE

private static final CoordinateCartesianRelative COORDINATES_SELECTED_ANCHOR_SCALE
the anchor position of the selected-coordinates text relative to the center of the instrument


COORDINATES_TEXT

private static final TextProperties COORDINATES_TEXT
the text properties of the coordinates


DISTANCE_TEXT

private static final TextProperties DISTANCE_TEXT
the text properties of the distance


FACEPLATE

private static final RectangularFaceplaceDescriptor FACEPLATE
the faceplace


GRID_COLOR

private static final java.awt.Color GRID_COLOR
the color of the latitude/longitude grid


HEADING_ANCHOR_SCALE

private static final CoordinateCartesianRelative HEADING_ANCHOR_SCALE
the anchor position of the heading text relative to the center of the instrument


HEADING_TEXT

private static final TextProperties HEADING_TEXT
the text properties of the heading


MAP_WINDOW_ANCHOR_SCALE

private static final CoordinateCartesianRelative MAP_WINDOW_ANCHOR_SCALE
the anchor position of the map window relative to the center of the instrument


MAP_WINDOW_OUTLINE_COLOR

private static final java.awt.Color MAP_WINDOW_OUTLINE_COLOR
the color of the window outline


MAP_WINDOW_OUTLINE_SCALE

private static final Scaler MAP_WINDOW_OUTLINE_SCALE
the size scale of the map-window outline relative to the instrument size


MAP_WINDOW_POWER_OFF_BODY_COLOR

private static final java.awt.Color MAP_WINDOW_POWER_OFF_BODY_COLOR
the color of the power button in off mode


MAP_WINDOW_POWER_ON_BODY_COLOR

public static final java.awt.Color MAP_WINDOW_POWER_ON_BODY_COLOR
the color of the power button in on mode


MAP_WINDOW_SIZE_SCALE

private static final ScalerPair MAP_WINDOW_SIZE_SCALE
the size scale of the window relative to the instrument size


NORTH_INDICATOR_COLOR

private static final java.awt.Color NORTH_INDICATOR_COLOR
the color of the barb indicating north


NORTH_INDICATOR_PRIMARY_OFFSET

private static final CoordinateWorld NORTH_INDICATOR_PRIMARY_OFFSET
the length of the north-indicator barb


NORTH_INDICATOR_SECONDARY_OFFSET

private static final CoordinateWorld NORTH_INDICATOR_SECONDARY_OFFSET
the length of the shortened north-indicator barb that is hidden by the regular one. This is a quick-and-dirty trick to keep the barb from disappearing in high zoom when the end of standard one is off the map and therefore not rendered


PROFILE_SAMPLE_WINDOW_SIZE

final int PROFILE_SAMPLE_WINDOW_SIZE
the number of altitude previous samples to display in the profile view

See Also:
Constant Field Values

PROFILE_VERTICAL_SIZE

final double PROFILE_VERTICAL_SIZE
the vertical size of the profile view relative to the map vertical size

See Also:
Constant Field Values

TRACK_HORIZONTAL_COLOR

private static final java.awt.Color TRACK_HORIZONTAL_COLOR
the color of the horizontal track


TRACK_SAMPLE_RATE

private static final int TRACK_SAMPLE_RATE
the sample rate as a function of calls to update() for recording track entries

See Also:
Constant Field Values

TRACK_VERTICAL_COLOR

private static final java.awt.Color TRACK_VERTICAL_COLOR
the color of the vertical track


ZOOM_DEFAULT

private static final double ZOOM_DEFAULT
the default zoom factor

See Also:
Constant Field Values

ZOOM_MAX

private static final double ZOOM_MAX
the maximum zoom factor

See Also:
Constant Field Values

ZOOM_MIN

private static final double ZOOM_MIN
the minimum zoom factor

See Also:
Constant Field Values

ZOOM_STEP

private static final double ZOOM_STEP
the zoom step

See Also:
Constant Field Values
Constructor Detail

GPSMap

public GPSMap(java.lang.String id,
              int canvasSize,
              CoordinateCartesianAbsolute canvasAnchor,
              NavigationChart chart)
Creates a GPS map.

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
chart - - the chart providing the navigational elements
Method Detail

configureControls

private void configureControls()
Configures the control.s


getChart

public NavigationChart getChart()
Gets the navigation chart.

Returns:
the chart

getSpatialDescriptor

public SevenDOFDescriptor getSpatialDescriptor()
Gets the spatial descriptor of the aircraft.

Returns:
the descriptor

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

mapWindowCoordinateToWorldCoordinate_

public CoordinateWorld mapWindowCoordinateToWorldCoordinate_(CoordinateCartesianAbsolute coordinateWindow)
Translates a window coordinate in pixels to a world coordinate in latitude and longitude.

Specified by:
mapWindowCoordinateToWorldCoordinate_ in interface I_WorldMappable
Parameters:
coordinateWindow - - the window coordinate
Returns:
the world coordinate, or null if the window coordinate is off the world

mapWorldCoordinateToWindowCoordinate_

public CoordinateCartesianAbsolute mapWorldCoordinateToWindowCoordinate_(CoordinateWorld coordinateWorld)
Translates a world coordinate in latitude and longitude to a window coordinate in pixels.

Specified by:
mapWorldCoordinateToWindowCoordinate_ in interface I_WorldMappable
Parameters:
coordinateWorld - - the world coordinate
Returns:
the window coordinate, or null if the world coordinate is off the window

mapWorldDistanceToWindowDistance_

public double mapWorldDistanceToWindowDistance_(Latitude distance)
Computes a world distance in latitude to a window distance in pixels.

Specified by:
mapWorldDistanceToWindowDistance_ in interface I_WorldMappable
Parameters:
distance - - the world distance
Returns:
the pixel distance

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class A_Instrument

render

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

Overrides:
render in class A_RectangularInstrument
Parameters:
graphics - - the graphics context

renderAirplane

private void renderAirplane()
Renders the needle.


renderChart

private void renderChart(boolean areDetailsVisible)
Renders the chart.

Parameters:
areDetailsVisible - - whether to render details at the current zoom level

renderControls

private void renderControls()
Renders the controls.


renderGrid

private void renderGrid()
Renders the latitude/longitude grid.


renderInfo

private void renderInfo()
Renders the text information.


renderMapFrame

private void renderMapFrame()
Renders the map frame.


renderMapWindow

private void renderMapWindow()
Renders the map window.


renderNorthIndicator

private void renderNorthIndicator(CoordinateWorld coordinate)
Renders the barb indicate north from the aircraft.

Parameters:
coordinate - - the coordinate of the end of the barb

renderTrackHorizontal

private void renderTrackHorizontal()
Renders the aircraft horizontal track.


renderTrackVertical

private void renderTrackVertical()
Renders the aircraft vertical track.


sampleTrack

private void sampleTrack()
Records a entry in the track history at the defined sample rate.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

update

public void update(SevenDOFDescriptor spatialDescriptor)
Updates the state of the instrument without rendering it.

Parameters:
spatialDescriptor - - the spatial descriptor

updateMapScale

private void updateMapScale()
Updates the map scale.