stella.jview
Class JSliderParameter

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.jview.JSliderParameter
All Implemented Interfaces:
Cloneable, Displayable, Parameter, Trigger, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class JSliderParameter
extends AbstractParameter
implements Value, Trigger, Displayable

A slider parameter is a Value or Trigger that is entered into the system by moving a slider in a window. It is typically used for testing the response of the system to certain parameters. As the same class is used for Values and Triggers, be aware that a slider parameter might throw a number format exception if called on the 'wrong end'.
The following properties are required for a slider parameter:

Note that displaying the sliders is in most cases achieved with a dirty trick. To allow testing programs to use the same ParameterClustering instance as the real world, a JFrameParameter should also be present in the parameter list of the cluster. Each slider parameter can than display itself when the JFrameParameter.registerParameter(stella.Parameter) with the slider as the parameter is called.


Nested Class Summary
protected  class JSliderParameter.SliderListener
          Handles slide events.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static int DEFCOARSENESS
          The default parameter resolution.
private static DecimalFormat DEFFORMAT
          The default number format to use for labels.
private static int DEFLABELSPACING
          The default label spacing.
private static String DEFNAME
          A default name.
private static int DEFTICKSPACING
          The default tick spacing.
private  NumberFormat format
          The decimal formatter to use for the labels.
static String KEY_COARSENESS
          The key to the number of points in the slider, one for triggers.
static String KEY_LABELSPACING
          The key to the spacing of the labels.
static String KEY_MAX
          The key to the maximum value of the paramter, 'true' for triggers.
static String KEY_MIN
          The key to the minimum value of the paramter, 'false' for triggers.
static String KEY_TICKSPACING
          The key to the spacing of the slider ticks.
private  double scale
          The scale of the slider.
private  JLabel showvalue
          The converted value of this parameter.
private  JSlider slider
          The slider for this parameter.
private  Trigger trigger
          The auxilliar trigger object.
private  Value value
          Tha auxilliar value object.
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
JSliderParameter(Map info)
          Constructs a new slider parameter.
 
Method Summary
 Object get()
          Returns the value of this parameter.
 long getElapsedToggleTime()
          Returns the time elapsed since the last toggle event.
 Icon getIcon()
          Might return an icon, if one was stated in the properties
 Date getLastToggleTime()
          Returns the last toggle time.
 Component getRepresentation()
          Returns a panel consiting of a label giving the parameter name, an non-editable text-field giving the current value of the parameter and the actual slider.
 Boolean getTrigger()
          Returns the parameter as a Boolean.
 Number getValue()
          Returns the slider parameter's value.
 void init()
          Initializes the slider parameter.
 boolean isTrue()
          Returns true if this slider is on its right edge.
 Object set(Object val)
          Sets the value of this parameter.
 Boolean setTrigger(Boolean to)
          Sets the parameter as a Boolean.
 Number setValue(Number num)
          Sets the slider parameter's value.
 Boolean toggleTrigger()
          Toggles the trigger.
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, rescanned, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Parameter
getFormatted, getName, getString
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_MIN

public static final String KEY_MIN
The key to the minimum value of the paramter, 'false' for triggers.

See Also:
Constant Field Values

KEY_MAX

public static final String KEY_MAX
The key to the maximum value of the paramter, 'true' for triggers.

See Also:
Constant Field Values

KEY_TICKSPACING

public static final String KEY_TICKSPACING
The key to the spacing of the slider ticks. Zero for no ticks.

See Also:
Constant Field Values

KEY_LABELSPACING

public static final String KEY_LABELSPACING
The key to the spacing of the labels. Zero for no labels.

See Also:
Constant Field Values

KEY_COARSENESS

public static final String KEY_COARSENESS
The key to the number of points in the slider, one for triggers.

See Also:
Constant Field Values

DEFNAME

private static final String DEFNAME
A default name.

See Also:
Constant Field Values

DEFTICKSPACING

private static final int DEFTICKSPACING
The default tick spacing.

See Also:
Constant Field Values

DEFLABELSPACING

private static final int DEFLABELSPACING
The default label spacing.

See Also:
Constant Field Values

DEFCOARSENESS

private static final int DEFCOARSENESS
The default parameter resolution.

See Also:
Constant Field Values

DEFFORMAT

private static final DecimalFormat DEFFORMAT
The default number format to use for labels.


slider

private JSlider slider
The slider for this parameter.


showvalue

private JLabel showvalue
The converted value of this parameter. Displayed in a text field.


scale

private double scale
The scale of the slider. Zero means trigger.


format

private NumberFormat format
The decimal formatter to use for the labels.


trigger

private Trigger trigger
The auxilliar trigger object.


value

private Value value
Tha auxilliar value object.

Constructor Detail

JSliderParameter

public JSliderParameter(Map info)
Constructs a new slider parameter. The KEY_TICKSPACING, the KEY_LABELSPACING, the KEY_COARSENESS, and the AbstractParameter.KEY_FORMAT adopt their default value. Construction of the layout is deferred to the getRepresentation() method.

Method Detail

init

public void init()
Initializes the slider parameter. Defines minimum/maximum and the jcomponent.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractParameter

getIcon

public Icon getIcon()
Might return an icon, if one was stated in the properties

Specified by:
getIcon in interface Displayable

getRepresentation

public Component getRepresentation()
Returns a panel consiting of a label giving the parameter name, an non-editable text-field giving the current value of the parameter and the actual slider. Depending on the KEY_TICKSPACING and the KEY_LABELSPACING, ticks and labels are displayed on the slider.

Specified by:
getRepresentation in interface Displayable

get

public Object get()
Returns the value of this parameter. If this parameter is a trigger, a Boolean instance is returned, otherwise the return type is a Double instance.

Specified by:
get in interface Parameter

set

public Object set(Object val)
Sets the value of this parameter. Additionally, the slider is adjusted to the exact position.

Specified by:
set in interface Parameter
Returns:
The previous value of this parameter.

getValue

public Number getValue()
Returns the slider parameter's value.

Specified by:
getValue in interface Value

setValue

public Number setValue(Number num)
Sets the slider parameter's value. Additionally, the slider position is updated.

Specified by:
setValue in interface Value

getTrigger

public Boolean getTrigger()
Returns the parameter as a Boolean.

Specified by:
getTrigger in interface Trigger

isTrue

public boolean isTrue()
Returns true if this slider is on its right edge.

Specified by:
isTrue in interface Trigger

setTrigger

public Boolean setTrigger(Boolean to)
Sets the parameter as a Boolean. Additionally, the slider position is updated.

Specified by:
setTrigger in interface Trigger

toggleTrigger

public Boolean toggleTrigger()
Toggles the trigger.

Specified by:
toggleTrigger in interface Trigger

getLastToggleTime

public Date getLastToggleTime()
Returns the last toggle time.

Specified by:
getLastToggleTime in interface Trigger

getElapsedToggleTime

public long getElapsedToggleTime()
Returns the time elapsed since the last toggle event.

Specified by:
getElapsedToggleTime in interface Trigger