etomica.graphics
Class DeviceToggleRadioButtons

java.lang.Object
  extended by etomica.graphics.Device
      extended by etomica.graphics.DeviceToggleRadioButtons
All Implemented Interfaces:
GraphicalElement, Dimensioned

public class DeviceToggleRadioButtons
extends Device

Button that toggles a boolean value using a pair of radio buttons. This device can connect to any object capable of switching between two states. The device operates through a ModifierBoolean instance that must be connected to the state of the controlled object.


Nested Class Summary
 
Nested classes/interfaces inherited from class etomica.graphics.Device
Device.ActionSet
 
Field Summary
 
Fields inherited from class etomica.graphics.Device
controller, unit
 
Constructor Summary
DeviceToggleRadioButtons(ModifierBoolean modifier)
          Constructor with default labels of a blank title and "True" and "False" for the true/false labels.
DeviceToggleRadioButtons(ModifierBoolean modifier, String title, String trueText, String falseText)
           
 
Method Summary
 JRadioButton falseButton()
           
static EtomicaInfo getEtomicaInfo()
           
 String getFalseLabel()
           
 ModifierBoolean getModifier()
          Specifies the boolean modifier that is set between true and false by the button.
 boolean getState()
          Returns the currents true/false state of the button.
 String getTitle()
           
 String getTrueLabel()
           
 Component graphic(Object obj)
          Returns the GUI button element for display in the simulation.
 void setFalseLabel(String text)
          Specifies the button's label when the toggle is set to false.
 void setModifier(ModifierBoolean newModifier)
          Returns the boolean modifier set by this button.
 void setState(boolean b)
          Sets the button to the given state.
 void setTitle(String text)
           
 void setTrueLabel(String text)
          Specifies the button's label when the toggle is set to true.
 JRadioButton trueButton()
           
 
Methods inherited from class etomica.graphics.Device
doAction, getController, getDimension, getPostAction, getPreAction, getUnit, graphic, setController, setPostAction, setPreAction, setUnit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeviceToggleRadioButtons

public DeviceToggleRadioButtons(ModifierBoolean modifier)
Constructor with default labels of a blank title and "True" and "False" for the true/false labels.


DeviceToggleRadioButtons

public DeviceToggleRadioButtons(ModifierBoolean modifier,
                                String title,
                                String trueText,
                                String falseText)
Parameters:
sim - the parent simulation of this device
modifier - the boolean modifier controlled by this device
title - a descriptive string. If empty ("") provides plain border; if null, provides no border.
trueText - text associated with "true" state of modifier
falseText - text associated with "false" state of modifier
Method Detail

getEtomicaInfo

public static EtomicaInfo getEtomicaInfo()

setState

public void setState(boolean b)
Sets the button to the given state.


getState

public boolean getState()
Returns the currents true/false state of the button.


getModifier

public ModifierBoolean getModifier()
Specifies the boolean modifier that is set between true and false by the button.


setModifier

public void setModifier(ModifierBoolean newModifier)
Returns the boolean modifier set by this button.


graphic

public Component graphic(Object obj)
Returns the GUI button element for display in the simulation.

Specified by:
graphic in interface GraphicalElement
Specified by:
graphic in class Device
Parameters:
obj - An object that might be used to specify the graphic that the GraphicalElement is to return. In most cases the GraphicalElement ignores this parameter, and it can be set to null.
Returns:
A Component that can be used in the GUI of a graphical simulation
See Also:
Device, Display

setTitle

public void setTitle(String text)

getTitle

public String getTitle()

setTrueLabel

public void setTrueLabel(String text)
Specifies the button's label when the toggle is set to true.


getTrueLabel

public String getTrueLabel()
Returns:
the label displayed when the toggle is set to true.

setFalseLabel

public void setFalseLabel(String text)
Specifies the button's label when the toggle is set to false.


getFalseLabel

public String getFalseLabel()
Returns:
the label displayed when the toggle is set to false.

trueButton

public JRadioButton trueButton()
Returns:
the instance of the button selecting the "true" state. Useful to change it color or other graphics attributes.

falseButton

public JRadioButton falseButton()
Returns:
the instance of the button selecting the "false" state. Useful to change it color or other graphics attributes.