01: package demo.notification.whiteboard;
02:
03: import java.awt.Color;
04:
05: import org.apache.log.Logger;
06:
07: import org.apache.log.Hierarchy;
08:
09: /**
10:
11: * @author Alphonse Bendt
12:
13: * @version $Id: BrushSizePixelImage.java,v 1.2 2003/08/01 15:28:25 alphonse.bendt Exp $
14:
15: */
16:
17: public class BrushSizePixelImage extends PixelImage {
18:
19: Logger logger_ = Hierarchy.getDefaultHierarchy().getLoggerFor(
20: "PixelImage");
21:
22: int brushSize = 1;
23:
24: boolean brush = true;
25:
26: int width, height;
27:
28: public void setBrushSize(int x) {
29:
30: brushSize = x;
31:
32: }
33:
34: public int getBrushSize() {
35:
36: return brushSize;
37:
38: }
39:
40: public BrushSizePixelImage(int width, int height) {
41:
42: super (width, height);
43:
44: logger_.debug("init");
45:
46: this .width = width;
47:
48: this .height = height;
49:
50: }
51:
52: public void setArea(int x, int y, int r, int g, int b) {
53:
54: for (int xi = x - brushSize; xi <= x + brushSize; xi++)
55:
56: for (int yi = y - brushSize; yi <= y + brushSize; yi++) {
57:
58: if (xi >= 0 && yi >= 0 && xi < width && yi < height)
59:
60: super .setPixel(xi, yi, r, g, b);
61:
62: }
63:
64: }
65:
66: public void setPixel(int x, int y, int red, int green, int blue) {
67:
68: Color color = new Color(red, green, blue);
69:
70: if (brush) {
71:
72: setArea(x, y, red, green, blue);
73:
74: } else {
75:
76: super .setPixel(x, y, red, green, blue);
77:
78: }
79:
80: }
81:
82: public void clearAll() {
83:
84: for (int x = 0; x < width; x++) {
85:
86: for (int y = 0; y < height; y++) {
87:
88: super .setPixel(x, y, 0, 0, 0);
89:
90: }
91:
92: }
93:
94: }
95:
96: } // BPixelImage
|