GT Computing Home Page

GT Computing Home Page

Stage Class Reference

Revision history:

  • March 11, 1998 - Rev 1.05 - Add permanent data storage.
  • April 8, 1998 - Rev 1.1 - Implement clocked update.
  • September 17, 1998 - Replaced by linguist.quickshow.Stage.

A Stage coordinates all the actions that take place within its visible area. Working with one or more Actors, it enables the functionality of an applet to be divided logically among a set of communicating objects rather than putting all the functionality into one place, and minimizes the overhead in managing this technique. A Stage should confine itself to constructing the Actors and (usually) initiating the first event; after that it should play little part in proceedings. All the rest is done by Actors.

Hint: Where a method is provided in the Actor class, do not use the Stage method of the same name as it is more consistent to use the Actor method.

The operation of the Stage is roughly as follows. At a regular rate that defaults to ten times per second, the Stage examines each of its Actors and the CursorHilite to see if any need updating. If the resulting invalid rectangle is not empty, each of the Actors is called to update any part of itself that lies within that rectangle. (This usually means each Actor redraws itself in its entirety.) Then the Stage copies the invalid rectangle to the Applet window, where you get to see the result. Next it calls the sync() method in each Actor, which gives each one the opportunity to perform its actions in a regular timed manner. Finally the Stage waits for the remainder of the timing period before starting the sequence over.

A useful feature of an Actor is its ability to synchronize with its Stage. As you will see from its documentation, screen updates are performed at a fixed (user programmable) rate that defaults to ten updates/sec. An Actor can run at any speed it likes but the results of its efforts will only appear at that rate. So in many cases it makes sense for the Actor to synchronize with its Stage, to save doing unnecessary work. This is the reason for the sync() method. After the Stage has updated everything (that needed updating) it calls each of its Actor's sync() methods. These are empty by default, but you can override them to do useful processing. Knowing the Stage update rate you can make sure your Actor maintains a known speed without using extra timers.

Formal (javadoc) documentation