Class GUISlider<T>

Type Parameters:
T - the value type.
All Implemented Interfaces:
GUIValueField<T>

public class GUISlider<T> extends GUIGlassPanel implements GUIValueField<T>
A slider class that alters an internal value depending on where the slider sits on the slider bar.

This object already contains its own layout and a child object, its movement constrained to that of its parent, that acts as the slider thumb.

This object fires an EVENT_VALUE_CHANGE event when the slider changes.

This object and its descendants return specific theme keys depending on the current state of the slider.

Thumb:

Slider Themes
Enabled THEME_KEY_SLIDER_THUMB
Focused THEME_KEY_SLIDER_THUMB_FOCUSED
Disabled THEME_KEY_SLIDER_THUMB_DISABLED

Track:

Slider Themes
Horizontal, Enabled THEME_KEY_SLIDER_HORIZONTAL_TRACK
Horizontal, Focused THEME_KEY_SLIDER_HORIZONTAL_TRACK_FOCUSED
Horizontal, Disabled THEME_KEY_SLIDER_HORIZONTAL_TRACK_DISABLED
Vertical, Enabled THEME_KEY_SLIDER_VERTICAL_TRACK
Vertical, Focused THEME_KEY_SLIDER_VERTICAL_TRACK_FOCUSED
Vertical, Disabled THEME_KEY_SLIDER_VERTICAL_TRACK_DISABLED

Track Start:

Slider Themes
Horizontal, Enabled THEME_KEY_SLIDER_HORIZONTAL_TRACK_START
Horizontal, Focused THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_FOCUSED
Horizontal, Disabled THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_DISABLED
Vertical, Enabled THEME_KEY_SLIDER_VERTICAL_TRACK_START
Vertical, Focused THEME_KEY_SLIDER_VERTICAL_TRACK_START_FOCUSED
Vertical, Disabled THEME_KEY_SLIDER_VERTICAL_TRACK_START_DISABLED

Track End:

Slider Themes
Horizontal, Enabled THEME_KEY_SLIDER_HORIZONTAL_TRACK_END
Horizontal, Focused THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_FOCUSED
Horizontal, Disabled THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_DISABLED
Vertical, Enabled THEME_KEY_SLIDER_VERTICAL_TRACK_END
Vertical, Focused THEME_KEY_SLIDER_VERTICAL_TRACK_END_FOCUSED
Vertical, Disabled THEME_KEY_SLIDER_VERTICAL_TRACK_END_DISABLED
Author:
Matthew Tropiano
  • Field Details

    • THEME_KEY_SLIDER_THUMB

      public static final String THEME_KEY_SLIDER_THUMB
      Theme key for slider thumb.
      See Also:
    • THEME_KEY_SLIDER_THUMB_DISABLED

      public static final String THEME_KEY_SLIDER_THUMB_DISABLED
      Theme key for slider thumb, disabled.
      See Also:
    • THEME_KEY_SLIDER_THUMB_FOCUSED

      public static final String THEME_KEY_SLIDER_THUMB_FOCUSED
      Theme key for slider thumb, focused.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK
      Theme key for horizontal slider track.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_START

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_START
      Theme key for horizontal slider track start.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_END

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_END
      Theme key for horizontal slider track end.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_DISABLED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_DISABLED
      Theme key for horizontal slider track, disabled.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_DISABLED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_DISABLED
      Theme key for horizontal slider track start, disabled.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_DISABLED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_DISABLED
      Theme key for horizontal slider track end, disabled.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_FOCUSED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_FOCUSED
      Theme key for horizontal slider track, focused.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_FOCUSED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_FOCUSED
      Theme key for horizontal slider track start, focused.
      See Also:
    • THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_FOCUSED

      public static final String THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_FOCUSED
      Theme key for horizontal slider track end, focused.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK
      Theme key for vertical slider track.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_START

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_START
      Theme key for vertical slider track start.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_END

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_END
      Theme key for vertical slider track end.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_DISABLED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_DISABLED
      Theme key for vertical slider track, disabled.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_START_DISABLED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_START_DISABLED
      Theme key for vertical slider track start, disabled.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_END_DISABLED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_END_DISABLED
      Theme key for vertical slider track end, disabled.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_FOCUSED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_FOCUSED
      Theme key for vertical slider track, focused.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_START_FOCUSED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_START_FOCUSED
      Theme key for vertical slider track start, focused.
      See Also:
    • THEME_KEY_SLIDER_VERTICAL_TRACK_END_FOCUSED

      public static final String THEME_KEY_SLIDER_VERTICAL_TRACK_END_FOCUSED
      Theme key for vertical slider track end, focused.
      See Also:
    • THUMB_NAME

      public static final String THUMB_NAME
      The name given to the thumb object.
      See Also:
    • TRACK_NAME

      public static final String TRACK_NAME
      The name given to the track object.
      See Also:
    • TRACK_START_NAME

      public static final String TRACK_START_NAME
      The name given to the track start object.
      See Also:
    • TRACK_END_NAME

      public static final String TRACK_END_NAME
      The name given to the track end object.
      See Also:
    • THUMB_PRESS

      protected static final GUIAction THUMB_PRESS
      Key press event on the thumb.
    • THUMB_MOUSE_PRESS

      protected static final GUIAction THUMB_MOUSE_PRESS
      Mouse press event on the thumb.
    • THUMB_MOUSE_DRAG

      protected static final GUIAction THUMB_MOUSE_DRAG
      Mouse drag event on the thumb.
    • style

      protected GUISlider.Style style
      Slider style.
    • model

      protected RangeModel<T> model
      Slider model.
    • thumbObject

      protected GUIObject thumbObject
      Internal object for the thumb.
    • trackObject

      protected GUIObject trackObject
      Internal object for the track.
    • trackStartObject

      protected GUIObject trackStartObject
      Internal object for the track start.
    • trackEndObject

      protected GUIObject trackEndObject
      Internal object for the track end.
    • thumbScalar

      protected float thumbScalar
      Thumb scalar.
    • currentValue

      protected T currentValue
      Current value.
  • Constructor Details

    • GUISlider

      public GUISlider(RangeModel<T> model)
      Creates a new GUI Slider object in horizontal style.
      Parameters:
      model - the range model to use for defining values.
    • GUISlider

      public GUISlider(RangeModel<T> model, GUISlider.Style style)
      Creates a new GUI Slider object.
      Parameters:
      model - the range model to use for defining values.
      style - the slider's style.
    • GUISlider

      public GUISlider(RangeModel<T> model, GUISlider.Style style, float thumbScalar)
      Creates a new GUI Slider object.
      Parameters:
      model - the range model to use for defining values.
      style - the slider's style.
      thumbScalar - the thumb scalar (from 0 to 1).
  • Method Details

    • setLayout

      public GUIObject setLayout(GUILayout layout)
      This uses a special layout; to preserve it, this throws UnsupportedOperationException.
      Overrides:
      setLayout in class GUIObject
      Parameters:
      layout - the layout to use.
      Returns:
      itself, to chain calls.
      Throws:
      UnsupportedOperationException - if called.
    • getStyle

      public GUISlider.Style getStyle()
      Returns:
      the current slider style.
    • setValue

      public GUIValueField<T> setValue(Object value)
      Description copied from interface: GUIValueField
      Sets this field's value. This must accept any object, and attempt to set the correct value based on it. This object must fire an GUIValueField.EVENT_VALUE_CHANGE event if it changes from its current value.
      Specified by:
      setValue in interface GUIValueField<T>
      Parameters:
      value - the value to set.
      Returns:
      itself, to chain calls.
    • getValue

      public T getValue()
      Specified by:
      getValue in interface GUIValueField<T>
      Returns:
      this field's current value.
    • getThumb

      public GUIObject getThumb()
      Returns:
      the reference to the thumb object.
    • getTrackStart

      public GUIObject getTrackStart()
      Returns:
      the reference to the track start object.
    • getTrackEnd

      public GUIObject getTrackEnd()
      Returns:
      the reference to the track end object.
    • getTrack

      public GUIObject getTrack()
      Returns:
      the reference to the track object.
    • getThumbScalar

      public float getThumbScalar()
      Gets the current thumb scalar. It's a value from 0 to 1 that describes the width of the thumb relative to the width/height of the entire slider. Affected by slider style.
      Returns:
      the current scalar.
    • setThumbScalar

      public void setThumbScalar(float thumbScalar)
      Sets the current thumb scalar. It's a value from 0 to 1 that describes the width of the thumb relative to the width/height of the entire slider. Affected by slider style.
      Parameters:
      thumbScalar - the new scalar.
    • getPositionScalar

      protected float getPositionScalar()
      Returns:
      the interpolation value between 0 and 1 using the position of the slider.
    • setValuesByThumbBounds

      protected void setValuesByThumbBounds()
      Sets the internal values by the thumb position.