Class HorizontalSlider
java.lang.Object
de.gurkenlabs.litiengine.gui.GuiComponent
de.gurkenlabs.litiengine.gui.Slider
de.gurkenlabs.litiengine.gui.HorizontalSlider
- All Implemented Interfaces:
IRenderable,Tweenable,MouseListener,MouseMotionListener,MouseWheelListener,EventListener
A GUI component that represents a horizontal slider with customizable appearance and behavior.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FontIconFont icon for the left arrow button.static final FontIconFont icon for the right arrow button.Fields inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
ICON_FONT -
Constructor Summary
ConstructorsConstructorDescriptionHorizontalSlider(double x, double y, double width, double height, float minValue, float maxValue, float stepSize) Initializes a new instance of theHorizontalSliderclass with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected floatGets the relative value of the mouse's x-coordinate within the slider's range.Gets the relative location of the slider thumb based on the current value.protected voidInitializes the components of the slider, including its buttons and thumb.protected voidRenders the slider's bar on the specified graphics context.protected voidRenders the tick marks of the slider on the specified graphics context.protected voidUpdates the dimensions of the slider thumb based on the number of steps.Methods inherited from class de.gurkenlabs.litiengine.gui.Slider
getButton1, getButton2, getButtonSpritesheet, getChangeConsumer, getCurrentValue, getMaxValue, getMinValue, getSliderComponent, getSliderSpritesheet, getSteps, getStepSize, getTickSize, inferValueFromMouseLocation, isDragging, isShowingTicks, onChange, prepare, render, setButton1, setButton2, setButtonSpritesheet, setCurrentValue, setMaxValue, setMinValue, setShowTicks, setSliderComponent, setSliderSpritesheet, setStepSize, setTickSizeMethods inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
addRenderedListener, addRenderListener, getAppearance, getAppearanceDisabled, getAppearanceHovered, getBoundingBox, getCenterX, getCenterY, getClickConsumer, getComponentId, getComponents, getCurrentAppearance, getFont, getHeight, getHoverConsumer, getHoverSound, getLocation, getMouseDraggedConsumer, getMouseEnterConsumer, getMouseLeaveConsumer, getMouseMovedConsumer, getMousePressedConsumer, getMouseReleasedConsumer, getMouseWheelConsumer, getName, getShape, getTag, getText, getTextAlign, getTextAngle, getTextShadowColor, getTextShadowRadius, getTextToRender, getTextValign, getTextX, getTextY, getTweenValues, getWidth, getX, getY, hasAutomaticLineBreaks, hasTextAntialiasing, hasTextShadow, isEnabled, isForwardMouseEvents, isHovered, isPressed, isSelected, isSuspended, isVisible, mouseClicked, mouseDragged, mouseEntered, mouseEventShouldBeForwarded, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, onClicked, onHovered, onMouseDragged, onMouseEnter, onMouseLeave, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelScrolled, onTextChanged, removeListener, removeListener, setAutomaticLineBreaks, setDimension, setEnabled, setFont, setFontSize, setForwardMouseEvents, setHeight, setHovered, setHoverSound, setLocation, setLocation, setName, setSelected, setTag, setText, setTextAlign, setTextAngle, setTextAntialiasing, setTextShadow, setTextShadowColor, setTextShadowRadius, setTextValign, setTextX, setTextY, setTweenValues, setVisible, setWidth, setX, setY, suspend, toggleSelection, toggleSuspension
-
Field Details
-
ARROW_LEFT
Font icon for the left arrow button. -
ARROW_RIGHT
Font icon for the right arrow button.
-
-
Constructor Details
-
HorizontalSlider
public HorizontalSlider(double x, double y, double width, double height, float minValue, float maxValue, float stepSize) Initializes a new instance of theHorizontalSliderclass with the specified properties.- Parameters:
x- The x-coordinate of the slider's position.y- The y-coordinate of the slider's position.width- The width of the slider.height- The height of the slider.minValue- The minimum value of the slider.maxValue- The maximum value of the slider.stepSize- The step size for the slider.
-
-
Method Details
-
getRelativeSliderLocation
Gets the relative location of the slider thumb based on the current value.- Specified by:
getRelativeSliderLocationin classSlider- Returns:
- A
Point2Drepresenting the relative position of the slider thumb.
-
updateSliderDimensions
protected void updateSliderDimensions()Updates the dimensions of the slider thumb based on the number of steps.- Specified by:
updateSliderDimensionsin classSlider
-
getRelativeMouseValue
protected float getRelativeMouseValue()Gets the relative value of the mouse's x-coordinate within the slider's range.- Specified by:
getRelativeMouseValuein classSlider- Returns:
- A
floatrepresenting the relative mouse value.
-
initializeComponents
protected void initializeComponents()Initializes the components of the slider, including its buttons and thumb.- Overrides:
initializeComponentsin classGuiComponent
-
renderBar
Renders the slider's bar on the specified graphics context. -
renderTicks
Renders the tick marks of the slider on the specified graphics context.- Specified by:
renderTicksin classSlider- Parameters:
g- TheGraphics2Dcontext on which to render the tick marks.
-