1 24 25 package org.objectweb.tribe.demos.draw; 26 27 import java.io.Serializable ; 28 29 39 public class WhiteBoardCommand implements Serializable 40 { 41 static final int DRAW = 1; 42 static final int CLEAR = 2; 43 int mode; 44 int x = 0; 45 int y = 0; 46 int r = 0; 47 int g = 0; 48 int b = 0; 49 50 54 WhiteBoardCommand() 55 { 56 this.mode = CLEAR; 57 } 58 59 68 WhiteBoardCommand(int x, int y, int r, int g, int b) 69 { 70 this.mode = DRAW; 71 this.x = x; 72 this.y = y; 73 this.r = r; 74 this.g = g; 75 this.b = b; 76 } 77 78 83 WhiteBoardCommand Copy() 84 { 85 if (mode == CLEAR) 86 return new WhiteBoardCommand(); 87 else 88 return new WhiteBoardCommand(x, y, r, g, b); 89 } 90 91 94 public String toString() 95 { 96 StringBuffer ret = new StringBuffer (); 97 switch (mode) 98 { 99 case DRAW : 100 ret 101 .append("DRAW(" + x + ", " + y + ") [" + r + "|" + g + "|" + b 102 + "]"); 103 break; 104 case CLEAR : 105 ret.append("CLEAR"); 106 break; 107 default : 108 return "<undefined>"; 109 } 110 return ret.toString(); 111 } 112 113 } | Popular Tags |