KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > utobcast > draw > DrawCommand


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package utobcast.draw;
26
27 import java.io.Serializable JavaDoc;
28
29 /**
30  * This class represents a Draw command.
31  */

32 public class DrawCommand implements Serializable JavaDoc
33 {
34   static final int DRAW = 1;
35   static final int CLEAR = 2;
36   int mode;
37   int x = 0;
38   int y = 0;
39   int r = 0;
40   int g = 0;
41   int b = 0;
42
43   DrawCommand(int mode)
44   {
45     this.mode = mode;
46   }
47
48   DrawCommand(int mode, int x, int y, int r, int g, int b)
49   {
50     this.mode = mode;
51     this.x = x;
52     this.y = y;
53     this.r = r;
54     this.g = g;
55     this.b = b;
56   }
57
58   DrawCommand copy()
59   {
60     return new DrawCommand(mode, x, y, r, g, b);
61   }
62
63   /**
64    * @see java.lang.Object#toString()
65    */

66   public String JavaDoc toString()
67   {
68     StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
69     switch (mode)
70     {
71       case DRAW :
72         ret
73             .append("DRAW(" + x + ", " + y + ") [" + r + "|" + g + "|" + b
74                 + "]");
75         break;
76       case CLEAR :
77         ret.append("CLEAR");
78         break;
79       default :
80         return "<undefined>";
81     }
82     return ret.toString();
83   }
84
85 }
Popular Tags