|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmaclib.DrawingStuff
public final class DrawingStuff
A DrawingStuff object implements an off-screen image for
backing store and provides automatic repaint for a
DrawingApplet panel.
The drawings are to be done on the off-screen image, using the graphic
context that is obtained by a call to the getGraphics()
method.
New drawings have to be explicitely exposed by invoking the
doExpose method.
When the DrawingApplet panel needs to be repaint, its
paint method calls the DrawingStuff's one.
The DrawingStuff also implements listeners for handling
keyboard and mouse events that concern the DrawingApplet.
MacLib,
DrawingFrame,
DrawingApplet| Field Summary | |
|---|---|
static int |
CONTROL
Used to encode the control modifier in the button state. |
static int |
DEFAULT_SCREEN_HEIGHT
The default final height for an off-screen image. |
static int |
DEFAULT_SCREEN_WIDTH
The default final width for an off-screen image. |
static int |
META
Used to encode the meta modifier in the button state. |
static int |
NONE
Used to specify no modifier in the button state. |
static int |
SHIFT
Used to encode the shift modifier in the button state. |
| Constructor Summary | |
|---|---|
DrawingStuff(DrawingApplet panel,
int width,
int height,
java.lang.String debug)
Constructs and initializes a DrawingStuff attached to the
specified DrawingApplet. |
|
| Method Summary | |
|---|---|
void |
dispose()
Disposes of this DrawingStuff and releases its resources. |
void |
doExpose(int left,
int top,
int right,
int bottom)
Paints the specified rectangular area onto the visible panel with the content of the associated off-screen image. |
void |
finalize()
Called by the garbage collector when there are no more reference to this DrawingStuff. |
boolean |
getButton()
Returns the state of the mouse button. |
int |
getButtonState()
Returns an integer value that describes the modifier keys state at the time of the last mouse pressed event. |
java.awt.Graphics |
getGraphics()
Returns a graphic context for drawing onto the off-screen image that is associated to this DrawingStuff. |
char |
getKey()
Returns the char corresponding to the last keyboard event. |
java.awt.Point |
getMouse()
Returns the current mouse location (relative to the corresponding drawing panel) as a java.awt.Point. |
void |
keyPressed(java.awt.event.KeyEvent e)
Invoked by the event handler when a key has been pressed. |
void |
keyReleased(java.awt.event.KeyEvent e)
Invoked by the event handler when a key has been released. |
void |
keyTyped(java.awt.event.KeyEvent e)
Invoked by the event handler when a key has been typed. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Invoked by the event handler when the mouse has been clicked on the drawing panel. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Invoked by the event handler when a mouse button is pressed on the drawing panel and then dragged. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Invoked by the event handler when the mouse enters the drawing panel. |
void |
mouseExited(java.awt.event.MouseEvent e)
Invoked by the event handler when the mouse exits the drawing panel. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Invoked by the event handler when the mouse has been moved on the drawing panel (with no button down). |
void |
mousePressed(java.awt.event.MouseEvent e)
Invoked by the event handler when a mouse button has been pressed on the drawing panel. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Invoked by the event handler when a mouse button has been released on the drawing panel. |
void |
paint(java.awt.Graphics g)
Invoked by the DrawingApplet.paint(Graphics) method when
an exposed area needs to be repaint. |
char |
peekKey()
Returns the char corresponding to the last keyboard event, if any occurs and the char is still kept available. |
void |
reset()
Resets the drawing and event context of this DrawingStuff. |
java.lang.String |
toString()
Returns a string representation of the state of this DrawingStuff. |
boolean |
waitClick()
Waits until the mouse button is pressed or released, then returns the state of the mouse button. |
java.awt.Point |
waitMouse()
Waits until the mouse button is released, after being pressed, or until the mouse location is dragged. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NONE
getButtonState(),
Constant Field Valuespublic static final int SHIFT
getButtonState(),
Constant Field Valuespublic static final int CONTROL
getButtonState(),
Constant Field Valuespublic static final int META
getButtonState(),
Constant Field Valuespublic static final int DEFAULT_SCREEN_WIDTH
DrawingStuff(maclib.DrawingApplet, int, int, java.lang.String),
Constant Field Valuespublic static final int DEFAULT_SCREEN_HEIGHT
DrawingStuff(maclib.DrawingApplet, int, int, java.lang.String),
Constant Field Values| Constructor Detail |
|---|
public DrawingStuff(DrawingApplet panel,
int width,
int height,
java.lang.String debug)
DrawingStuff attached to the
specified DrawingApplet.
panel - the DrawingAppletwidth - the final width of the off-screen imageheight - the final height of the off-screen imagedebug - a string indicating the debug level| Method Detail |
|---|
public void dispose()
DrawingStuff and releases its resources.
This method is called by the dispose() method for
DrawingApplet.
public void finalize()
DrawingStuff.
finalize in class java.lang.Objectpublic java.awt.Graphics getGraphics()
DrawingStuff.
This context should be explicitely disposed when finished.
Graphics object.
public void doExpose(int left,
int top,
int right,
int bottom)
left - the left coordinate of the filled area.top - the top coordinate of the filled area.right - the right coordinate of the filled area.bottom - the bottom coordinate of the filled area.public void paint(java.awt.Graphics g)
DrawingApplet.paint(Graphics) method when
an exposed area needs to be repaint.
It results in copying the content of the associated off-screen image
onto the panel.
public void reset()
DrawingStuff.
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic boolean getButton()
true if the button is currently down;
false otherwise.public java.awt.Point getMouse()
java.awt.Point.
java.awt.Point objectpublic boolean waitClick()
true if the button is currently down;
false otherwise.public java.awt.Point waitMouse()
java.awt.Point.
java.awt.Point objectpublic int getButtonState()
NONE, or a combination of
the SHIFT, CONTROL and META
(for the Alt key) constant flags.
NONE,
SHIFT,
CONTROL,
METApublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListenerpublic char peekKey()
0 otherwisegetKey()public char getKey()
peekKey()public java.lang.String toString()
DrawingStuff.
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||