Class HorizontalSlider

All Implemented Interfaces:
IRenderable, Tweenable, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class HorizontalSlider extends Slider
A GUI component that represents a horizontal slider with customizable appearance and behavior.
  • Field Details

    • ARROW_LEFT

      public static final FontIcon ARROW_LEFT
      Font icon for the left arrow button.
    • ARROW_RIGHT

      public static final FontIcon 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 the HorizontalSlider class 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

      public Point2D getRelativeSliderLocation()
      Gets the relative location of the slider thumb based on the current value.
      Specified by:
      getRelativeSliderLocation in class Slider
      Returns:
      A Point2D representing 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:
      updateSliderDimensions in class Slider
    • getRelativeMouseValue

      protected float getRelativeMouseValue()
      Gets the relative value of the mouse's x-coordinate within the slider's range.
      Specified by:
      getRelativeMouseValue in class Slider
      Returns:
      A float representing the relative mouse value.
    • initializeComponents

      protected void initializeComponents()
      Initializes the components of the slider, including its buttons and thumb.
      Overrides:
      initializeComponents in class GuiComponent
    • renderBar

      protected void renderBar(Graphics2D g)
      Renders the slider's bar on the specified graphics context.
      Specified by:
      renderBar in class Slider
      Parameters:
      g - The Graphics2D context on which to render the bar.
    • renderTicks

      protected void renderTicks(Graphics2D g)
      Renders the tick marks of the slider on the specified graphics context.
      Specified by:
      renderTicks in class Slider
      Parameters:
      g - The Graphics2D context on which to render the tick marks.