uk.ac.starlink.ttools.plot2.config
Class SliderSpecifier

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.config.SpecifierPanel<Double>
      extended by uk.ac.starlink.ttools.plot2.config.SliderSpecifier
All Implemented Interfaces:
Specifier<Double>

public class SliderSpecifier
extends SpecifierPanel<Double>

Double value specifier that uses a slider to choose a value in the range betwen two given values. Linear and logarithmic scaling are available. The slider can optionally be accompanied by a text entry field.

Since:
13 Jan 2014
Author:
Mark Taylor

Nested Class Summary
static class SliderSpecifier.TextOption
          Specifies whether and how a text display field should appear alongside the slider for user entry.
 
Constructor Summary
SliderSpecifier(double lo, double hi, boolean log, double reset)
          Constructs a specifier with minimal options.
SliderSpecifier(double lo, double hi, boolean log, double reset, boolean flip, SliderSpecifier.TextOption txtOpt)
          Constructs a specifier with all options.
 
Method Summary
protected  JComponent createComponent()
          Abstract method called lazily during getComponent to obtain the graphical component used by this specifier.
 JSlider getSlider()
          Returns the slider component used by this specifier.
 double getSliderValue()
          Returns the value currently represented by the slider, regardless of whether the slider or text field is currently active.
 Double getSpecifiedValue()
          Returns the typed value currently specified by the graphical component.
 JTextField getTextField()
          Returns the text entry component used by this specifier.
 double getTextValue()
          Returns the value currently entered in the text field, regardless of whether the text field or slider is currently active.
 boolean isSliderActive()
          Indicates whether the slider or the text field is the currently selected input component.
 void setSliderActive(boolean isActive)
          Configures programmatically whether the slider or the text field is the currently selected input component.
 void setSpecifiedValue(Double dValue)
          Sets the typed value represented by the graphical component.
 void submitReport(ReportMap report)
          Accepts information about a completed plot that was drawn with input from this specifier.
 String valueToString(double value)
          Formats a value provided by this specifier for display.
 
Methods inherited from class uk.ac.starlink.ttools.plot2.config.SpecifierPanel
addActionListener, fireAction, getActionForwarder, getChangeForwarder, getComponent, isXFill, removeActionListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SliderSpecifier

public SliderSpecifier(double lo,
                       double hi,
                       boolean log,
                       double reset)
Constructs a specifier with minimal options.

Parameters:
lo - slider lower bound
hi - slider upper bound
log - true for logarithmic slider scale, false for linear
reset - value reset button resets to, or NaN for no reset

SliderSpecifier

public SliderSpecifier(double lo,
                       double hi,
                       boolean log,
                       double reset,
                       boolean flip,
                       SliderSpecifier.TextOption txtOpt)
Constructs a specifier with all options.

Parameters:
lo - slider lower bound
hi - slider upper bound
log - true for logarithmic slider scale, false for linear
reset - value reset button resets to, or NaN for no reset
flip - true to make slider values increase right to left
txtOpt - configures whether a text field should appear; null means NONE
Method Detail

createComponent

protected JComponent createComponent()
Description copied from class: SpecifierPanel
Abstract method called lazily during getComponent to obtain the graphical component used by this specifier. It will be called a maximum of once. It is not necessary that the component actually be created in this method, for instance it may be created at construction time if that's more convenient.

Specified by:
createComponent in class SpecifierPanel<Double>
Returns:
graphical component

getSpecifiedValue

public Double getSpecifiedValue()
Description copied from interface: Specifier
Returns the typed value currently specified by the graphical component.

Returns:
specified value

setSpecifiedValue

public void setSpecifiedValue(Double dValue)
Description copied from interface: Specifier
Sets the typed value represented by the graphical component. Calling this method ought to make it clear to the user what value it is set at; in any case a subsequent call of getSpecifiedValue should yield the same result.

However if a value is set which is of the correct type but cannot be represented by this specifier, results are unpredictable.

Parameters:
dValue - new value

submitReport

public void submitReport(ReportMap report)
Description copied from interface: Specifier
Accepts information about a completed plot that was drawn with input from this specifier. In many cases, the implementation of this method will be a no-op, but it gives this object a chance to update its state or its component's appearance based on the way the plot was actually drawn, which may provide information not otherwise available to this object.

Parameters:
report - report of a plot partially specified by this object

isSliderActive

public boolean isSliderActive()
Indicates whether the slider or the text field is the currently selected input component.

Returns:
true for slider, false for text field

setSliderActive

public void setSliderActive(boolean isActive)
Configures programmatically whether the slider or the text field is the currently selected input component.

Parameters:
isActive - true for slider, false for text field

getTextValue

public double getTextValue()
Returns the value currently entered in the text field, regardless of whether the text field or slider is currently active.

Returns:
text field value as a double, may be NaN

getSliderValue

public double getSliderValue()
Returns the value currently represented by the slider, regardless of whether the slider or text field is currently active.

Returns:
slider value

getSlider

public JSlider getSlider()
Returns the slider component used by this specifier.

Returns:
slider

getTextField

public JTextField getTextField()
Returns the text entry component used by this specifier.

Returns:
text field

valueToString

public String valueToString(double value)
Formats a value provided by this specifier for display. The default implementation does something obvious, but may be overridden by subclasses.

Parameters:
value - double value as provided by this specifier
Returns:
string representation for preseentation to the user


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.