All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class linguist.quickshow.Stage

linguist.quickshow.Stage

public class Stage
The Stage class is a special kind of Canvas that manages a set of Actors, each providing independent but centrally managed behavior. The Stage/Actor metaphor is particularly suited to graphical components having many independent interactive components, such as games.

A number of the methods documented here are available in the Actor class. In general you should avoid using the Stage versions directly; the less use made of the Stage the better. Its job is to stay in the background and quietly manage the system. In most applications the class that you derive from Stage will have little to do beyond some initial setting up.

See Also:
Actor

Variable Index

 o cursorHilite

Constructor Index

 o Stage()
The Stage constructor.

Method Index

 o addActor(Actor, String)
Add an actor to the display list.
 o createImage(int, int)
Create an offscreen (drawing) image.
 o disableEvents()
 o enableEvents()
 o findActor(String)
Find an Actor by name.
 o findActor(String, int)
Find an Actor by name and ID.
 o findFrontActor(int, int)
Find which actor is frontmost at a given screen position.
 o getActors()
Get the list of Actors currently registered with the Stage.
 o getApplet()
Return the Applet for this Stage.
 o getBottom()
Get the bottom position of the Stage.
 o getCursorX()
Get the cursor X position.
 o getCursorY()
Get the cursor Y position.
 o getData(String)
Retrieve the data stored for a key.
 o getHeight()
Get the height of the Stage.
 o getLastInputEvent()
Get the most recent cursor event.
 o getLeft()
Get the left position of the Stage.
 o getRefreshDelay()
Get the current refresh delay.
 o getRight()
Get the right position of the Stage.
 o getSound(String)
Get a sound.
 o getTop()
Get the top position of the Stage.
 o getWidth()
Get the width of the Stage.
 o init()
Initialize the Stage.
 o isData(String)
Tell me if some data is present.
 o moveBehind(Actor, Actor)
Move one actor behind another.
 o moveInFront(Actor, Actor)
Move one actor in front of another.
 o paint(Graphics)
Paint the Stage.
 o pause(int)
Pause for a given number of milliseconds.
 o postMessage(String, int, String)
Post a message to an Actor.
 o postMessage(String, int, String, Object)
Post a message with data to an Actor.
 o postMessage(String, String)
Post a message to an Actor.
 o postMessage(String, String, Object)
Post a message with data to an Actor.
 o processMessage(String, Object)
Process a message.
 o processMouseEvent(MouseEvent)
Handle a mouse event.
 o processMouseMotionEvent(MouseEvent)
Handle a mouse motion event.
 o putData(String, Object)
Save some data for an Actor.
 o redraw()
Redraw the Stage.
 o redrawAll()
Redraw the entire Stage.
 o removeActor(Actor)
Remove an actor from the display list.
 o removeData(String)
Remove the data stored for a key.
 o run()
The Thread 'run()' method.
 o sendMessage(String, int, String)
Send a message to an Actor.
 o sendMessage(String, int, String, Object)
Send a message with data to an Actor.
 o sendMessage(String, String)
Send a message to an Actor.
 o sendMessage(String, String, Object)
Send a message with data to an Actor.
 o setCursorHilite(CursorHilite)
Add a cursor hilite.
 o setRefreshDelay(int)
Set the current refresh delay.
 o setSize(int, int)
Override this method in Canvas to prevent the Stage being resized.
 o setStageSize(int, int)
(Re)size the stage.
 o setupStage()
Set up the Stage.
 o showStatus(String)
Display a status message in the browser status window.
 o stageHook()
 o stop()
Stop this Thread.
 o toBack(Actor)
Move an actor to the back of the display list.
 o toFront(Actor)
Move an actor to the front of the display list.
 o update(Graphics)
Override of the update() method to prevent the background being drawn.
 o updateCursorEvents()
Force a cursor in or out event.
 o waitForActors()
Wait for all Actors to be ready.

Variables

 o cursorHilite
 protected CursorHilite cursorHilite

Constructors

 o Stage
 public Stage()
The Stage constructor.

Methods

 o getActors
 public Vector getActors()
Get the list of Actors currently registered with the Stage.

Returns:
A Vector comprising each of the registered Actors. The one at the back of the display list will be first in the Vector.
See Also:
Actor
 o getLeft
 public int getLeft()
Get the left position of the Stage.

Returns:
The position.
 o getRight
 public int getRight()
Get the right position of the Stage.

Returns:
The position.
 o getTop
 public int getTop()
Get the top position of the Stage.

Returns:
The position.
 o getBottom
 public int getBottom()
Get the bottom position of the Stage.

Returns:
The position.
 o getWidth
 public int getWidth()
Get the width of the Stage.

Returns:
The width, in pixels.
 o getHeight
 public int getHeight()
Get the height of the Stage.

Returns:
The height, in pixels.
 o getRefreshDelay
 public int getRefreshDelay()
Get the current refresh delay. This is the interval between screen updates.

Returns:
The delay, in milliseconds.
 o setRefreshDelay
 public void setRefreshDelay(int d)
Set the current refresh delay. This is the interval between screen updates. The default is 100.

Parameters:
d - the delay, in milliseconds.
 o update
 public void update(Graphics g)
Override of the update() method to prevent the background being drawn.

Parameters:
g - the Graphics object with which to paint.
 o paint
 public void paint(Graphics g)
Paint the Stage. Since the Stage is used to draw all the Actors, it is always up to date and can be transferred directly to the screen when an update is needed.

Parameters:
g - the Graphics object with which to paint.
 o getApplet
 public Applet getApplet()
Return the Applet for this Stage. If the Stage is not part of an Applet this returns null.

 o init
 protected void init()
Initialize the Stage.

 o run
 public void run()
The Thread 'run()' method. Here the Stage updates itself at a regular interval, calling redraw() to do the work.

See Also:
redraw
 o stop
 public void stop()
Stop this Thread.

 o setupStage
 protected void setupStage()
Set up the Stage. This includes setting the size and loading the Actor(s). Override as necessary. The base method does nothing.

 o addActor
 public synchronized void addActor(Actor actor,
                                   String target)
Add an actor to the display list.

Parameters:
actor - the Actor to add.
target - if null, put the Actor at the front of the list. If not null, this is the name of another Actor behind which this Actor should be placed.
 o removeActor
 public synchronized void removeActor(Actor a)
Remove an actor from the display list.

Parameters:
actor - the Actor to remove.
 o toFront
 public synchronized void toFront(Actor a)
Move an actor to the front of the display list.

Parameters:
actor - the Actor to move.
 o toBack
 public synchronized void toBack(Actor a)
Move an actor to the back of the display list.

Parameters:
actor - the Actor to move.
 o moveInFront
 public synchronized void moveInFront(Actor a,
                                      Actor b)
Move one actor in front of another.

Parameters:
a - the Actor to move.
b - the Actor to move in front of.
 o moveBehind
 public synchronized void moveBehind(Actor a,
                                     Actor b)
Move one actor behind another.

Parameters:
a - the Actor to move.
b - the Actor to move behind.
 o waitForActors
 public void waitForActors()
Wait for all Actors to be ready. This will usually be called from setupStage() after instantiating all the Actors.

See Also:
setupStage
 o setCursorHilite
 protected void setCursorHilite(CursorHilite h)
Add a cursor hilite.

Parameters:
h - the CursorHilite object to use on this Stage.
 o getCursorX
 public int getCursorX()
Get the cursor X position.

Returns:
The cursor X position valid at the most recent event.
 o getCursorY
 public int getCursorY()
Get the cursor Y position.

Returns:
The cursor Y position valid at the most recent event.
 o getLastInputEvent
 public InputEvent getLastInputEvent()
Get the most recent cursor event.

Returns:
The cursor Y position valid at the most recent event.
See Also:
processMouseEvent
 o disableEvents
 public void disableEvents()
 o enableEvents
 public void enableEvents()
 o processMouseEvent
 public void processMouseEvent(MouseEvent e)
Handle a mouse event.

Parameters:
e - the event to be handled.
 o processMouseMotionEvent
 public void processMouseMotionEvent(MouseEvent e)
Handle a mouse motion event.

Parameters:
e - the event to be handled.
 o updateCursorEvents
 public void updateCursorEvents()
Force a cursor in or out event. This is useful to get the correct cursor if the Stage has been rebuilt under the cursor.

 o findFrontActor
 public Actor findFrontActor(int x,
                             int y)
Find which actor is frontmost at a given screen position.

Parameters:
x - the X screen position.
y - the Y screen position.
 o findActor
 public Actor findActor(String name)
Find an Actor by name.

Parameters:
name - the name of the Actor.
 o findActor
 public Actor findActor(String name,
                        int id)
Find an Actor by name and ID.

Parameters:
name - the name of the Actor.
id - the ID of the Actor.
 o setStageSize
 public void setStageSize(int w,
                          int h)
(Re)size the stage.

Parameters:
w - the (new) width required.
h - the (new) height required.
 o setSize
 public void setSize(int w,
                     int h)
Override this method in Canvas to prevent the Stage being resized.

Parameters:
w - ignored.
h - ignored.
 o createImage
 public Image createImage(int w,
                          int h)
Create an offscreen (drawing) image. This only works if the container of this Stage is visible.

Parameters:
w - the width required.
h - the height required.
 o redrawAll
 public void redrawAll()
Redraw the entire Stage.

 o redraw
 public synchronized void redraw()
Redraw the Stage. Get the invalid rectangles from all the Actors and from the CursorHilite, then if there is anything to draw, do it. Finally, send sync messages to each Actor as a timing reference.

 o showStatus
 public void showStatus(String s)
Display a status message in the browser status window.

Parameters:
s - the string to display.
 o pause
 public boolean pause(int ms)
Pause for a given number of milliseconds.

Parameters:
ms - the pause duration in milliseconds.
 o getSound
 public AudioClip getSound(String name)
Get a sound.

Parameters:
name - the name of the sound.
Returns:
An AudioClip object.
 o postMessage
 public void postMessage(String name,
                         String s)
Post a message to an Actor.

Parameters:
name - the name of the Actor.
s - the message String.
 o postMessage
 public void postMessage(String name,
                         String s,
                         Object d)
Post a message with data to an Actor.

Parameters:
name - the name of the Actor.
s - the message String.
d - some additional data.
 o postMessage
 public void postMessage(String name,
                         int id,
                         String s)
Post a message to an Actor.

Parameters:
name - the name of the Actor.
id - the ID of the Actor.
s - the message String.
 o postMessage
 public void postMessage(String name,
                         int id,
                         String s,
                         Object d)
Post a message with data to an Actor.

Parameters:
name - the name of the Actor.
id - the ID of the Actor.
s - the message String.
d - some additional data.
 o sendMessage
 public Object sendMessage(String name,
                           String s)
Send a message to an Actor.

Parameters:
name - the name of the Actor.
s - the message String.
 o sendMessage
 public Object sendMessage(String name,
                           String s,
                           Object d)
Send a message with data to an Actor.

Parameters:
name - the name of the Actor.
s - the message String.
d - some additional data.
 o sendMessage
 public Object sendMessage(String name,
                           int id,
                           String s)
Send a message to an Actor.

Parameters:
name - the name of the Actor.
id - the ID of the Actor.
s - the message String.
 o sendMessage
 public Object sendMessage(String name,
                           int id,
                           String s,
                           Object d)
Send a message with data to an Actor.

Parameters:
name - the name of the Actor.
id - the ID of the Actor.
s - the message String.
d - some additional data.
 o putData
 public void putData(String key,
                     Object data)
Save some data for an Actor. Data saved in this way is permanent (for the life of the Stage) and can be retrieved later by any Actor.

Parameters:
key - a unique key.
data - the data item to save.
 o isData
 public boolean isData(String key)
Tell me if some data is present.

Parameters:
key - the key.
Returns:
True if an item of data has been stored for this key.
 o getData
 public Object getData(String key)
Retrieve the data stored for a key.

Parameters:
key - the key.
Returns:
The item of data stored for this key, or null.
 o removeData
 public void removeData(String key)
Remove the data stored for a key.

Parameters:
key - the key.
 o stageHook
 public void stageHook()
 o processMessage
 public void processMessage(String command,
                            Object data)
Process a message. This provides a means to send data to a subclass object.

Parameters:
command - the message string.
data - an optional data packet, or null.

All Packages  Class Hierarchy  This Package  Previous  Next  Index