Class TimeSpinner3D

All Implemented Interfaces:
Animation, Editable, StyleListener, InternalPickerWidget, Iterable<Component>

public class TimeSpinner3D extends Container implements InternalPickerWidget

Hour and minute wheels selecting a time of day, in either 24 hour or AM/PM form according to #setShowMeridiem(boolean).

The body of a lightweight Picker of type time, and usable on its own as an ordinary Container. The minute wheel can step by more than one minute, which is what a picker offering quarter hours uses.

With #setDurationMode(boolean) set it selects a LENGTH of time instead, and the meridiem is not shown; prefer DurationSpinner3D for that, which also offers a day wheel.

getValue() and setValue(Object) carry the time as minutes since midnight, as an Integer.

  • Constructor Details

    • TimeSpinner3D

      public TimeSpinner3D(int minuteStep)
      Default constructor
    • TimeSpinner3D

      public TimeSpinner3D()
  • Method Details

    • calcPreferredSize

      protected Dimension calcPreferredSize()
      Description copied from class: Container

      Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

      Returns

      the calculated preferred size based on component content

      Overrides:
      calcPreferredSize in class Container
    • getPropertyNames

      public String[] getPropertyNames()

      A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

      Returns

      the property names allowing mutation

      Overrides:
      getPropertyNames in class Component
    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

      Overrides:
      getPropertyTypes in class Component
    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

      Overrides:
      getPropertyValue in class Component
    • setPropertyValue

      public String setPropertyValue(String name, Object value)

      Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

      Overrides:
      setPropertyValue in class Component
    • getMinuteStep

      public int getMinuteStep()

      Gets the minutes spinner step size.

      Returns

      the minuteStep

    • setMinuteStep

      public void setMinuteStep(int minuteStep)

      Sets the step-size for the minutes spinner.

      Parameters
      • minuteStep: The step size. Must be beween 1 and 60.
    • setHourRange

      public void setHourRange(int min, int max)

      Sets the hours range to display. Note that the spinner must not be in duration mode, and must by in 24 hour mode, otherwise this will thrown an IllegalStateException.

      Parameters
      • min: The minimum hour to display (0-24). Set to -1 to allow any minimum.

      • nax: The maximum hour to display (0-24). Set -1 to allow any maximum.

      Throws
      • IllegalStateException: If the spinner is not in 24 hour mode.
      See also
      • #getMinHour()

      • #getMaxHour()

    • getMinHour

      public int getMinHour()

      Gets the current minimum hour to display. -1 for no limit

      Returns

      The current minimum hour (0-24). -1 for no limit.

      See also
      • #setHourRange(int, int)

      • #getMaxHour()

    • getMaxHour

      public int getMaxHour()

      Gets the current maximum hour to display. -1 for no limit.

      Returns

      The current maximum hour (0-24). -1 for no limit.

      See also
      • #getMinHour()

      • #setHourRange(int, int)

    • isShowMeridiem

      public boolean isShowMeridiem()
      Returns

      the showMeridiem

    • setShowMeridiem

      public void setShowMeridiem(boolean showMeridiem)

      Shows AM/PM indication

      Parameters
      • showMeridiem: the showMeridiem to set
    • getCurrentHour

      public int getCurrentHour()

      The hour from 1-12 or 0-23

      Returns

      the currentHour

    • setCurrentHour

      public void setCurrentHour(int currentHour)

      Set the hour from 1-12 or 0-23

      Parameters
      • currentHour: the currentHour to set
    • getCurrentMinute

      public int getCurrentMinute()
      Returns

      the currentMinute

    • setCurrentMinute

      public void setCurrentMinute(int currentMinute)
      Parameters
      • currentMinute: the currentMinute to set
    • isCurrentMeridiem

      public boolean isCurrentMeridiem()
      Returns

      the currentMeridiem

    • setCurrentMeridiem

      public void setCurrentMeridiem(boolean currentMeridiem)
      Parameters
      • currentMeridiem: the currentMeridiem to set
    • isDurationMode

      public boolean isDurationMode()

      Duration mode uses the time spinner to indicate a duration in hours and minutes

      Returns

      the durationMode

    • setDurationMode

      public void setDurationMode(boolean durationMode)

      Duration mode uses the time spinner to indicate a duration in hours and minutes

      Parameters
      • durationMode: the durationMode to set
    • setHoursVisible

      public void setHoursVisible(boolean visible)

      Show or hide the hours spinner.

      Parameters
      • visible: True to show the hours spinner.
    • setMinutesVisible

      public void setMinutesVisible(boolean visible)

      Show or hide the minutes spinner.

      Parameters
      • visible: True to make the minutes spinner visible.
    • getValue

      public Object getValue()
      Description copied from interface: InternalPickerWidget

      The currently selected value.

      Returns

      the selection, in whatever type this implementation documents; never null once the widget has been laid out

      Specified by:
      getValue in interface InternalPickerWidget
    • setValue

      public void setValue(Object value)
      Description copied from interface: InternalPickerWidget

      Moves the selection to value.

      The widget scrolls to the new selection rather than jumping, when it is already on screen.

      Parameters
      • value: the new selection, in the type this implementation documents. A value outside the widget's range is clamped into it.
      Specified by:
      setValue in interface InternalPickerWidget
    • paint

      public void paint(Graphics g)
      Description copied from class: Container

      This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

      Parameters
      • g: the component graphics
      Specified by:
      paint in interface Animation
      Overrides:
      paint in class Container