gnu.app.displayhack
Class DisplayHack

java.lang.Object
  extended by gnu.app.Application
      extended by gnu.x11.Application
          extended by gnu.app.displayhack.DisplayHack
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Deco, Munch, Rorschach, Sprites, Squiral

public abstract class DisplayHack
extends Application
implements java.lang.Runnable

Base class for display hacks.

The implementation uses two threads so that one can be painting and one can be waiting for user input. Only with two threads can sleep(long) be interrupted (with restart() or exit()) to give responsive user interface.


Field Summary
 boolean clear
          Clear window before the first iteration.
 Color[] colors
           
 long delay
           
 boolean erase
          Erase window between iterations.
 long eraser_delay
           
 int eraser_delta
           
 GC eraser_gc
           
 int eraser_mode
           
 GC gc
           
 GC.Values gc_values
           
static java.util.Random random
           
 boolean stop_now
           
 java.lang.Thread thread
           
 Window window
           
 
Fields inherited from class gnu.x11.Application
display
 
Constructor Summary
DisplayHack(java.lang.String[] args, boolean clear, boolean erase, boolean rainbow_color, int default_color_count, int default_delay)
           
 
Method Summary
 void about(java.lang.String version, java.lang.String description, java.lang.String author, java.lang.String url)
          #about(String, String, String, String, String)
static boolean chance(float probability)
           
 void dispatch_event()
           
 void erase()
           
 void exec()
          Main method.
 void exit()
           
abstract  void paint()
           
 Color random_color()
           
 int random_int(int n)
          Random.nextInt(int) accepting zero as argument.
 int random_sign()
           
 void restart()
           
 void run()
           
 boolean sleep(long millis)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stop_now

public boolean stop_now

random

public static final java.util.Random random

eraser_delta

public int eraser_delta

eraser_mode

public int eraser_mode

delay

public long delay

eraser_delay

public long eraser_delay

colors

public Color[] colors

gc

public GC gc

eraser_gc

public GC eraser_gc

gc_values

public GC.Values gc_values

window

public Window window

thread

public java.lang.Thread thread

clear

public boolean clear
Clear window before the first iteration. Hacks that play with screen content or those that wish to improve initial perceived drawing speed (such as Deco) should set this to false.


erase

public boolean erase
Erase window between iterations.

Constructor Detail

DisplayHack

public DisplayHack(java.lang.String[] args,
                   boolean clear,
                   boolean erase,
                   boolean rainbow_color,
                   int default_color_count,
                   int default_delay)
Method Detail

paint

public abstract void paint()

about

public void about(java.lang.String version,
                  java.lang.String description,
                  java.lang.String author,
                  java.lang.String url)
Description copied from class: Application
#about(String, String, String, String, String)


chance

public static boolean chance(float probability)

dispatch_event

public void dispatch_event()

erase

public void erase()

exec

public void exec()
Main method. Separating this method from constructor allows subclass constructors to be called before dispatching the first Expose. It is responsible for user interaction.


exit

public void exit()

random_color

public Color random_color()

random_int

public int random_int(int n)
Random.nextInt(int) accepting zero as argument.


random_sign

public int random_sign()

restart

public void restart()

run

public void run()
Specified by:
run in interface java.lang.Runnable

sleep

public boolean sleep(long millis)