Class SurfaceProgress

java.lang.Object
com.codename1.surfaces.SurfaceNode
com.codename1.surfaces.SurfaceProgress

public class SurfaceProgress extends SurfaceNode

A progress indicator node. The value is a fraction between 0 and 1, supplied either literally, by state-map key, or as a date interval the OS animates natively (iOS only; other platforms freeze the interval's value as of the last refresh).

Determinate STYLE_CIRCULAR progress falls back to a linear bar on Android app widgets, which only support indeterminate circular spinners.

  • Field Details

    • STYLE_LINEAR

      public static final int STYLE_LINEAR
      A horizontal progress bar.
      See Also:
    • STYLE_CIRCULAR

      public static final int STYLE_CIRCULAR
      A circular gauge. Falls back to linear on Android app widgets.
      See Also:
  • Constructor Details

    • SurfaceProgress

      public SurfaceProgress(int style)

      Creates a progress node.

      Parameters
      • style: STYLE_LINEAR or STYLE_CIRCULAR
  • Method Details

    • setValue

      public SurfaceProgress setValue(float value)

      Sets a literal progress value.

      Parameters
      • value: the progress fraction between 0 and 1
      Returns

      this progress node, for chaining

    • setValueState

      public SurfaceProgress setValueState(String valueStateKey)

      Reads the progress value from the state map. The state value is a Number between 0 and 1.

      Parameters
      • valueStateKey: the state-map key holding the fraction
      Returns

      this progress node, for chaining

    • setDateInterval

      public SurfaceProgress setDateInterval(Date start, Date end)

      Animates progress across a date interval on the OS clock without app wakeups. Only iOS renders this natively; other platforms display the interval's fraction as of their last refresh.

      Parameters
      • start: interval start
      • end: interval end
      Returns

      this progress node, for chaining

    • setColor

      public SurfaceProgress setColor(SurfaceColor color)

      Sets the indicator color.

      Parameters
      • color: the color
      Returns

      this progress node, for chaining

    • getStyle

      public int getStyle()
      Returns STYLE_LINEAR or STYLE_CIRCULAR.
    • getValue

      public float getValue()
      Returns the literal progress fraction, or -1 when unset.
    • getValueKey

      public String getValueKey()
      Returns the state-map key of the progress value, or null.
    • getIntervalStart

      public Date getIntervalStart()
      Returns the animated interval start, or null.
    • getIntervalEnd

      public Date getIntervalEnd()
      Returns the animated interval end, or null.
    • getColor

      public SurfaceColor getColor()
      Returns the indicator color, or null for the platform default.
    • setPadding

      public SurfaceProgress setPadding(int all)
      Description copied from class: SurfaceNode

      Sets the same padding on all four sides.

      Parameters
      • all: padding in dips
      Returns

      this node, for chaining

      Overrides:
      setPadding in class SurfaceNode
    • setPadding

      public SurfaceProgress setPadding(int top, int right, int bottom, int left)
      Description copied from class: SurfaceNode

      Sets the padding of each side individually.

      Parameters
      • top: top padding in dips
      • right: right padding in dips
      • bottom: bottom padding in dips
      • left: left padding in dips
      Returns

      this node, for chaining

      Overrides:
      setPadding in class SurfaceNode
    • setBackground

      public SurfaceProgress setBackground(SurfaceColor background)
      Description copied from class: SurfaceNode

      Sets the background color of this node.

      Parameters
      • color: the background color
      Returns

      this node, for chaining

      Overrides:
      setBackground in class SurfaceNode
    • setCornerRadius

      public SurfaceProgress setCornerRadius(int radius)
      Description copied from class: SurfaceNode

      Sets the corner radius applied to the node's background. May render square on Android versions below 12.

      Parameters
      • radius: the corner radius in dips
      Returns

      this node, for chaining

      Overrides:
      setCornerRadius in class SurfaceNode
    • setAlignment

      public SurfaceProgress setAlignment(SurfaceAlignment alignment)
      Description copied from class: SurfaceNode

      Sets this node's alignment within its parent. In a SurfaceBox all nine positions apply; in rows and columns only the cross-axis component is used.

      Parameters
      • alignment: the alignment
      Returns

      this node, for chaining

      Overrides:
      setAlignment in class SurfaceNode
    • setWeight

      public SurfaceProgress setWeight(int weight)
      Description copied from class: SurfaceNode

      Sets the flexible-space weight of this node within a row or column. Nodes with a weight share the leftover space of the parent proportionally; a weight of 0 (the default) sizes the node to its natural size.

      Parameters
      • weight: the relative weight, 0 for natural sizing
      Returns

      this node, for chaining

      Overrides:
      setWeight in class SurfaceNode
    • setSize

      public SurfaceProgress setSize(int widthDips, int heightDips)
      Description copied from class: SurfaceNode

      Sets a fixed size for this node. A value of 0 (the default) keeps the natural size of the respective axis.

      Parameters
      • widthDips: fixed width in dips, 0 for natural width
      • heightDips: fixed height in dips, 0 for natural height
      Returns

      this node, for chaining

      Overrides:
      setSize in class SurfaceNode
    • setAction

      public SurfaceProgress setAction(String actionId)
      Description copied from class: SurfaceNode

      Assigns a tap action to this node. Tapping the node opens (or foregrounds) the app and delivers the action id to the handler registered with Surfaces.setActionHandler(...). Note that small iOS home-screen widgets only honor the action of the root node.

      Parameters
      • actionId: the app-defined action identifier
      Returns

      this node, for chaining

      Overrides:
      setAction in class SurfaceNode
    • setAction

      public SurfaceProgress setAction(String actionId, Map<String,Object> params)
      Description copied from class: SurfaceNode

      Assigns a tap action with parameters to this node. The parameter map may contain String, Number and Boolean values and is delivered verbatim with the SurfaceActionEvent.

      Parameters
      • actionId: the app-defined action identifier
      • params: parameters delivered with the action, may be null
      Returns

      this node, for chaining

      Overrides:
      setAction in class SurfaceNode