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
-
cursorHilite
-
-
Stage()
- The Stage constructor.
-
addActor(Actor, String)
- Add an actor to the display list.
-
createImage(int, int)
- Create an offscreen (drawing) image.
-
disableEvents()
-
-
enableEvents()
-
-
findActor(String)
- Find an Actor by name.
-
findActor(String, int)
- Find an Actor by name and ID.
-
findFrontActor(int, int)
- Find which actor is frontmost at a given screen position.
-
getActors()
- Get the list of Actors currently registered with the Stage.
-
getApplet()
- Return the Applet for this Stage.
-
getBottom()
- Get the bottom position of the Stage.
-
getCursorX()
- Get the cursor X position.
-
getCursorY()
- Get the cursor Y position.
-
getData(String)
- Retrieve the data stored for a key.
-
getHeight()
- Get the height of the Stage.
-
getLastInputEvent()
- Get the most recent cursor event.
-
getLeft()
- Get the left position of the Stage.
-
getRefreshDelay()
- Get the current refresh delay.
-
getRight()
- Get the right position of the Stage.
-
getSound(String)
- Get a sound.
-
getTop()
- Get the top position of the Stage.
-
getWidth()
- Get the width of the Stage.
-
init()
- Initialize the Stage.
-
isData(String)
- Tell me if some data is present.
-
moveBehind(Actor, Actor)
- Move one actor behind another.
-
moveInFront(Actor, Actor)
- Move one actor in front of another.
-
paint(Graphics)
- Paint the Stage.
-
pause(int)
- Pause for a given number of milliseconds.
-
postMessage(String, int, String)
- Post a message to an Actor.
-
postMessage(String, int, String, Object)
- Post a message with data to an Actor.
-
postMessage(String, String)
- Post a message to an Actor.
-
postMessage(String, String, Object)
- Post a message with data to an Actor.
-
processMessage(String, Object)
- Process a message.
-
processMouseEvent(MouseEvent)
- Handle a mouse event.
-
processMouseMotionEvent(MouseEvent)
- Handle a mouse motion event.
-
putData(String, Object)
- Save some data for an Actor.
-
redraw()
- Redraw the Stage.
-
redrawAll()
- Redraw the entire Stage.
-
removeActor(Actor)
- Remove an actor from the display list.
-
removeData(String)
- Remove the data stored for a key.
-
run()
- The Thread 'run()' method.
-
sendMessage(String, int, String)
- Send a message to an Actor.
-
sendMessage(String, int, String, Object)
- Send a message with data to an Actor.
-
sendMessage(String, String)
- Send a message to an Actor.
-
sendMessage(String, String, Object)
- Send a message with data to an Actor.
-
setCursorHilite(CursorHilite)
- Add a cursor hilite.
-
setRefreshDelay(int)
- Set the current refresh delay.
-
setSize(int, int)
- Override this method in Canvas to prevent the Stage being resized.
-
setStageSize(int, int)
- (Re)size the stage.
-
setupStage()
- Set up the Stage.
-
showStatus(String)
- Display a status message in the browser status window.
-
stageHook()
-
-
stop()
- Stop this Thread.
-
toBack(Actor)
- Move an actor to the back of the display list.
-
toFront(Actor)
- Move an actor to the front of the display list.
-
update(Graphics)
- Override of the update() method to prevent the background being drawn.
-
updateCursorEvents()
- Force a cursor in or out event.
-
waitForActors()
- Wait for all Actors to be ready.
cursorHilite
protected CursorHilite cursorHilite
Stage
public Stage()
- The Stage constructor.
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
getLeft
public int getLeft()
- Get the left position of the Stage.
- Returns:
- The position.
getRight
public int getRight()
- Get the right position of the Stage.
- Returns:
- The position.
getTop
public int getTop()
- Get the top position of the Stage.
- Returns:
- The position.
getBottom
public int getBottom()
- Get the bottom position of the Stage.
- Returns:
- The position.
getWidth
public int getWidth()
- Get the width of the Stage.
- Returns:
- The width, in pixels.
getHeight
public int getHeight()
- Get the height of the Stage.
- Returns:
- The height, in pixels.
getRefreshDelay
public int getRefreshDelay()
- Get the current refresh delay.
This is the interval between screen updates.
- Returns:
- The delay, in milliseconds.
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.
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.
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.
getApplet
public Applet getApplet()
- Return the Applet for this Stage.
If the Stage is not part of an Applet this returns null.
init
protected void init()
- Initialize the Stage.
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
stop
public void stop()
- Stop this Thread.
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.
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.
removeActor
public synchronized void removeActor(Actor a)
- Remove an actor from the display list.
- Parameters:
- actor - the Actor to remove.
toFront
public synchronized void toFront(Actor a)
- Move an actor to the front of the display list.
- Parameters:
- actor - the Actor to move.
toBack
public synchronized void toBack(Actor a)
- Move an actor to the back of the display list.
- Parameters:
- actor - the Actor to move.
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.
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.
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
setCursorHilite
protected void setCursorHilite(CursorHilite h)
- Add a cursor hilite.
- Parameters:
- h - the CursorHilite object to use on this Stage.
getCursorX
public int getCursorX()
- Get the cursor X position.
- Returns:
- The cursor X position valid at the most recent event.
getCursorY
public int getCursorY()
- Get the cursor Y position.
- Returns:
- The cursor Y position valid at the most recent event.
getLastInputEvent
public InputEvent getLastInputEvent()
- Get the most recent cursor event.
- Returns:
- The cursor Y position valid at the most recent event.
- See Also:
- processMouseEvent
disableEvents
public void disableEvents()
enableEvents
public void enableEvents()
processMouseEvent
public void processMouseEvent(MouseEvent e)
- Handle a mouse event.
- Parameters:
- e - the event to be handled.
processMouseMotionEvent
public void processMouseMotionEvent(MouseEvent e)
- Handle a mouse motion event.
- Parameters:
- e - the event to be handled.
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.
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.
findActor
public Actor findActor(String name)
- Find an Actor by name.
- Parameters:
- name - the name of the Actor.
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.
setStageSize
public void setStageSize(int w,
int h)
- (Re)size the stage.
- Parameters:
- w - the (new) width required.
- h - the (new) height required.
setSize
public void setSize(int w,
int h)
- Override this method in Canvas to prevent the Stage being resized.
- Parameters:
- w - ignored.
- h - ignored.
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.
redrawAll
public void redrawAll()
- Redraw the entire Stage.
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.
showStatus
public void showStatus(String s)
- Display a status message in the browser status window.
- Parameters:
- s - the string to display.
pause
public boolean pause(int ms)
- Pause for a given number of milliseconds.
- Parameters:
- ms - the pause duration in milliseconds.
getSound
public AudioClip getSound(String name)
- Get a sound.
- Parameters:
- name - the name of the sound.
- Returns:
- An AudioClip object.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
removeData
public void removeData(String key)
- Remove the data stored for a key.
- Parameters:
- key - the key.
stageHook
public void stageHook()
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