Class ConsoleLoadingAnimation


  • public class ConsoleLoadingAnimation
    extends java.lang.Object
    A simple function to create a loading animation in the console. Useful while startup routines to show a user that the software is still working. Cant be used with ConsoleManager together.
    • Method Summary

      Modifier and Type Method Description
      static void disable()
      Disable and remove the loading animation.
      static void enable()
      Enable the loading animation and take over print stream to prevent output while loading.
      static void enable​(boolean takeOverSystemOutputStream)
      Enable the loading animation.
      static boolean isEnabled()
      Is the animation enabled?
      static void setAnimation​(char[] animation)
      The animation chars in the correct order.
      static void setSpeed​(int speed)
      The speed of the animation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConsoleLoadingAnimation

        public ConsoleLoadingAnimation()
    • Method Detail

      • enable

        public static void enable()
        Enable the loading animation and take over print stream to prevent output while loading. Cant be used with ConsoleManager together.
      • enable

        public static void enable​(boolean takeOverSystemOutputStream)
        Enable the loading animation. Cant be used with ConsoleManager together.
        Parameters:
        takeOverSystemOutputStream - Take over the output stream from System.out to prevent output while showing loading animation?
      • disable

        public static void disable()
                            throws java.lang.InterruptedException,
                                   java.util.concurrent.TimeoutException
        Disable and remove the loading animation.
        Throws:
        java.lang.InterruptedException - InterruptedException from Thread.sleep() while waiting for the thread shutdown.
        java.util.concurrent.TimeoutException - If the threads are not stopping this exception will be triggered after 10 seconds.
      • setAnimation

        public static void setAnimation​(char[] animation)
        The animation chars in the correct order. Will also reset the animation to start at the beginning.
        Parameters:
        animation - Default is {'⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷'}.
      • setSpeed

        public static void setSpeed​(int speed)
        The speed of the animation. Higher is slower.
        Parameters:
        speed - Default is 25.
      • isEnabled

        public static boolean isEnabled()
        Is the animation enabled?
        Returns:
        Returns true if the animation is enabled.