java.lang.Object
io.github.palexdev.materialfx.skins.MFXSliderSkin.LayoutData
- Enclosing class:
- MFXSliderSkin
Support class to the slider's skin. It helps manage/update info about layout such as:
the x coordinate at zero value (or min if the min is greater than 0, or the max is lesser than 0, or the slider is se
to be non-bidirectional), the thumb x and y coordinates, the bar width and bar x coordinate, the major ticks data (see
MFXSliderSkin.TickData)
and their y coordinate which is the same for all of them.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the current slider's value, then creates a list with the ticks value obtained by mapping theMFXSliderSkin.TickDatalist withMFXSliderSkin.TickData.getTickVal(), callsNumberUtils.closestValueTo(double, List).getTicks()Returns all the ticks by mapping theMFXSliderSkin.TickDatalist withMFXSliderSkin.TickData.getTick().doubledoublevoidIf theMFXSlider.showMajorTicksProperty()is set to false, does nothing.voidupdate(boolean isFullUpdate) Updated all the layout variables of this class.voidBuilds the major ticks and sets their style class to "tick-even" or "tick-odd" according to their index in the list.
-
Constructor Details
-
LayoutData
protected LayoutData()
-
-
Method Details
-
update
public void update(boolean isFullUpdate) Updated all the layout variables of this class. If the isFullUpdate parameter is false the zeroPos is not recomputed. It also manages theMFXSlider.bidirectionalProperty()feature. One thing I'm excited about this system is how the coordinates are computed. We heavily make use ofNumberUtils.mapOneRangeToAnother(double, NumberRange, NumberRange, int). The sliders values can be negative or be way greater than the slider's width, that's why the slider's value should be mapped from the min-max range to the width range that goes from 0 to slider.getWidth(). -
updateTicksData
public void updateTicksData()Builds the major ticks and sets their style class to "tick-even" or "tick-odd" according to their index in the list. After building the ticks and their layout data (MFXSliderSkin.TickData, callspositionTicks(). -
positionTicks
public void positionTicks()If theMFXSlider.showMajorTicksProperty()is set to false, does nothing. For each previously builtMFXSliderSkin.TickDataadds the tick to the ticks container and sets their position, ifMFXSlider.showTicksAtEdgesProperty()is set to false the ticks that represent the min and max values of the slider are not added. -
findNearestTick
public double findNearestTick()Gets the current slider's value, then creates a list with the ticks value obtained by mapping theMFXSliderSkin.TickDatalist withMFXSliderSkin.TickData.getTickVal(), callsNumberUtils.closestValueTo(double, List).- Returns:
- the closest value from the current value and the list of the ticks values
-
getTicks
Returns all the ticks by mapping theMFXSliderSkin.TickDatalist withMFXSliderSkin.TickData.getTick(). -
halfThumbWidth
public double halfThumbWidth()- Returns:
- half the width of the thumb
-
halfThumbHeight
public double halfThumbHeight()- Returns:
- half the height of the thumb
-