jaron.pde
Class RadioButton

java.lang.Object
  extended by jaron.components.Signal
      extended by jaron.pde.RadioButton
All Implemented Interfaces:
SignalListener, java.util.EventListener

public class RadioButton
extends Signal

The RadioButton class provides a virtual on-off switch for the Processing Development Environment (PDE).
By extending the Signal class it can hook into the EventListener mechanism and thus receive and send numerical values.

Have a look at the example of the UAVsim for the usage of the RadioButton.

Since:
1.0
Version:
1.2
Author:
jarontec gmail com

Constructor Summary
RadioButton(processing.core.PApplet applet, int left, int top)
          Creates a new RadioButton object for the Processing Development Environment (PDE).
RadioButton(processing.core.PApplet applet, int left, int top, int width, int height)
          Creates a new RadioButton object for the Processing Development Environment (PDE).
RadioButton(processing.core.PApplet applet, java.lang.String label, int left, int top)
          Creates a new RadioButton object for the Processing Development Environment (PDE).
RadioButton(processing.core.PApplet applet, java.lang.String label, int left, int top, int width, int height)
          Creates a new RadioButton object for the Processing Development Environment (PDE).
 
Method Summary
 void draw()
          Draws the button to the screen.
 java.lang.Boolean isMouseOver()
          Returns true if the mouse is hovering over the butten.
 boolean isOn()
          Retuns true if the radio button is switched on and false if it is turned off.
 void mouseMoved(int x, int y)
          Handles a mouseMoved event that occurred in the GUI.
 void mousePressed(int x, int y)
          Acts on a mousePressed event that occurred in the Processing Development Environment.
 void mouseReleased(int x, int y)
          Acts on a mouseReleased event that occurred in the Processing Development Environment.
 void setLabel(java.lang.String label)
          Sets the button's label that is displayed underneath the button.
 void switchOff()
          Switches this button off.
 void switchOn()
          Switches this button on.
 
Methods inherited from class jaron.components.Signal
addSignalListener, getBandwidth, getHigh, getLow, getValue, removeSignalListener, setBandwidth, setHigh, setLow, setValue, signalChanged
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RadioButton

public RadioButton(processing.core.PApplet applet,
                   java.lang.String label,
                   int left,
                   int top,
                   int width,
                   int height)
Creates a new RadioButton object for the Processing Development Environment (PDE).

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
label - the label that is displayed at the bottom
left - the component's position from the left
top - the component's position from top
width - the component's width
height - the component's height

RadioButton

public RadioButton(processing.core.PApplet applet,
                   int left,
                   int top,
                   int width,
                   int height)
Creates a new RadioButton object for the Processing Development Environment (PDE).

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
left - the component's position from the left
top - the component's position from top
width - the component's width
height - the component's height

RadioButton

public RadioButton(processing.core.PApplet applet,
                   java.lang.String label,
                   int left,
                   int top)
Creates a new RadioButton object for the Processing Development Environment (PDE).

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
label - the label that is displayed at the bottom
left - the component's position from the left
top - the component's position from top

RadioButton

public RadioButton(processing.core.PApplet applet,
                   int left,
                   int top)
Creates a new RadioButton object for the Processing Development Environment (PDE).

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
left - the component's position from the left
top - the component's position from top
Method Detail

draw

public void draw()
Draws the button to the screen. This method should usually be called from the draw method of the Processing Development Environment. This ensures that the button is updated periodically.


isMouseOver

public java.lang.Boolean isMouseOver()
Returns true if the mouse is hovering over the butten.

Returns:
true if the mouse hovers over the button

mouseMoved

public void mouseMoved(int x,
                       int y)
Handles a mouseMoved event that occurred in the GUI.
This method should usually be called from the mouseMoved method of the GUI (e.g. in the Processing Development Environment). This ensures that the user interaction is received and processed by the control.

Parameters:
x - the current x value of the mouse
y - the current y value of the mouse

mousePressed

public void mousePressed(int x,
                         int y)
Acts on a mousePressed event that occurred in the Processing Development Environment. This method should usually be called from the mousePressed method of the PDE. This ensures that the user interaction is received and processed by the control.

Parameters:
x - the current x value of the mouse
y - the current y value of the mouse

mouseReleased

public void mouseReleased(int x,
                          int y)
Acts on a mouseReleased event that occurred in the Processing Development Environment. This method should usually be called from the mouseReleased method of the PDE. This ensures that the user interaction is received and processed by the control.

Parameters:
x - the current x value of the mouse
y - the current y value of the mouse

setLabel

public void setLabel(java.lang.String label)
Sets the button's label that is displayed underneath the button.

Parameters:
label - a String describing the button's functionality in short

switchOn

public void switchOn()
Switches this button on.


switchOff

public void switchOff()
Switches this button off.


isOn

public boolean isOn()
Retuns true if the radio button is switched on and false if it is turned off.

Returns:
true or false