etomica.graphics
Class DeviceSlider

java.lang.Object
  extended by etomica.graphics.Device
      extended by etomica.graphics.DeviceSlider
All Implemented Interfaces:
GraphicalElement, Dimensioned
Direct Known Subclasses:
DeviceNSelector

public class DeviceSlider
extends Device

Device the changes a property using a graphical slider, via a Modifier.

See Also:
ModifierGeneral

Nested Class Summary
 
Nested classes/interfaces inherited from class etomica.graphics.Device
Device.ActionSet
 
Field Summary
protected  Object component
          Object with property being modulated
protected  ModifyAction modifyAction
          Modifier connecting the slider to the property
protected  String property
          Property being modulated
protected  DecimalSlider slider
          Subclass of Swing slider displayed to screen located in utility package
protected  boolean suppressAction
           
protected  IAction targetAction
           
protected  JTextField textField
          To show the values of slider
 
Fields inherited from class etomica.graphics.Device
controller, unit
 
Constructor Summary
DeviceSlider(IController controller)
           
DeviceSlider(IController controller, Modifier m)
          Constructs a slider connected to the get/set Value methods of the given Modifier
DeviceSlider(IController controller, Object object, String property)
          Constructs a slider connected to the given property of the given object
 
Method Summary
 void doAction(IAction action)
          Method called by subclasses to execute the action of the device.
 void doUpdate()
           
 Object getComponent()
           
 boolean getEditValues()
           
 String getLabel()
           
 double getMaximum()
           
 double getMinimum()
           
 Modifier getModifier()
           
 int getNMajor()
           
 JPanel getPanel()
           
 int getPrecision()
           
 String getProperty()
           
 boolean getShowSlider()
           
 boolean getShowValues()
           
 DecimalSlider getSlider()
           
 JTextField getTextField()
           
 double getValue()
           
 Component graphic(Object obj)
          Returns the GUI element for display in the simulation.
 boolean isEnabled()
           
 boolean isShowBorder()
           
 void setBorderAlignment(int align)
           
 void setComponent(Object obj)
           
 void setEditValues(boolean b)
           
 void setEnabled(boolean isEnabled)
          Sets the deivce's slider and textfield to be enabled or not.
 void setLabel(String s)
          Sets the value of a descriptive label using the given string.
 void setMaximum(double max)
          Sets maximum value of slider; should be called after any calls to setPrecision.
 void setMinimum(double min)
          Sets minimum value of slider; should be called after any calls to setPrecision.
 void setModifier(Modifier m)
           
 void setNMajor(int n)
           
 void setPrecision(int n)
           
 void setProperty(String s)
           
 void setShowBorder(boolean b)
           
 void setShowMinorTicks(boolean b)
           
 void setShowSlider(boolean b)
           
 void setShowValues(boolean b)
           
 void setSliderValueShape(String s)
           
 void setSliderVerticalOrientation(boolean b)
           
 void setUnit(Unit u)
          Override superclass setUnit method to update label when unit is changed
 void setValue(double d)
           
 
Methods inherited from class etomica.graphics.Device
getController, getDimension, getPostAction, getPreAction, getUnit, graphic, setController, setPostAction, setPreAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifyAction

protected ModifyAction modifyAction
Modifier connecting the slider to the property


slider

protected DecimalSlider slider
Subclass of Swing slider displayed to screen located in utility package


component

protected Object component
Object with property being modulated


property

protected String property
Property being modulated


textField

protected JTextField textField
To show the values of slider


targetAction

protected IAction targetAction

suppressAction

protected boolean suppressAction
Constructor Detail

DeviceSlider

public DeviceSlider(IController controller)

DeviceSlider

public DeviceSlider(IController controller,
                    Object object,
                    String property)
Constructs a slider connected to the given property of the given object


DeviceSlider

public DeviceSlider(IController controller,
                    Modifier m)
Constructs a slider connected to the get/set Value methods of the given Modifier

Method Detail

setEnabled

public void setEnabled(boolean isEnabled)
Sets the deivce's slider and textfield to be enabled or not.


isEnabled

public boolean isEnabled()

setUnit

public void setUnit(Unit u)
Override superclass setUnit method to update label when unit is changed

Specified by:
setUnit in interface Dimensioned
Overrides:
setUnit in class Device

setBorderAlignment

public void setBorderAlignment(int align)

setModifier

public void setModifier(Modifier m)

getModifier

public final Modifier getModifier()

doUpdate

public void doUpdate()

doAction

public void doAction(IAction action)
Description copied from class: Device
Method called by subclasses to execute the action of the device. Action is specified by the subclass as the targetAction field; if this field is null, not action is performed. The action is normally performed by calling the doActionNow method of the controller, which causes the controller's thread to perform the action as soon as possible after suspending all simulation activities. If a controller has not been defined (is null), then the action is performed on the thread calling this method.

Overrides:
doAction in class Device

getProperty

public String getProperty()

setProperty

public void setProperty(String s)

getComponent

public Object getComponent()

setComponent

public void setComponent(Object obj)

getMinimum

public double getMinimum()

setMinimum

public void setMinimum(double min)
Sets minimum value of slider; should be called after any calls to setPrecision.


getMaximum

public double getMaximum()

setMaximum

public void setMaximum(double max)
Sets maximum value of slider; should be called after any calls to setPrecision.


setShowMinorTicks

public void setShowMinorTicks(boolean b)

setNMajor

public void setNMajor(int n)

getNMajor

public int getNMajor()

getShowSlider

public boolean getShowSlider()

setShowSlider

public void setShowSlider(boolean b)

getShowValues

public boolean getShowValues()

setShowValues

public void setShowValues(boolean b)

setSliderValueShape

public void setSliderValueShape(String s)

setSliderVerticalOrientation

public void setSliderVerticalOrientation(boolean b)

getEditValues

public boolean getEditValues()

setEditValues

public void setEditValues(boolean b)

getPrecision

public int getPrecision()

setPrecision

public void setPrecision(int n)

getValue

public double getValue()

setValue

public void setValue(double d)

graphic

public Component graphic(Object obj)
Returns the GUI 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

setLabel

public void setLabel(String s)
Sets the value of a descriptive label using the given string.


getLabel

public String getLabel()
Returns:
the current instance of the descriptive label.

setShowBorder

public void setShowBorder(boolean b)

isShowBorder

public boolean isShowBorder()

getSlider

public DecimalSlider getSlider()
Returns:
a handle to the DecimalSlider instance used by this slider device

getTextField

public JTextField getTextField()
Returns:
a handle to the JTextField instance used by this slider device

getPanel

public JPanel getPanel()
Returns:
a handle to the JPanel instance used by this slider device