uavsim.graphics.controls
Class A_Control

java.lang.Object
  extended by uavsim.graphics.controls.A_Control
Direct Known Subclasses:
A_Button, A_Knob

public abstract class A_Control
extends java.lang.Object

Provides the shared functionality for all controls that belong to an instrument.

Author:
Dan Tappan [22.06.11]

Field Summary
private  A_Instrument _hostInstrument
          the host instrument that this control belongs to
protected  java.lang.String _id
          the unique control identifier
static java.awt.Cursor CURSOR_ARROW_DOWN
          the down-arrow cursor
static java.awt.Cursor CURSOR_ARROW_LEFT
          the left-arrow cursor
static java.awt.Cursor CURSOR_ARROW_RIGHT
          the right-arrow cursor
static java.awt.Cursor CURSOR_ARROW_UP
          the up-arrow cursor
static java.awt.Cursor CURSOR_CROSSHAIR
          the crosshair cursor
static java.awt.Cursor CURSOR_DEFAULT
          the default cursor
static java.awt.Cursor CURSOR_HAND
          the hand cursor
 
Constructor Summary
A_Control(java.lang.String id, A_Instrument hostInstrument)
          Creates an abstract control.
 
Method Summary
protected  CoordinateCartesianAbsolute calculateAnchor(A_ControlProperties properties)
          Calculates the absolute anchor coordinate of this control on its host instrument.
 A_Instrument getHostInstrument()
          Gets the host instrument that this control belongs to.
 java.lang.String getID()
          Gets the unique control identifier.
abstract  boolean handleMouseEvent_(java.awt.event.MouseEvent event)
          Handles a mouse event.
protected abstract  boolean isCoordinateHit(CoordinateCartesianAbsolute coordinate)
          Determines whether a screen coordinate is contained within the bounds of this control.
 void render(java.awt.Graphics2D graphics)
          Renders the controls.
 void resetCursor()
          Resets the cursor to the default.
 void setCursor(java.awt.Cursor cursor)
          Sets the cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_hostInstrument

private final A_Instrument _hostInstrument
the host instrument that this control belongs to


_id

protected final java.lang.String _id
the unique control identifier


CURSOR_ARROW_DOWN

public static final java.awt.Cursor CURSOR_ARROW_DOWN
the down-arrow cursor


CURSOR_ARROW_LEFT

public static final java.awt.Cursor CURSOR_ARROW_LEFT
the left-arrow cursor


CURSOR_ARROW_RIGHT

public static final java.awt.Cursor CURSOR_ARROW_RIGHT
the right-arrow cursor


CURSOR_ARROW_UP

public static final java.awt.Cursor CURSOR_ARROW_UP
the up-arrow cursor


CURSOR_CROSSHAIR

public static final java.awt.Cursor CURSOR_CROSSHAIR
the crosshair cursor


CURSOR_DEFAULT

public static final java.awt.Cursor CURSOR_DEFAULT
the default cursor


CURSOR_HAND

public static final java.awt.Cursor CURSOR_HAND
the hand cursor

Constructor Detail

A_Control

public A_Control(java.lang.String id,
                 A_Instrument hostInstrument)
Creates an abstract control.

Parameters:
id - - the unique control identifier
hostInstrument - - the control host instrument
Method Detail

calculateAnchor

protected CoordinateCartesianAbsolute calculateAnchor(A_ControlProperties properties)
Calculates the absolute anchor coordinate of this control on its host instrument.

Parameters:
properties - - the control properties
Returns:
the coordinate

getHostInstrument

public A_Instrument getHostInstrument()
Gets the host instrument that this control belongs to.

Returns:
the instrument

getID

public java.lang.String getID()
Gets the unique control identifier.

Returns:
the identifier

handleMouseEvent_

public abstract boolean handleMouseEvent_(java.awt.event.MouseEvent event)
Handles a mouse event.

Parameters:
event - - the event
Returns:
whether the mouse hovered over this control

isCoordinateHit

protected abstract boolean isCoordinateHit(CoordinateCartesianAbsolute coordinate)
Determines whether a screen coordinate is contained within the bounds of this control.

Parameters:
coordinate - - the coordinate
Returns:
the result

render

public void render(java.awt.Graphics2D graphics)
Renders the controls.

Parameters:
graphics - - the graphics context

resetCursor

public void resetCursor()
Resets the cursor to the default.


setCursor

public void setCursor(java.awt.Cursor cursor)
Sets the cursor.

Parameters:
cursor - - the cursor