Package net.java.games.input
Class AbstractComponent
- java.lang.Object
-
- net.java.games.input.AbstractComponent
-
- All Implemented Interfaces:
Component
- Direct Known Subclasses:
LinuxJoystickPOV
,WinTabComponent
public abstract class AbstractComponent extends java.lang.Object implements Component
Skeleton implementation of a named axis.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.java.games.input.Component
Component.Identifier, Component.POV
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractComponent(java.lang.String name, Component.Identifier id)
Protected constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description float
getDeadZone()
Returns the suggested dead zone for this axis.Component.Identifier
getIdentifier()
Returns the type or identifier of the axis.java.lang.String
getName()
Returns a human-readable name for this axis.float
getPollData()
Returns the data from the last time the control has been polled.boolean
isAnalog()
Returns whether or not the axis is analog, or false if it is digital.protected abstract float
poll()
java.lang.String
toString()
Returns a non-localized string description of this axis.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.java.games.input.Component
isRelative
-
-
-
-
Constructor Detail
-
AbstractComponent
protected AbstractComponent(java.lang.String name, Component.Identifier id)
Protected constructor- Parameters:
name
- A name for the axis
-
-
Method Detail
-
getIdentifier
public Component.Identifier getIdentifier()
Returns the type or identifier of the axis.- Specified by:
getIdentifier
in interfaceComponent
-
isAnalog
public boolean isAnalog()
Returns whether or not the axis is analog, or false if it is digital.
-
getDeadZone
public float getDeadZone()
Returns the suggested dead zone for this axis. Dead zone is the amount polled data can vary before considered a significant change in value. An application can safely ignore changes less than this value in the positive or negative direction.- Specified by:
getDeadZone
in interfaceComponent
- Returns:
- 0.0f by default, can be overridden
- See Also:
Component.getPollData()
-
getPollData
public final float getPollData()
Returns the data from the last time the control has been polled. If this axis is a button, the value returned will be either 0.0f or 1.0f. If this axis is normalised, the value returned will be between -1.0f and 1.0f.- Specified by:
getPollData
in interfaceComponent
- Returns:
- The data from the last time the control has been polled.
- See Also:
Controller.poll()
-
getName
public java.lang.String getName()
Returns a human-readable name for this axis.
-
toString
public java.lang.String toString()
Returns a non-localized string description of this axis.- Overrides:
toString
in classjava.lang.Object
-
poll
protected abstract float poll() throws java.io.IOException
- Throws:
java.io.IOException
-
-