|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Canvas
de.nidanet.dev.fun.winter.snow.Snow
public class Snow
An object of this class represents the screen for the falling flakes.
It runs as an single thread, too and produces every 5ms a new flake at a random
x-position.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Canvas |
|---|
Canvas.AccessibleAWTCanvas |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private boolean |
active
While the object is active, new flakes will occure. |
private ThreadGroup |
AllFlakes
A group for all flakes is needed for calling common thread methods. |
private boolean[][] |
FixPoints
An array for all fixed points at this screen. |
private long |
FlakeCounter
A global flake's counter to create unique IDs. |
private Vector<Flake> |
Flakes
The storage of all active flakes. |
private Color |
FontColor
The color of the text. |
private String[] |
Messages
The 3 lines of message that will be displayed. |
private Image |
Screen
The screen all flakes are painting at. |
static long |
serialVersionUID
Unique Id of this class. |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
Snow(String msg1,
String msg2,
String msg3,
Color c)
Creates the new screen and initializes the text and color. |
|
| Method Summary | |
|---|---|
boolean[][] |
getFixPoints()
Reads reads the local array of all fixed points. |
private void |
initFixPoints()
Initializes FixPoints by running through a raster of the
complete screen and storing all point that are not of RGB( 0, 0, 0 ). |
void |
paint(Graphics g)
Since the screen inherits from Canvas it has to know
how to paint itself. |
void |
removeFlake(Flake f)
When a flake reached a fixed point, it notifies this screen about this. |
void |
run()
While the screen is active it created new flakes every
5ms at a random x-position. |
void |
stop()
It stops the screen by setting active to false and interrupts
all flakes. |
| Methods inherited from class java.awt.Canvas |
|---|
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long serialVersionUID
private boolean active
private Vector<Flake> Flakes
private ThreadGroup AllFlakes
private long FlakeCounter
private boolean[][] FixPoints
private Image Screen
private String[] Messages
private Color FontColor
text.
| Constructor Detail |
|---|
public Snow(String msg1,
String msg2,
String msg3,
Color c)
active is false right now.
msg1 - the 1st line of the textmsg2 - the 2nd line of the textmsg3 - the 3rd line of the textc - the Messages color| Method Detail |
|---|
public void run()
active it created new flakes every
5ms at a random x-position.
run in interface Runnablepublic void stop()
active to false and interrupts
all flakes.
public void paint(Graphics g)
Canvas it has to know
how to paint itself. Here the text is written and the FixPoints
are initialized.
paint in class Canvasg - the graphics objectpublic void removeFlake(Flake f)
AllFlakes, and the new fixed point
is stored locally and is given to every falling flake
calling method Flake.addFixPoint(int, int).
f - the flake to removeFlake.addFixPoint(int, int)public boolean[][] getFixPoints()
FixPointsprivate void initFixPoints()
FixPoints by running through a raster of the
complete screen and storing all point that are not of RGB( 0, 0, 0 ).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||