33 import sun.awt.image.IntegerComponentRaster;
34 import java.util.Arrays;
35
36 class ColorPaintContext implements PaintContext {
37 int color;
38 WritableRaster savedTile;
39
40 protected ColorPaintContext(int color, ColorModel cm) {
41 this.color = color;
42 }
43
44 public void dispose() {
45 }
46
47 /*
48 * Returns the RGB value representing the color in the default sRGB
49 * {@link ColorModel}.
50 * (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are
51 * blue).
52 * @return the RGB value of the color in the default sRGB
53 * <code>ColorModel</code>.
54 * @see java.awt.image.ColorModel#getRGBdefault
55 * @see #getRed
56 * @see #getGreen
57 * @see #getBlue
58 */
59 int getRGB() {
60 return color;
61 }
62
63 public ColorModel getColorModel() {
64 return ColorModel.getRGBdefault();
65 }
66
67 public synchronized Raster getRaster(int x, int y, int w, int h) {
68 WritableRaster t = savedTile;
69
70 if (t == null || w > t.getWidth() || h > t.getHeight()) {
71 t = getColorModel().createCompatibleWritableRaster(w, h);
72 IntegerComponentRaster icr = (IntegerComponentRaster) t;
73 Arrays.fill(icr.getDataStorage(), color);
|
33 import sun.awt.image.IntegerComponentRaster;
34 import java.util.Arrays;
35
36 class ColorPaintContext implements PaintContext {
37 int color;
38 WritableRaster savedTile;
39
40 protected ColorPaintContext(int color, ColorModel cm) {
41 this.color = color;
42 }
43
44 public void dispose() {
45 }
46
47 /*
48 * Returns the RGB value representing the color in the default sRGB
49 * {@link ColorModel}.
50 * (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are
51 * blue).
52 * @return the RGB value of the color in the default sRGB
53 * {@code ColorModel}.
54 * @see java.awt.image.ColorModel#getRGBdefault
55 * @see #getRed
56 * @see #getGreen
57 * @see #getBlue
58 */
59 int getRGB() {
60 return color;
61 }
62
63 public ColorModel getColorModel() {
64 return ColorModel.getRGBdefault();
65 }
66
67 public synchronized Raster getRaster(int x, int y, int w, int h) {
68 WritableRaster t = savedTile;
69
70 if (t == null || w > t.getWidth() || h > t.getHeight()) {
71 t = getColorModel().createCompatibleWritableRaster(w, h);
72 IntegerComponentRaster icr = (IntegerComponentRaster) t;
73 Arrays.fill(icr.getDataStorage(), color);
|