uavsim.graphics.controls.knobs
Class A_Knob

java.lang.Object
  extended by uavsim.graphics.controls.A_Control
      extended by uavsim.graphics.controls.knobs.A_Knob
Direct Known Subclasses:
Knob

public abstract class A_Knob
extends A_Control

Provides the shared functionality of a basic interactive knob with clockwise and counterclockwise rotation.

Author:
Dan Tappan [22.06.11]

Field Summary
protected  Circle _body
          the knob body.
protected  KnobProperties _properties
          the knob properties
private static ArcMathematical ARC_DECREASE
          the left segment of the knob which decreases the knob value when clicked
private static ArcMathematical ARC_INCREASE
          the right segment of the knob which increases the knob value when clicked
 
Fields inherited from class uavsim.graphics.controls.A_Control
_id, CURSOR_ARROW_DOWN, CURSOR_ARROW_LEFT, CURSOR_ARROW_RIGHT, CURSOR_ARROW_UP, CURSOR_CROSSHAIR, CURSOR_DEFAULT, CURSOR_HAND
 
Constructor Summary
A_Knob(java.lang.String id, KnobProperties properties, A_Instrument hostInstrument)
          Creates an abstract knob control.
 
Method Summary
 KnobProperties getProperties()
          Gets the knob properties.
 boolean handleMouseEvent_(java.awt.event.MouseEvent mouseEvent)
          Handles a mouse event.
protected  boolean isCoordinateHit(CoordinateCartesianAbsolute point)
          Determines whether a screen coordinate is contained within the bounds of this control.
protected  boolean isCoordinateHit(CoordinateCartesianAbsolute point, ArcMathematical arc)
          Determines whether a point is on a segment of the knob.
 void render(java.awt.Graphics2D graphics)
          Renders the controls.
 java.lang.String toString()
          
 
Methods inherited from class uavsim.graphics.controls.A_Control
calculateAnchor, getHostInstrument, getID, resetCursor, setCursor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_body

protected Circle _body
the knob body. This initial object serves as a placeholder until render() supplies the real one based on the actual size


_properties

protected final KnobProperties _properties
the knob properties


ARC_DECREASE

private static final ArcMathematical ARC_DECREASE
the left segment of the knob which decreases the knob value when clicked


ARC_INCREASE

private static final ArcMathematical ARC_INCREASE
the right segment of the knob which increases the knob value when clicked

Constructor Detail

A_Knob

public A_Knob(java.lang.String id,
              KnobProperties properties,
              A_Instrument hostInstrument)
Creates an abstract knob control.

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

getProperties

public KnobProperties getProperties()
Gets the knob properties.

Returns:
the properties

handleMouseEvent_

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

Specified by:
handleMouseEvent_ in class A_Control
Parameters:
mouseEvent - - the event
Returns:
whether the mouse hovered over this control

isCoordinateHit

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

Specified by:
isCoordinateHit in class A_Control
Parameters:
point - - the coordinate
Returns:
the result

isCoordinateHit

protected boolean isCoordinateHit(CoordinateCartesianAbsolute point,
                                  ArcMathematical arc)
Determines whether a point is on a segment of the knob. This is typically used to determine whether an increase or decrease event has occurred.

Parameters:
point - - the point
arc - - the arc defining the segment
Returns:
the state

render

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

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

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object