java.lang.Object
com.amalgamasimulation.desktop.ui.editor.sections.descriptors.SpinnerProperties<V>
Type Parameters:
V - type of the value

public class SpinnerProperties<V> extends Object
Settings of the spinner in a spinner section: width, steps, read-only mode and enablement.
Author:
Ionov Ivan
  • Method Details

    • newInstance

      public static <V> SpinnerProperties<V> newInstance()
      Creates spinner settings with default values.
      Type Parameters:
      V - type of the value
      Returns:
      new settings
    • getWidth

      public int getWidth()
      Returns the width of the spinner.
      Returns:
      the width in pixels
    • width

      public SpinnerProperties<V> width(int width)
      Sets the width of the spinner.
      Parameters:
      width - the width in pixels
      Returns:
      this instance
    • getIncrement

      public V getIncrement()
      Returns the step of the arrows and the Up and Down keys.
      Returns:
      the step, or null for the spinner default
    • increment

      public SpinnerProperties<V> increment(V increment)
      Sets the step of the arrows and the Up and Down keys. A step smaller than one unit of the last digit (below 0.1 with one digit after the point) is rounded to 0, and the spinner keeps its previous step.
      Parameters:
      increment - the step in units of the value, or null for the spinner default
      Returns:
      this instance
    • getPageIncrement

      public V getPageIncrement()
      Returns the step of the Page Up and Page Down keys.
      Returns:
      the step, or null for the spinner default
    • pageIncrement

      public SpinnerProperties<V> pageIncrement(V pageIncrement)
      Sets the step of the Page Up and Page Down keys. A step smaller than one unit of the last digit (below 0.1 with one digit after the point) is rounded to 0, and the spinner keeps its previous step.
      Parameters:
      pageIncrement - the step in units of the value, or null for the spinner default
      Returns:
      this instance
    • isReadOnly

      public boolean isReadOnly()
      Returns whether typing is turned off.
      Returns:
      true if the value can be changed only with the arrows and keys
    • readOnly

      public SpinnerProperties<V> readOnly(boolean readOnly)
      Turns typing off; the arrows and keys still change the value. Applies only when the spinner is created.
      Parameters:
      readOnly - true to turn typing off
      Returns:
      this instance
    • isEnabled

      public boolean isEnabled()
      Returns whether the spinner should be enabled. Takes into account both its own setting and the section state.
      Returns:
      true if the spinner should be enabled
    • enabled

      public SpinnerProperties<V> enabled(boolean enabled)
      Enables or disables the spinner: typing and the arrows. The section buttons are not affected.
      Parameters:
      enabled - true to enable the spinner
      Returns:
      this instance
    • enabled

      public SpinnerProperties<V> enabled(BooleanSupplier enabled)
      Sets a condition that enables the spinner. It is checked again on each section update.
      Parameters:
      enabled - the condition
      Returns:
      this instance
    • sectionEnabled

      public SpinnerProperties<V> sectionEnabled(boolean sectionEnabled)
      Sets the state of the section that holds the spinner.
      Parameters:
      sectionEnabled - true if the section is enabled
      Returns:
      this instance
    • copy

      public void copy(SpinnerProperties<V> spinnerProperties)
      Copies all settings except the section state from other settings.
      Parameters:
      spinnerProperties - the settings to copy from