package com.mindprod.example;
import static java.lang.System.*;
/**
* Methods to display on the console the fact your app is still alive and busy working away.
* <p/>
* These are classics from the days of the Apple][ and DOS.
* These won't work on eclipse which displays \b as a box instead of backspace.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2009-01-01 initial version
* @since 2009-01-01
*/
public final class TestImAlive
{
/**
* chars to cycle through in the bubble display
*/
private static final char bubbles[] = { '.', 'o', 'O', 'o' };
/**
* chars to cycle through in the spinner display
*/
private static final char spins[] = { '-', '\\', '|', '/' };
/**
* where we are in the bubble cycle 0..4
*/
private static int bubbleCycle = 0;
/**
* where we are in the spinner cycle 0..4
*/
private static int spinCycle = 0;
/**
* display an animated bubble on the console that kicks over each elapsedTime spinner is called.
*/
private static void bubbler()
{
out.print( bubbles[ bubbleCycle ] + "\b" );
bubbleCycle = ( bubbleCycle + 1 ) & 3;
}
/**
* display an animated spinner on the console that kicks over each elapsedTime spinner is called.
*/
private static void spinner()
{
out.print( spins[ spinCycle ] + "\b" );
spinCycle = ( spinCycle + 1 ) & 3;
}
/**
* Test harness for bubbler and spinner
*
* @param args not used
*/
@SuppressWarnings( { "EmptyCatchBlock" } )
public static void main( String[] args )
{
for ( int i = 0; i < 20; i++ )
{
try
{
Thread.sleep( 250 );// sleep .25 a second
}
catch ( InterruptedException e )
{
}
bubbler();
}
for ( int i = 0; i < 20; i++ )
{
try
{
Thread.sleep( 250 );// sleep .25 a second
}
catch ( InterruptedException e )
{
}
spinner();
}
}
}