home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 3.4 KB | 133 lines |
- /*
- * [ Title ] alpha 3
- * Y.Amemoto
- * Create 1995/12/03
- *
- */
-
- import java.io.InputStream;
- import java.lang.Integer;
- import awt.*;
- import browser.*;
- import net.www.html.*;
-
- public class Title extends Applet implements Runnable {
- String dir;
- Thread kicker = null;
- int pause, move, bgcolor;
- int width, height;
- Image im;
- Image img;
- Graphics offscreen;
- int y, x;
- int imwidth, imheight;
-
- public void init() {
- String at;
- dir = getAttribute("img");
- if (dir == null) dir = "images/title.gif";
- img = getImage(dir);
- imwidth = img.width;
- imheight = img.height;
-
- at = getAttribute("pause");
- if (at == null) pause = 100;
- else pause = Integer.valueOf(at).intValue();
-
- at = getAttribute("width");
- if (at == null) width = 450;
- else width = Integer.valueOf(at).intValue();
-
- at = getAttribute("height");
- if (at == null) height = 100;
- else height = Integer.valueOf(at).intValue();
- resize(width, height);
-
- at = getAttribute("move");
- if (at == null) {
- move = 5;
- }
- else {
- move = Integer.valueOf(at).intValue();
- if (move < 1 || move > 50) {
- move = 5;
- }
- }
-
- at = getAttribute("bgcolor");
- if (at == null) {
- bgcolor = 1;
- }
- else {
- bgcolor = Integer.valueOf(at).intValue();
- if (bgcolor < 0 || bgcolor > 12){
- bgcolor = 1;
- }
- }
-
- im = createImage(width, height);
- offscreen = new Graphics(im);
- switch (bgcolor) {
- case 0: offscreen.setForeground(Color.white);
- break;
- case 1: offscreen.setForeground(Color.lightGray);
- break;
- case 2: offscreen.setForeground(Color.gray);
- break;
- case 3: offscreen.setForeground(Color.darkGray);
- break;
- case 4: offscreen.setForeground(Color.black);
- break;
- case 5: offscreen.setForeground(Color.red);
- break;
- case 6: offscreen.setForeground(Color.pink);
- break;
- case 7: offscreen.setForeground(Color.orange);
- break;
- case 8: offscreen.setForeground(Color.yellow);
- break;
- case 9: offscreen.setForeground(Color.green);
- break;
- case 10: offscreen.setForeground(Color.magenta);
- break;
- case 11: offscreen.setForeground(Color.cyan);
- break;
- case 12: offscreen.setForeground(Color.blue);
- break;
- }
- }
-
- public void run() {
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
-
- while (kicker != null) {
- x = imwidth;
- while ( x > -imwidth){
- x -= move;
- repaint();
- Thread.sleep(pause);
- }
- }
- }
-
- public void paint(Graphics g) {
- update(g);
- }
- public void update(Graphics g) {
- offscreen.fillRect(0, 0, width, height);
- offscreen.drawImage(img, x, y);
- g.drawImage(im, 0, 0);
- }
-
- public void start() {
- if (kicker == null) {
- kicker = new Thread(this);
- kicker.start();
- }
- }
-
- public void stop() {
- kicker = null;
- }
- }
-