1 24 25 package utobcast.draw; 26 27 import java.io.Serializable ; 28 29 32 public class DrawCommand implements Serializable 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 66 public String toString() 67 { 68 StringBuffer ret = new StringBuffer (); 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 |