All Implemented Interfaces:
Styleable, EventTarget, Skinnable

@ClassVersion(sourceVersion="$Id: RangeSlider.java 1121 2024-03-16 16:51:23Z tquadrat $") @API(status=STABLE, since="0.4.6") public final class RangeSlider extends FoundationFXControl

The RangeSlider control is simply a JavaFX Slider control with support for two 'thumbs', rather than one. A thumb is the non-technical name for the draggable area inside the Slider/RangeSlider that allows for a value to be set.

Because the RangeSlider has two thumbs, it also has a few additional rules and user interactions:

  1. The 'lower value' thumb can not move past the 'higher value' thumb.
  2. Whereas the Slider control only has one value property, the RangeSlider has a low value and a high value property, not surprisingly represented by the 'low value' and 'high value' thumbs.
  3. The area between the low and high values represents the allowable range. For example, if the low value is 2 and the high value is 8, then the allowable range is between 2 and 8.
  4. The allowable range area is rendered differently. This area is able to be dragged with mouse/touch input to allow for the entire range to be modified. For example, following on from the previous example of the allowable range being between 2 and 8, if the user drags the range bar to the right, the low value will adjust to 3, and the high value 9, and so on until the user stops adjusting.

Code Samples

Instantiating a RangeSlider is simple. The first decision is to decide whether a horizontal or a vertical track is more appropriate. By default RangeSlider instances are horizontal, but this can be changed by setting the orientation property.

Once the orientation is determined, the next most important decision is to determine what the min/max and default low/high values are. The min/max values represent the smallest and largest legal values for the thumbs to be set to, whereas the low/high values represent where the thumbs are currently, within the bounds of the min/max values. Because all four values are required in all circumstances, they are all required parameters to instantiate a RangeSlider: the constructor takes four doubles, representing min, max, lowValue and highValue (in that order).

For example, here is a simple horizontal RangeSlider that has a minimum value of 0, a maximum value of 100, a low value of 10 and a high value of 90:

final RangeSlider hSlider = new RangeSlider( 0, 100, 10, 90 );

To create a vertical slider, simply do the following:

 final RangeSlider vSlider = new RangeSlider( 0, 200, 30, 150 );
  vSlider.setOrientation( Orientation.VERTICAL );

This code creates a vertical RangeSlider with a min value of 0, a max value of 200, a low value of 30, and a high value of 150.

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: RangeSlider.java 1121 2024-03-16 16:51:23Z tquadrat $
Since:
0.4.6
See Also:
Inspired through:
ControlsFX Project
UML Diagram
UML Diagram for "org.tquadrat.foundation.fx.control.RangeSlider"

UML Diagram for "org.tquadrat.foundation.fx.control.RangeSlider"

UML Diagram for "org.tquadrat.foundation.fx.control.RangeSlider"