KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > demos > DrawCommand


1 // $Id: DrawCommand.java,v 1.3 2004/09/23 16:29:35 belaban Exp $
2

3 package org.jgroups.demos;
4
5 import java.io.Serializable JavaDoc;
6
7
8 public class DrawCommand implements Serializable JavaDoc {
9     static final int DRAW=1;
10     static final int CLEAR=2;
11     final int mode;
12     int x=0;
13     int y=0;
14     int r=0;
15     int g=0;
16     int b=0;
17
18     
19     DrawCommand(int mode) {
20     this.mode=mode;
21     }
22     
23     DrawCommand(int mode, int x, int y, int r, int g, int b) {
24     this.mode=mode;
25     this.x=x;
26     this.y=y;
27     this.r=r;
28     this.g=g;
29     this.b=b;
30     }
31
32
33     DrawCommand Copy() {
34     return new DrawCommand(mode, x, y, r, g, b);
35     }
36     
37     
38     public String JavaDoc toString() {
39     StringBuffer JavaDoc ret=new StringBuffer JavaDoc();
40     switch(mode) {
41     case DRAW: ret.append("DRAW(" + x + ", " + y + ") [" + r + '|' + g + '|' + b + ']');
42         break;
43     case CLEAR: ret.append("CLEAR");
44         break;
45     default:
46         return "<undefined>";
47     }
48     return ret.toString();
49     }
50     
51 }
52
Popular Tags