Class TLcdRangeSlider

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, SwingConstants

public class TLcdRangeSlider extends JComponent implements SwingConstants
A component that lets the user graphically select a range by sliding a minimum and maximum knob within a bounded interval. The slider can display major tick marks, minor tick marks and labels. The range in between the knobs can be displayed too.
See Also:
  • Field Details

    • fRangeSliderModel

      protected TLcdRangeSliderModel fRangeSliderModel
      The data that handles the numeric maximum value, minimum value, and current-position value for the slider.
    • fChangeEvent

      protected ChangeEvent fChangeEvent
      Only one ChangeEvent is needed per slider instance since the event's only (read-only) state is the source property.
    • fSlideCursorFlag

      protected boolean fSlideCursorFlag
      If true, the cursor changes to a move cursor when held over the range between the minimum and maximum knob.
    • fShowMajorTicks

      protected boolean fShowMajorTicks
      If true, the major ticks are drawn.
    • fShowMinorTicks

      protected boolean fShowMinorTicks
      If true, the minor ticks are drawn.
    • fShowRange

      protected boolean fShowRange
      If true, the range is drawn.
    • fShowLabels

      protected boolean fShowLabels
      If true, the labels are drawn.
    • fMajorTickSpacing

      protected double fMajorTickSpacing
      The number of values between the major tick marks -- the larger marks that break up the minor tick marks.
    • fMinorTickSpacing

      protected double fMinorTickSpacing
      The number of values between the minor tick marks -- the smaller marks that occur between the major tick marks.
    • fSnapToTicks

      protected boolean fSnapToTicks
      If true, the knobs (and the data range they represents) resolve to the closest tick mark next to where the user positioned the knobs.
    • fOrientation

      protected int fOrientation
    • fKeyStep

      protected double fKeyStep
      The number of values the knobs move by when they are moved using the keyboard.
    • fLabelTable

      protected Dictionary fLabelTable
  • Constructor Details

    • TLcdRangeSlider

      public TLcdRangeSlider(double aMin, double aMax)
      Constructor, takes only a minimum and maximum, all possible options are set to true, except "snap to ticks". The default orientation HORIZONTAL is used.
      Parameters:
      aMin - Description of Parameter
      aMax - Description of Parameter
    • TLcdRangeSlider

      public TLcdRangeSlider(double aMin, double aMax, int aOrientation)
      Constructor, takes only a minimum maximum and a orientation, all possible options are set to true, except "snap to ticks".
      Parameters:
      aMin - the sliders minimum.
      aMax - the sliders maximum.
      aOrientation - Description of Parameter
  • Method Details

    • setModel

      public void setModel(TLcdRangeSliderModel aRangeSliderModel)
      Sets the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.
      Parameters:
      aRangeSliderModel - contains the properties of the slider: minimum, maximum, range minimum and range maximum.
    • setRangeVisble

      public void setRangeVisble(boolean aRangeVisible)
      Determines whether the range is painted on the slider
      Parameters:
      aRangeVisible - true to render the range on the slider.
    • setMajorTickSpacing

      public void setMajorTickSpacing(double aMajorTickSpacing)
      Sets the spacing between major ticks. This spacing is the amount of values between major ticks.
      Parameters:
      aMajorTickSpacing - the spacing between major ticks.
    • setMinorTickSpacing

      public void setMinorTickSpacing(double aMinorTickSpacing)
      Sets the spacing between minor ticks. This spacing is the amount of values between minor ticks.
      Parameters:
      aMinorTickSpacing - the spacing in data values between minor ticks.
      See Also:
    • getModel

      public TLcdRangeSliderModel getModel()
      Returns the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.
      Returns:
      the model that handles the sliders fundamental properties: minimum, maximum, range minimum and range maximum.
    • getOrientation

      public int getOrientation()
      Returns how this slider should be rendered.
      Returns:
      either VERTICAL or HORIZONTAL.
    • setOrientation

      public void setOrientation(int aOrientation)
      Sets how the slider should be rendered, vertically or horizontally.
      Parameters:
      aOrientation - sliders orientation, either VERTICAL or HORIZONTAL.
    • getSnapToTicks

      public boolean getSnapToTicks()
      Returns true if the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.
      Returns:
      true to let the knobs snap to the closest tick mark.
    • setSnapToTicks

      public void setSnapToTicks(boolean aSnapToTicks)
      Specifying true makes the knobs (and the range they represent) resolve to the closest tick mark next to where the user positioned the knobs.
      Parameters:
      aSnapToTicks - true to make knobs (and the range they represent) snap to the closest tick mark.
    • getPaintMajorTicks

      public boolean getPaintMajorTicks()
      Tells if major tick marks are to be painted.
      Returns:
      true to have the major tick marks painted, false otherwise.
    • getPaintMinorTicks

      public boolean getPaintMinorTicks()
      Tells if minor tick marks are to be painted.
      Returns:
      true to have the minor tick marks painted, false otherwise.
    • getPaintRange

      public boolean getPaintRange()
      Tells if the range between the minimum and maximum knobs is to be painted.
      Returns:
      true to have the range between the minimum and maximum nob rendered. false otherwise.
    • getPaintTicks

      public boolean getPaintTicks()
      Tells if either the major or minor (or both) tick marks are to be painted.
      Returns:
      true when either minor of major ticks will be rendered, false otherwise.
    • setPaintTicks

      public void setPaintTicks(boolean aPaintTicks)
      Determines whether tick marks (both major and minor) are painted on the slider.
      Parameters:
      aPaintTicks - true to render all ticks, major and minor, false to render no ticks at all.
    • setPaintMinorTicks

      public void setPaintMinorTicks(boolean aPaintMinorTicks)
      Determines whether minor tick marks are painted on the slider.
      Parameters:
      aPaintMinorTicks - true to render minor ticks.
    • setPaintMajorTicks

      public void setPaintMajorTicks(boolean aPaintMajorTicks)
      Determines whether major tick marks are painted on the slider.
      Parameters:
      aPaintMajorTicks - true to render major ticks.
    • setPaintLabels

      public void setPaintLabels(boolean aPaintLabels)
      Tells if labels are to be painted. Note that the label table should also be set.
      Parameters:
      aPaintLabels - true if the labels should be painted, false otherwise.
      See Also:
    • getPaintLabels

      public boolean getPaintLabels()
      Tells if labels are to be painted.
      Returns:
      true if the labels should be rendered.
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • getChangeCursorOverRange

      public boolean getChangeCursorOverRange()
      Tells is the cursor changes to a move cursor when held over the range between the minimum and maximum knob.
      Returns:
      true to have the cursor change over the range, false otherwise.
    • setChangeCursorOverRange

      public void setChangeCursorOverRange(boolean aChangeCursorOverRange)
      Determines whether the cursor changes to a move cursor when held over the range between the minimum and maximum knob.
      Parameters:
      aChangeCursorOverRange - true to make the cursor change when held over the range between the minimum and maximum knob.
    • getMinorTickSpacing

      public double getMinorTickSpacing()
      Gets the range of data values between minor ticks.
      Returns:
      the range of data values between minor ticks.
    • getMajorTickSpacing

      public double getMajorTickSpacing()
      Gets the amount of data values between major ticks.
      Returns:
      the range of data values between minor ticks.
    • getPrecision

      public int getPrecision()
      Returns the number of digits after the decimal point to which the data values are rounded.
      Returns:
      the number of digits after the decimal point to which the data values are rounded.
    • setPrecision

      public void setPrecision(int aPrecision)
      Determines the number of digits after the decimal point. Data values are rounded to this precision.
      Parameters:
      aPrecision - the number of digits after the decimal point that are to be kept.
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
      Returns true if one or both of the slider knobs are being dragged.
      Returns:
      the value of the models valueIsAdjusting property
    • setValueIsAdjusting

      public void setValueIsAdjusting(boolean aValueIsAdjusting)
      Sets whether the model should anticipate on subsequent changes.
      Parameters:
      aValueIsAdjusting - true if the model will change frequently subsequently. false otherwise.
    • reset

      public void reset()
      Sets the minimum and maximum knob to the models minimum and maximum.
    • setRangeMinimum

      public void setRangeMinimum(double aRangeMinimum)
      Sets the models range minimum value.
      Parameters:
      aRangeMinimum - the minimum of the range this slider should cover.
    • setRangeMaximum

      public void setRangeMaximum(double aRangeMaximum)
      Sets the models range maximum value.
      Parameters:
      aRangeMaximum - the maximum of the range this slider should cover.
    • setMinimum

      public void setMinimum(double aMinimum)
      Sets the models minimum value.
      Parameters:
      aMinimum - the minimum the range slider can cover.
    • setMaximum

      public void setMaximum(double aMaximum)
      Sets the models maximum value.
      Parameters:
      aMaximum - the maximum the range slider can cover.
    • setRange

      public void setRange(double aMin, double aMax)
      Sets the models range minimum and maximum value.
      Parameters:
      aMin - the new minimum of the range.
      aMax - the new maximum of the range.
    • getRangeMinimum

      public double getRangeMinimum()
      Returns the models range minimum value.
      Returns:
      the minimum value of the current range.
    • getRangeMaximum

      public double getRangeMaximum()
      Returns the models range maximum value.
      Returns:
      the maximum value of the current range.
    • getMinimum

      public double getMinimum()
      Returns the models minimum value.
      Returns:
      the minimum value the range slider can take into account.
    • getMaximum

      public double getMaximum()
      Returns the models range maximum value.
      Returns:
      the maximum value the range slider can take into account.
    • addChangeListener

      public void addChangeListener(ChangeListener aChangeListener)
      Adds a listener that will be notified of changes of the model.
      Parameters:
      aChangeListener - a listener that should be notified of changes in the model.
    • removeChangeListener

      public void removeChangeListener(ChangeListener aChangeListener)
      Removes a listener that will be notified of changes of the model.
      Parameters:
      aChangeListener - a listener that should no longer be notified of changes in the model.
    • getKeyStep

      public double getKeyStep()
      Returns the number of values the knobs move by when they are moved using the keyboard.
      Returns:
      the number of values the knobs move by when they are moved using the keyboard.
    • setKeyStep

      public void setKeyStep(double aKeyStep)
      Sets the number of values the knobs move by when they are moved using the keyboard.
      Parameters:
      aKeyStep - the number of values the knobs move by when they are moved using the keyboard.
    • getLabelTable

      public Dictionary getLabelTable()
    • setLabelTable

      public void setLabelTable(Dictionary labels)
    • updateLabelUIs

      protected void updateLabelUIs()
      Resets the UI property to a value from the current look and feel.
      See Also:
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JComponent
    • getUIClassID

      public String getUIClassID()
      Overrides:
      getUIClassID in class JComponent
    • createStandardLabels

      public Hashtable createStandardLabels(double aIncrement)
      Creates a hashtable that will draw text labels starting at the slider minimum using the aIncrement specified. If you call createStandardLabels( 10 ) and the slider minimum is zero, then it will make labels for the values 0, 10, 20, 30, and so on.
      Parameters:
      aIncrement - the step in data space between 2 values for which a label is created.
      Returns:
      a hashtable that can be used as label table for this range slider, with the first label assigned to the minimum of the slider and all subsequent labels at a distance apart equal to the increment.
      See Also:
    • createStandardLabels

      public Hashtable createStandardLabels(double aIncrement, double aStart)
      Creates a hashtable that will draw text labels starting at the aStart point specified using the aIncrement specified. If you call createStandardLabels( 10, 2 ), then it will make labels for the values 2, 12, 22, 32, and so on.
      Parameters:
      aIncrement - the step in data space between 2 values for which a label is created.
      aStart - the data value for which the first label should be created.
      Returns:
      a hashtable that can be used as label table for this range slider, with the first label assigned to the aStart value passed and all subsequent labels at a distance apart equal to the aIncrement.
      Throws:
      IllegalArgumentException - if slider label aStart point out of range or if label aIncrement is less than or equal to zero
      See Also: