Class InfiniteProgress

java.lang.Object
com.codename1.ui.Component
com.codename1.components.InfiniteProgress
All Implemented Interfaces:
Animation, Editable, StyleListener

public class InfiniteProgress extends Component

Shows a "Washing Machine" infinite progress indication animation, to customize the image you can either use the infiniteImage theme constant or the setAnimation method. The image is rotated automatically so don't use an animated image or anything like that as it would fail with the rotation logic.

This class can be used in one of two ways either by embedding the component into the UI thru something like this:

myContainer.add(new InfiniteProgress());

Notice that this can be used within a custom dialog too.

A second approach allows showing the infinite progress over the entire screen which blocks all input. This tints the background while the infinite progress rotates:

Dialog ip = new InfiniteProgress().showInifiniteBlocking();

// do some long operation here using invokeAndBlock or do something in a separate thread and callback later
// when you are done just call

ip.dispose();
  • Constructor Details

    • InfiniteProgress

      public InfiniteProgress()
      Default constructor to define the UIID
  • Method Details

    • isDefaultMaterialDesignMode

      public static boolean isDefaultMaterialDesignMode()

      Indicates whether infinite progress and pull to refresh work in the material design mode by default

      Returns

      the defaultMaterialDesignMode

    • setDefaultMaterialDesignMode

      public static void setDefaultMaterialDesignMode(boolean aDefaultMaterialDesignMode)

      Indicates whether infinite progress and pull to refresh work in the material design mode by default

      Parameters
      • aDefaultMaterialDesignMode: the defaultMaterialDesignMode to set
    • getDefaultMaterialDesignColor

      public static int getDefaultMaterialDesignColor()

      The default color of the current material design progress spinner

      Returns

      the defaultMaterialDesignColor

    • setDefaultMaterialDesignColor

      public static void setDefaultMaterialDesignColor(int aDefaultMaterialDesignColor)

      The default color of the current material design progress spinner

      Parameters
      • aDefaultMaterialDesignColor: the defaultMaterialDesignColor to set
    • showInifiniteBlocking

      public Dialog showInifiniteBlocking()

      Shows the infinite progress over the whole screen, the blocking can be competed by calling dispose() on the returned Dialog.

      Dialog ip = new InfiniteProgress().showInifiniteBlocking();
      
      // do some long operation here using invokeAndBlock or do something in a separate thread and callback later
      // when you are done just call
      
      ip.dispose();
      
      Returns

      the dialog created for the blocking effect, disposing it will return to the previous form and remove the input block.

      Deprecated

      typo in method name please use #showInfiniteBlocking() instead

    • showInfiniteBlocking

      public Dialog showInfiniteBlocking()

      Shows the infinite progress over the whole screen, the blocking can be competed by calling dispose() on the returned Dialog.

      Dialog ip = new InfiniteProgress().showInifiniteBlocking();
      
      // do some long operation here using invokeAndBlock or do something in a separate thread and callback later
      // when you are done just call
      
      ip.dispose();
      
      Returns

      the dialog created for the blocking effect, disposing it will return to the previous form and remove the input block.

    • initComponent

      protected void initComponent()
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • deinitialize

      protected void deinitialize()
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
      Overrides:
      deinitialize in class Component
    • animate

      public boolean animate()

      Updates the progress animation. This only updates if the InfiniteProgress is on the currently displayed form and is visible. If you need to update the progress animation in another context, use #animate(boolean).

      Returns

      true if it animated and should be repainted.

      Specified by:
      animate in interface Animation
      Overrides:
      animate in class Component
    • animate

      public boolean animate(boolean force)

      Updates the progress animation.

      Parameters
      • force: @param force If false, then the animation is only updated if the progress is visible and on the current form. True will force the update.
      Returns

      True if it animated and should be repainted.

      Since

      7.0

    • calcPreferredSize

      protected Dimension calcPreferredSize()

      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 Component
    • paint

      public void paint(Graphics g)

      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 Component
    • getAnimation

      public Image getAnimation()
      Returns

      the animation

    • setAnimation

      public void setAnimation(Image animation)

      Allows setting the image that will be rotated as part of this effect

      Parameters
      • animation: the animation to set
    • 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
    • getTintColor

      public int getTintColor()

      The tinting color of the screen when the showInfiniteBlocking method is invoked

      Returns

      the tintColor

    • setTintColor

      public void setTintColor(int tintColor)

      The tinting color of the screen when the showInfiniteBlocking method is invoked

      Parameters
      • tintColor: the tintColor to set
    • getTickCount

      public int getTickCount()

      The animation rotates with EDT ticks, but not for every tick. To slow down the animation increase this number and to speed it up reduce it to 1. It can't be 0 or lower.

      Returns

      the tickCount

    • setTickCount

      public void setTickCount(int tickCount)

      The animation rotates with EDT ticks, but not for every tick. To slow down the animation increase this number and to speed it up reduce it to 1. It can't be 0 or lower.

      Parameters
      • tickCount: the tickCount to set
    • getAngleIncrease

      public int getAngleIncrease()

      The angle to increase (in degrees naturally) in every tick count, reduce to 1 to make the animation perfectly slow and smooth, increase to 45 to make it fast and jumpy. Its probably best to use a number that divides well with 360 but that isn't a requirement. Valid numbers are anything between 1 and 359.

      Returns

      the angleIncrease

    • setAngleIncrease

      public void setAngleIncrease(int angleIncrease)

      The angle to increase (in degrees naturally) in every tick count, reduce to 1 to make the animation perfectly slow and smooth, increase to 45 to make it fast and jumpy. Its probably best to use a number that divides well with 360 but that isn't a requirement. Valid numbers are anything between 1 and 359.

      Parameters
      • angleIncrease: the angleIncrease to set
    • isMaterialDesignMode

      public boolean isMaterialDesignMode()

      Indicates whether this instance of infinite progress works in the material design mode by default

      Returns

      the materialDesignMode

    • setMaterialDesignMode

      public void setMaterialDesignMode(boolean materialDesignMode)

      Indicates whether this instance of infinite progress works in the material design mode by default

      Parameters
      • materialDesignMode: the materialDesignMode to set
    • getMaterialDesignColor

      public int getMaterialDesignColor()

      The color of the current material design progress spinner

      Returns

      the materialDesignColor

    • setMaterialDesignColor

      public void setMaterialDesignColor(int materialDesignColor)

      The color of the current material design progress spinner

      Parameters
      • materialDesignColor: the materialDesignColor to set