Class GUICycler<T>

Type Parameters:
T - the object type in the cycler.
All Implemented Interfaces:
GUISelectable<T>, GUIValueField<T>

public class GUICycler<T> extends GUILabel implements GUIValueField<T>, GUISelectable<T>
Option cycler abstract. A cycler changes its value each click. An GUIValueField.EVENT_VALUE_CHANGE event is fired each value change.
  • Field Details

    • model

      protected IndexedModel<T> model
      The model to use.
    • currentIndex

      protected int currentIndex
      The current choice index.
    • BASIC_ACTION

      protected static final GUIAction BASIC_ACTION
  • Constructor Details

    • GUICycler

      public GUICycler(IndexedModel<T> model)
      Creates a new cycler with a set of items to cycle through.
      Parameters:
      model - the model that this cycler uses for values.
  • Method Details

    • setSelectedIndex

      public GUICycler<T> setSelectedIndex(int index)
      Description copied from interface: GUISelectable
      Sets the selected index on the object. If the index is out of bounds, it should be set to -1, meaning nothing selected.
      Specified by:
      setSelectedIndex in interface GUISelectable<T>
      Parameters:
      index - the new selected index.
      Returns:
      this selectable.
    • getSelectedIndex

      public int getSelectedIndex()
      Description copied from interface: GUISelectable
      Gets the selected index on the object.
      Specified by:
      getSelectedIndex in interface GUISelectable<T>
      Returns:
      the current selected index.
    • getSelectedValue

      public T getSelectedValue()
      Specified by:
      getSelectedValue in interface GUISelectable<T>
      Returns:
      the current selected value, or null if no value selected.
    • getValue

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

      public GUICycler<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.
    • advanceSelection

      protected void advanceSelection()
      Advances the cycler's selected index.
    • reverseSelection

      protected void reverseSelection()
      Reverses the cycler's selected index.