at.wisch.joystick.ffeffect
Class Effect

java.lang.Object
  extended by at.wisch.joystick.ffeffect.Effect
Direct Known Subclasses:
ConditionEffect, ExtendedEffect

public abstract class Effect
extends java.lang.Object

The Class Effect. An Effect object represents an actual force feedback effect to be played on an FFJoystick.

To play an effect you have to instantiate it with 'new', after that you can set or change certain parameters.
- You can use the default constructor with no parameters, which creates an effect with default settings. After that you can change its parameters using setter methods.
- Or you can use the advanced constructor where you submit all properties at initialization. You can change the properties using setter as well.

An Effect can be uploaded to several devices. It can also be altered to update the effect on the device. That can be done even while the effect is playing. To get to know how to upload, play, update, pause, stop or delete an effect on the device see FFJoystick.

Author:
Martin Wischenbart
See Also:
FFJoystick, Direction

Field Summary
static int EFFECT_CONSTANT
          The constant EFFECT_CONSTANT: the object is a ConstantEffect (casting is safe).
static int EFFECT_CUSTOM
          The constant EFFECT_CUSTOM: the object is a CustomEffect (casting is safe).
static int EFFECT_DAMPER
          The constant EFFECT_DAMPER: the object is a DamperEffect (casting is safe).
static int EFFECT_FRICTION
          The constant EFFECT_FRICTION: the object is a FrictionEffect (casting is safe).
static int EFFECT_INERTIA
          The constant EFFECT_INERTIA: the object is a InertiaEffect (casting is safe).
static int EFFECT_RAMP
          The constant EFFECT_RAMP: the object is a RampEffect (casting is safe).
static int EFFECT_SAWTOOHDOWN
          The constant EFFECT_SAWTOOHDOWN: the object is a SawtoothDownEffect (casting is safe).
static int EFFECT_SAWTOOTHUP
          The constant EFFECT_SAWTOOTHUP: the object is a SawtoothUpEffect (casting is safe).
static int EFFECT_SINE
          The constant EFFECT_SINE: the object is a SineEffect (casting is safe).
static int EFFECT_SPRING
          The constant EFFECT_SPRING: the object is a SpringEffect (casting is safe).
static int EFFECT_SQUARE
          The constant EFFECT_SQUARE: the object is a SquareEffect (casting is safe).
static int EFFECT_TRIANGLE
          The constant EFFECT_TRIANGLE: the object is a TriangleEffect (casting is safe).
static int INFINITE_LENGTH
          The constant INFINITE_LENGTH: use this constant to set infinite length for an effect..
static int MAX_DELAY
          The constant MAX_DELAY (60000 ms): 60 seconds - the maximum delay for starting an effect, also the maximum interval for buttons triggering effects.
static int MAX_LENGTH
          The constant MAX_LENGTH (360000000 ms): 100 hours - the maximum length for an effect.
static int MAX_LEVEL
          The constant MAX_LEVEL (32767): this is the maximum parameter value for some Effect properties: strength, level, ...
static int MIN_LEVEL
          The constant MIN_LEVEL (-32768): this is the minimum parameter value (to the negative side) for some Effect properties.
static int NO_BUTTON
          The constant NO_BUTTON: use this constant to set no trigger button for the effect.
 
Method Summary
 int getButtonIndex()
          Gets the index of the button which is set to trigger the Effect.
 int getButtonInterval()
          Gets the currently set button interval.
static Direction getDefaultDirection()
          Gets the default direction.
 int getEffectDelay()
          Gets the effect delay before the effect will be started.
 int getEffectLength()
          Gets the effect length in ms.
 int getEffectType()
          Gets the effect type.
abstract  java.lang.String getName()
          Gets the effect type as a String.
abstract  int getStrength()
          Gets the strength.
 void setButtonIndex(int buttonIndex)
          Deprecated. trigger buttons are not supported on all operating systems. To stay platform independent you should trigger effects manually from events. See ControllerButtonEvent
 void setButtonInterval(int buttonInterval)
          Deprecated. trigger buttons are not supported on all operating systems. To stay platform independent you should trigger effects manually from events. See ControllerButtonEvent
static boolean setDefaultDirection(Direction direction)
          Sets the default direction.
 void setEffectDelay(int effectDelay)
          Sets the effect delay before the effect will be started.
 void setEffectLength(int effectLength)
          Sets the effect length in ms.
abstract  void setStrength(int strength)
          Sets the strength for an effect.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EFFECT_CONSTANT

public static final int EFFECT_CONSTANT
The constant EFFECT_CONSTANT: the object is a ConstantEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_SINE

public static final int EFFECT_SINE
The constant EFFECT_SINE: the object is a SineEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_SQUARE

public static final int EFFECT_SQUARE
The constant EFFECT_SQUARE: the object is a SquareEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_TRIANGLE

public static final int EFFECT_TRIANGLE
The constant EFFECT_TRIANGLE: the object is a TriangleEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_SAWTOOTHUP

public static final int EFFECT_SAWTOOTHUP
The constant EFFECT_SAWTOOTHUP: the object is a SawtoothUpEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_SAWTOOHDOWN

public static final int EFFECT_SAWTOOHDOWN
The constant EFFECT_SAWTOOHDOWN: the object is a SawtoothDownEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_RAMP

public static final int EFFECT_RAMP
The constant EFFECT_RAMP: the object is a RampEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_SPRING

public static final int EFFECT_SPRING
The constant EFFECT_SPRING: the object is a SpringEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_DAMPER

public static final int EFFECT_DAMPER
The constant EFFECT_DAMPER: the object is a DamperEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_INERTIA

public static final int EFFECT_INERTIA
The constant EFFECT_INERTIA: the object is a InertiaEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_FRICTION

public static final int EFFECT_FRICTION
The constant EFFECT_FRICTION: the object is a FrictionEffect (casting is safe).

See Also:
Constant Field Values

EFFECT_CUSTOM

public static final int EFFECT_CUSTOM
The constant EFFECT_CUSTOM: the object is a CustomEffect (casting is safe).

See Also:
Constant Field Values

NO_BUTTON

public static final int NO_BUTTON
The constant NO_BUTTON: use this constant to set no trigger button for the effect.

See Also:
Constant Field Values

INFINITE_LENGTH

public static final int INFINITE_LENGTH
The constant INFINITE_LENGTH: use this constant to set infinite length for an effect..

See Also:
Constant Field Values

MAX_LEVEL

public static final int MAX_LEVEL
The constant MAX_LEVEL (32767): this is the maximum parameter value for some Effect properties: strength, level, ...

See Also:
Constant Field Values

MIN_LEVEL

public static final int MIN_LEVEL
The constant MIN_LEVEL (-32768): this is the minimum parameter value (to the negative side) for some Effect properties.

See Also:
Constant Field Values

MAX_DELAY

public static final int MAX_DELAY
The constant MAX_DELAY (60000 ms): 60 seconds - the maximum delay for starting an effect, also the maximum interval for buttons triggering effects.

See Also:
Constant Field Values

MAX_LENGTH

public static final int MAX_LENGTH
The constant MAX_LENGTH (360000000 ms): 100 hours - the maximum length for an effect.

See Also:
Constant Field Values
Method Detail

getEffectType

public int getEffectType()
Gets the effect type. One of the following: EFFECT_CONSTANT, EFFECT_SINE, EFFECT_SQUARE, EFFECT_TRIANGLE, EFFECT_SAWTOOTHUP, EFFECT_SAWTOOTHDOWN, EFFECT_RAMP, EFFECT_SPRING, EFFECT_DAMPER, EFFECT_INERTIA, EFFECT_FRICTION or EFFECT_CUSTOM.

Returns:
the effect type
See Also:
getName()

getEffectLength

public int getEffectLength()
Gets the effect length in ms.

Returns:
the effect length in ms
See Also:
setEffectLength(int)

setEffectLength

public void setEffectLength(int effectLength)
Sets the effect length in ms. You can also set it to INFINITE_LENGTH to make the effect last for infinite time or until it is stopped.

Parameters:
effectLength - the new effect length (an int from 0 to MAX_LENGTH (360000000 ms ) or INFINITE_LENGTH)
See Also:
getEffectLength()

getEffectDelay

public int getEffectDelay()
Gets the effect delay before the effect will be started.

Returns:
the effect delay
See Also:
setEffectDelay(int)

setEffectDelay

public void setEffectDelay(int effectDelay)
Sets the effect delay before the effect will be started.

Parameters:
effectDelay - the new effect delay (an int from 0 to MAX_DELAY (60000 ms))
See Also:
getEffectDelay()

getButtonIndex

public int getButtonIndex()
Gets the index of the button which is set to trigger the Effect.

Returns:
the button index

setButtonIndex

@Deprecated
public void setButtonIndex(int buttonIndex)
Deprecated. trigger buttons are not supported on all operating systems. To stay platform independent you should trigger effects manually from events. See ControllerButtonEvent

Sets the button index, the index of the button which will trigger the Effect to be played, or NO_BUTTON. Once the effect is uploaded to the device, pressing this button will play the effect.

Parameters:
buttonIndex - the new button index
See Also:
getButtonIndex(), Joystick.getButtonCount()

getButtonInterval

public int getButtonInterval()
Gets the currently set button interval.

Returns:
the button interval
See Also:
setButtonInterval(int), getButtonIndex()

setButtonInterval

@Deprecated
public void setButtonInterval(int buttonInterval)
Deprecated. trigger buttons are not supported on all operating systems. To stay platform independent you should trigger effects manually from events. See ControllerButtonEvent

Sets the button interval. This interval defines how soon an effect can be triggered again by a button after the button was pressed.

Parameters:
buttonInterval - the new button interval (an int from 0 to MAX_DELAY (60000 ms ))
See Also:
getButtonInterval(), setButtonIndex(int)

setStrength

public abstract void setStrength(int strength)
Sets the strength for an effect. Every kind of effect has some way to set its strength or intensity. This is for convenience only, so we can use FFJoystick.getSimpleEffect() and later set strength without knowing what type of effect we actually have. If you know the type of effect, use the effect specific methods instead.

Parameters:
strength - the new strength (an int from 0 to MAX_LEVEL (32767))
See Also:
getStrength(), FFJoystick.getSimpleEffect()

getStrength

public abstract int getStrength()
Gets the strength. The strength tells us about the intensity of an effect. Depending on the type of effect the strength is computed differently. If you know the type of effect, use the effect specific methods instead.

Returns:
the strength
See Also:
setStrength(int)

getName

public abstract java.lang.String getName()
Gets the effect type as a String.

Returns:
the effect type as a String: one of the following: "Constant", "Sine", "Square", "Triangle", "SawtoothUp", "SawtoothDown", "Ramp", "Spring", "Inertia", "Damper", "Friction" or "Custom"
See Also:
getEffectType()

getDefaultDirection

public static Direction getDefaultDirection()
Gets the default direction. The default direction is used for all Effect objects that are initialized without a direction specified. If nothing is set, the "default" defaultDirection is PolarDirection.NORTHWEST.

Returns:
the default Direction
See Also:
setDefaultDirection(Direction)

setDefaultDirection

public static boolean setDefaultDirection(Direction direction)
Sets the default direction. The default direction is used for all Effect objects that are initialized without a direction specified.

Parameters:
direction - the direction object
Returns:
true, if successful. false, otherwise.
See Also:
getDefaultDirection()