etomica.graphics
Class DeviceSpinner

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

public class DeviceSpinner
extends Device

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

See Also:
ModifierGeneral

Nested Class Summary
protected  class DeviceSpinner.SpinnerListener
          Spinner listener, which relays the spinner change events to the modifier
 
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 spinner to the property
protected  String property
          Property being modulated
protected  JSpinner spinner
          Actual JSpinner
protected  SpinnerNumberModel spinnerModel
          Actual spinner model
protected  IAction targetAction
           
 
Fields inherited from class etomica.graphics.Device
controller, unit
 
Constructor Summary
DeviceSpinner(IController controller)
           
DeviceSpinner(IController controller, Modifier m)
          Constructs a spinner connected to the get/set Value methods of the given Modifier
DeviceSpinner(IController controller, Object object, String property)
          Constructs a spinner connected to the given property of the given object
 
Method Summary
 void doUpdate()
           
 Object getComponent()
           
 String getLabel()
           
 double getMaximum()
           
 double getMinimum()
           
 Modifier getModifier()
           
 JPanel getPanel()
           
 String getProperty()
           
 SpinnerNumberModel getSpinner()
           
 double getValue()
           
 Component graphic(Object obj)
          Returns the GUI element for display in the simulation.
 boolean isShowBorder()
           
 void setBorderAlignment(int align)
           
 void setComponent(Object obj)
           
 void setLabel(String s)
          Sets the value of a descriptive label using the given string.
 void setMaximum(double max)
          Sets maximum value of slider
 void setMinimum(double min)
          Sets minimum value of spinner
 void setModifier(Modifier m)
           
 void setProperty(String s)
           
 void setShowBorder(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
doAction, 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 spinner to the property


spinnerModel

protected SpinnerNumberModel spinnerModel
Actual spinner model


spinner

protected JSpinner spinner
Actual JSpinner


component

protected Object component
Object with property being modulated


property

protected String property
Property being modulated


targetAction

protected IAction targetAction
Constructor Detail

DeviceSpinner

public DeviceSpinner(IController controller)

DeviceSpinner

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


DeviceSpinner

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

Method Detail

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()

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 spinner


getMaximum

public double getMaximum()

setMaximum

public void setMaximum(double max)
Sets maximum value of slider


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()

getSpinner

public SpinnerNumberModel getSpinner()
Returns:
a handle to the SpinnerNumberModel instance used by this slider device

getPanel

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