Class OwnSliderPlus
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
com.badlogic.gdx.scenes.scene2d.ui.Slider
gaiasky.util.scene2d.OwnSliderPlus
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.ui.Styleable<com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.ProgressBarStyle>, com.badlogic.gdx.scenes.scene2d.utils.Disableable, com.badlogic.gdx.scenes.scene2d.utils.Layout, IObserver
An extended
Slider designed for complex data input in Gaia Sky.
Key Features:
- Integrated Labels: Draws a title (left-aligned) and a dynamic value (right-aligned) directly above the slider track.
- Value Mapping: Decouples the physical slider position from the returned value. The slider can represent a range (e.g., 0.001 to 100,000) while the internal widget logic remains in a normalized or manageable range.
- Non-linear (Power Curve) Scaling: When
logarithmicis enabled, the slider applies a transform of the form $f(t) = t^k$. This allows for fine-grained control at one end of the scale and coarse control at the other. - Visual Feedback: Automatic highlighting of labels and slider assets when the widget gains keyboard/controller focus.
- Event Integration: Built-in support for the
EventManagersystem.
Mapping Logic:
The slider maintains an Internal Range defined by [min, max].
The Mapped Range is defined by [mapMin, mapMax].
- Linear: If
logarithmicis false, the value is interpolated linearly between the two ranges. - Logarithmic/Power: If true, the normalized slider position $t \in [0,1]$
is raised to
logExponent. If $k < 1$, the high-end resolution is expanded; if $k > 1$, the low-end resolution is expanded.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Slider
com.badlogic.gdx.scenes.scene2d.ui.Slider.SliderStyleNested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.ProgressBarStyle -
Field Summary
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
POOLS -
Constructor Summary
ConstructorsConstructorDescriptionOwnSliderPlus(String title, float min, float max, boolean logarithmic, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a slider with logarithmic scaling support using default styles.OwnSliderPlus(String title, float min, float max, boolean logarithmic, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyle) Creates a slider with an option for logarithmic scaling.OwnSliderPlus(String title, float min, float max, float stepSize, boolean vertical, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyleName) Creates a slider with orientation and custom label style support.OwnSliderPlus(String title, float min, float max, float stepSize, float mapMin, float mapMax, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a slider with a mapped range using the default label style.OwnSliderPlus(String title, float min, float max, float stepSize, float mapMin, float mapMax, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyle) Creates a slider with a specific mapped range and custom label style.OwnSliderPlus(String title, float min, float max, float stepSize, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Simple constructor for a basic linear slider with a title.OwnSliderPlus(String title, float min, float max, float stepSize, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String sliderStyle) Creates a slider where the internal range and mapped range are identical. -
Method Summary
Modifier and TypeMethodDescriptionvoidConnect this slider with the given event.voidConnect this slider with the given event.voidconnectUnmapped(Event event) Connect this slider with the given event.voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha) protected com.badlogic.gdx.scenes.scene2d.utils.Drawableprotected com.badlogic.gdx.scenes.scene2d.utils.DrawablefloatfloatfloatvoidEvent notification call.voidvoidvoidsetDisabled(boolean disabled) voidsetDisplayValueMapped(boolean displayValueMapped) voidsetHeight(float height) voidsetLabelColor(float r, float g, float b, float a) voidsetLabelColor(com.badlogic.gdx.graphics.Color c) voidsetLogarithmicExponent(double exp) Sets the exponent used for the non-linear (log-like) mapping applied when logarithmic mode is enabled.voidsetMappedValue(double mappedValue) voidsetMappedValue(float mappedValue) voidsetMapValues(float mapMin, float mapMax, boolean logarithmic) voidvoidsetSize(float width, float height) voidsetTooltip(String tooltip) voidvoidsetUp(String title, float mapMin, float mapMax, boolean logarithmic, DecimalFormat nf, String labelStyleName) booleansetValue(float value) voidsetValueLabelTransform(Function<Float, String> transform) Sets a custom transformation for the displayed value string.voidsetValuePrefix(String valuePrefix) voidsetValueSuffix(String valueSuffix) voidsetWidth(float width) Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Slider
getKnobAfterDrawable, getKnobDrawable, getSnapToValues, getSnapToValuesThreshold, getStyle, isDragging, isOver, setButton, setSnapToValues, setSnapToValues, setVisualInterpolationInverse, setVisualPercent, snapMethods inherited from class com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
act, clamp, getKnobPosition, getMaxValue, getMinValue, getPercent, getProgrammaticChangeEvents, getStepSize, getValue, getVisualPercent, getVisualValue, isAnimating, isDisabled, isVertical, round, setAnimateDuration, setAnimateInterpolation, setProgrammaticChangeEvents, setRange, setRound, setStepSize, setStyle, setVisualInterpolation, updateVisualValueMethods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validateMethods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setStage, setTouchable, setUserObject, setVisible, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
-
Constructor Details
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, float stepSize, float mapMin, float mapMax, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyle) Creates a slider with a specific mapped range and custom label style.- Parameters:
title- The text displayed inside (left) the slider.min- The internal minimum value of the slider widget.max- The internal maximum value of the slider widget.stepSize- The size of the discrete steps between min and max.mapMin- The logical value represented when the slider is at its minimum position.mapMax- The logical value represented when the slider is at its maximum position.skin- The UI skin to use.labelStyle- The name of the label style within the skin.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, float stepSize, float mapMin, float mapMax, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a slider with a mapped range using the default label style.- Parameters:
title- The text displayed inside (left) the slider.min- The internal minimum value.max- The internal maximum value.stepSize- The size of the discrete steps.mapMin- The logical value represented at the far left/bottom.mapMax- The logical value represented at the far right/top.skin- The UI skin to use.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, float stepSize, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String sliderStyle) Creates a slider where the internal range and mapped range are identical.- Parameters:
title- The text displayed inside (left) the slider.min- The range minimum (both internal and display).max- The range maximum (both internal and display).stepSize- The step increment.skin- The UI skin to use.sliderStyle- The name of the slider style within the skin.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, boolean logarithmic, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a slider with logarithmic scaling support using default styles.- Parameters:
title- The text displayed inside (left) the slider.min- The minimum value of the mapped range.max- The maximum value of the mapped range.logarithmic- Whether to use a power-curve distribution for values.skin- The UI skin to use.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, boolean logarithmic, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyle) Creates a slider with an option for logarithmic scaling.Note: If
logarithmicis true, the internal range is forced to[0, 1]and step size is set to a very small value to ensure smooth power-curve math.- Parameters:
title- The text displayed inside (left) the slider.min- The logical minimum value of the mapped range.max- The logical maximum value of the mapped range.logarithmic- Whether to use a power-curve distribution.skin- The UI skin to use.labelStyle- The name of the label style.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, float stepSize, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Simple constructor for a basic linear slider with a title.- Parameters:
title- The text displayed inside (left) the slider.min- The range minimum.max- The range maximum.stepSize- The step increment.skin- The UI skin to use.
-
OwnSliderPlus
public OwnSliderPlus(String title, float min, float max, float stepSize, boolean vertical, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String labelStyleName) Creates a slider with orientation and custom label style support.- Parameters:
title- The text displayed inside (left) the slider.min- The internal minimum value.max- The internal maximum value.stepSize- The step increment.vertical- True if the slider should be vertical, false for horizontal.skin- The UI skin to use.labelStyleName- The name of the label style.
-
-
Method Details
-
setUp
-
setUp
public void setUp(String title, float mapMin, float mapMax, boolean logarithmic, DecimalFormat nf, String labelStyleName) -
setLogarithmicExponent
public void setLogarithmicExponent(double exp) Sets the exponent used for the non-linear (log-like) mapping applied when logarithmic mode is enabled. SeelogExponentfor details about how the exponent affects the curve.- Parameters:
exp- a strictly positive exponent controlling the non-linearity strength- Throws:
IllegalArgumentException- ifexp ≤ 0
-
setValueLabelTransform
-
setNumberFormatter
-
setDisplayValueMapped
public void setDisplayValueMapped(boolean displayValueMapped) -
setMapValues
public void setMapValues(float mapMin, float mapMax, boolean logarithmic) -
removeMapValues
public void removeMapValues() -
getValueString
-
setValue
public boolean setValue(float value) - Overrides:
setValuein classcom.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
getMappedValue
public float getMappedValue() -
setMappedValue
public void setMappedValue(double mappedValue) -
setMappedValue
public void setMappedValue(float mappedValue) -
setValuePrefix
-
setValueSuffix
-
setWidth
public void setWidth(float width) - Overrides:
setWidthin classcom.badlogic.gdx.scenes.scene2d.Actor
-
setHeight
public void setHeight(float height) - Overrides:
setHeightin classcom.badlogic.gdx.scenes.scene2d.Actor
-
setSize
public void setSize(float width, float height) - Overrides:
setSizein classcom.badlogic.gdx.scenes.scene2d.Actor
-
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidthin interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout- Overrides:
getPrefWidthin classcom.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeightin interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout- Overrides:
getPrefHeightin classcom.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha) - Overrides:
drawin classcom.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
getBackgroundDrawable
@Null protected com.badlogic.gdx.scenes.scene2d.utils.Drawable getBackgroundDrawable()- Overrides:
getBackgroundDrawablein classcom.badlogic.gdx.scenes.scene2d.ui.Slider
-
getKnobBeforeDrawable
protected com.badlogic.gdx.scenes.scene2d.utils.Drawable getKnobBeforeDrawable()- Overrides:
getKnobBeforeDrawablein classcom.badlogic.gdx.scenes.scene2d.ui.Slider
-
setDisabled
public void setDisabled(boolean disabled) - Specified by:
setDisabledin interfacecom.badlogic.gdx.scenes.scene2d.utils.Disableable- Overrides:
setDisabledin classcom.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
setLabelColor
public void setLabelColor(com.badlogic.gdx.graphics.Color c) -
setLabelColor
public void setLabelColor(float r, float g, float b, float a) -
restoreLabelColor
public void restoreLabelColor() -
setTooltip
-
connect
Connect this slider with the given event. Slider events contain a float value as the first parameter. When a slider is connected to an event, it is subscribed to it, and it publishes it when its value is modified. The connected value is unmapped ifconnectUnmappedis true, and mapped if it is false. -
connect
Connect this slider with the given event. Slider events contain a float value as the first parameter. When a slider is connected to an event, it is subscribed to it, and it publishes it when its value is modified. This variation publishes the mapped value. -
connectUnmapped
Connect this slider with the given event. Slider events contain a float value as the first parameter. When a slider is connected to an event, it is subscribed to it, and it publishes it when its value is modified. This variation publishes the unmapped internal value. -
notify
-