net.jinx.action.input.robot
Class AbstractControl

java.lang.Object
  extended by net.jinx.action.input.robot.AbstractControl
All Implemented Interfaces:
Control
Direct Known Subclasses:
AxisControl, ButtonControl, SliderControl

public abstract class AbstractControl
extends java.lang.Object
implements Control

Abstract implementation of Control with most parts implemented for you. All you have to do is implement the valueChange() method.

API Stability: Alpha.


Field Summary
 
Fields inherited from interface net.jinx.action.input.robot.Control
TYPE_AXIS, TYPE_BUTTON, TYPE_SLIDER, TYPE_TOGGLE
 
Constructor Summary
protected AbstractControl(java.lang.String name, int type)
          Constructs an AbstractControl.
 
Method Summary
 java.lang.String getName()
          Returns the name of this Control.
 int getType()
          Returns the type constant for this Control.
 float getValue()
          Returns the value of this Control.
 void setValue(float value)
          Sets the value of this Control.
protected abstract  void valueChange()
          This is called when the value of this control has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractControl

protected AbstractControl(java.lang.String name,
                          int type)
Constructs an AbstractControl.

Parameters:
name - the name of this Control.
type - one of the TYPE_* constants from the Control interface. No checking will be performed on this value.
Method Detail

getName

public java.lang.String getName()
Returns the name of this Control.

Specified by:
getName in interface Control
Returns:
the name as a String.

setValue

public void setValue(float value)
Sets the value of this Control. The value is clamped between -1 and 1. if the value is different from the previous value, valueChnaged() is called.

Specified by:
setValue in interface Control
Parameters:
value - the new value for this Control.

valueChange

protected abstract void valueChange()
This is called when the value of this control has changed.


getValue

public float getValue()
Returns the value of this Control.

Specified by:
getValue in interface Control
Returns:
the value.

getType

public int getType()
Returns the type constant for this Control.

Specified by:
getType in interface Control
Returns:
one of the TYPE_* constants from Control.