public class Joystick extends WidgetWithListener implements MouseListener, ThirdEventThread.ThirdEventWidget
Notes:
Button.ButtonListener
to send the button events,setDisableEnter(boolean)
method.Modifier and Type | Class and Description |
---|---|
static interface |
Joystick.JoystickListener
Interface that handle joystick buttons events.
|
static class |
Joystick.JoystickListenerToCommandEvents
Default implementation of
Joystick.JoystickListener . |
Widget.WidgetAttribute, Widget.WidgetDescription
MouseListener.MouseButton
DEFAULT_LABEL
Constructor and Description |
---|
Joystick()
Creates a joystick widget.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes the widget's associated resources (such as threads, images...).
|
void |
finalizeConfiguration()
Checks whether the widget configuration is valid or not and finalizes the widget configuration according all
attributes previously set.
|
int |
getSleepPeriod()
The thread sleep period is different than buttons period: thread should work faster than the buttons period in
order to be able to simulate several repeat event on several buttons.
|
void |
mousePressed(int x,
int y,
MouseListener.MouseButton button)
Invoked when a mouse has been pressed on a widget.
|
void |
mouseReleased(int x,
int y,
MouseListener.MouseButton button)
Invoked when a mouse has been released on a widget.
|
protected Object |
newDefaultListener()
Lets subclass creates a default listener.
|
void |
sendThirdEvent()
Asks to send the third event.
|
void |
setDisableEnter(boolean disableEnter)
Disables enter button.
|
void |
setDownSkin(Image skin)
Sets the skin to show joystick DOWN action.
|
void |
setEnterSkin(Image skin)
Sets the skin to show joystick ENTER action.
|
void |
setLeftSkin(Image skin)
Sets the skin to show joystick LEFT action.
|
void |
setListenerClass(String listenerClassName)
Defines the user class which has to implement
Joystick.JoystickListener . |
void |
setRepeatPeriod(int period)
Sets the repeat event period.
|
void |
setRightSkin(Image skin)
Sets the skin to show joystick RIGHT action.
|
void |
setUpSkin(Image skin)
Sets the skin to show joystick UP action.
|
void |
start()
Starts the widget.
|
newListener, setListenerClass
getAbsoluteX, getAbsoluteY, getCurrentSkin, getFilter, getHeight, getLabel, getParent, getSkin, getWidth, getX, getY, isOver, repaint, repaint, setCurrentSkin, setFilter, setHeight, setLabel, setOverlay, setSkin, setWidth, setX, setY, showYourself
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
public Joystick()
The default repeat period is 200ms.
public void dispose()
Widget
Default behavior disposes the common images and subclasses should override this method to define their own behavior.
This method should only be called by front panel engine.
public void finalizeConfiguration()
Widget
The widget attributes are set by the front panel parser but the order is not defined. This method allows to perform some checks between several attributes (this method is called by the front panel parser after setting all attributes defined in front panel file).
The configuration validation depends on widget itself. Each subclass must verify its configuration after checking its parent configuration.
When framework calling this method, all device widgets are not created and finalized yet, and by extension the
device itself is not fully created too. So the implementation must not have to call some methods on other widgets
and the methods Device.getDevice()
or FrontPanel.getDevice()
. As soon as all widgets are created
and finalized, the simulation starts calling the method Widget.start()
on each widget. As this moment only, the
widget is able to use the other widgets and the device itself.
On configuration error, a RuntimeException
(or a subclass of RuntimeException
) must be thrown.
This method should only be called by front panel parser.
finalizeConfiguration
in class Widget
public int getSleepPeriod()
getSleepPeriod
in interface ThirdEventThread.ThirdEventWidget
public void mousePressed(int x, int y, MouseListener.MouseButton button)
MouseListener
mousePressed
in interface MouseListener
x
- the mouse x coordinate relative to widget position.y
- the mouse y coordinate relative to widget position.button
- the button that has been pressed.public void mouseReleased(int x, int y, MouseListener.MouseButton button)
MouseListener
mouseReleased
in interface MouseListener
x
- the mouse x coordinate relative to widget position.y
- the mouse y coordinate relative to widget position.button
- the button that has been released.protected Object newDefaultListener()
WidgetWithListener
newDefaultListener
in class WidgetWithListener
public void sendThirdEvent()
ThirdEventThread.ThirdEventWidget
sendThirdEvent
in interface ThirdEventThread.ThirdEventWidget
public void setDisableEnter(boolean disableEnter)
This method should only be called by front panel parser.
disableEnter
- true to disable enter button.public void setDownSkin(Image skin)
This method should only be called by front panel parser.
skin
- skin for joystick DOWN action.public void setEnterSkin(Image skin)
This method should only be called by front panel parser.
skin
- skin for joystick ENTER action.public void setLeftSkin(Image skin)
This method should only be called by front panel parser.
skin
- skin for joystick LEFT action.public void setListenerClass(String listenerClassName)
Joystick.JoystickListener
.
This method should only be called by front panel parser.
listenerClassName
- user listener class name.public void setRepeatPeriod(int period)
This method should only be called by front panel parser.
period
- a time in milliseconds.public void setRightSkin(Image skin)
This method should only be called by front panel parser.
skin
- skin for joystick RIGHT action.public void setUpSkin(Image skin)
This method should only be called by front panel parser.
skin
- skin for joystick UP action.public void start()
Widget
Widget.finalizeConfiguration()
).
Main implementation does nothing.
This method should only be called by front panel engine.