01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Igor V. Stolyarov
19: * @version $Revision$
20: */package java.awt.image;
21:
22: import java.util.Hashtable;
23:
24: public class ImageFilter implements ImageConsumer, Cloneable {
25:
26: protected ImageConsumer consumer;
27:
28: public ImageFilter() {
29: super ();
30: }
31:
32: public ImageFilter getFilterInstance(ImageConsumer ic) {
33: ImageFilter filter = (ImageFilter) clone();
34: filter.consumer = ic;
35: return filter;
36: }
37:
38: @SuppressWarnings("unchecked")
39: public void setProperties(Hashtable<?, ?> props) {
40: Hashtable<Object, Object> fprops;
41: if (props == null) {
42: fprops = new Hashtable<Object, Object>();
43: } else {
44: fprops = (Hashtable<Object, Object>) props.clone();
45: }
46: String propName = "Filters"; //$NON-NLS-1$
47: String prop = "Null filter"; //$NON-NLS-1$
48: Object o = fprops.get(propName);
49: if (o != null) {
50: if (o instanceof String) {
51: prop = (String) o + "; " + prop; //$NON-NLS-1$
52: } else {
53: prop = o.toString() + "; " + prop; //$NON-NLS-1$
54: }
55: }
56: fprops.put(propName, prop);
57: consumer.setProperties(fprops);
58: }
59:
60: @Override
61: public Object clone() {
62: try {
63: return super .clone();
64: } catch (CloneNotSupportedException e) {
65: return null;
66: }
67: }
68:
69: public void resendTopDownLeftRight(ImageProducer ip) {
70: ip.requestTopDownLeftRightResend(this );
71: }
72:
73: public void setColorModel(ColorModel model) {
74: consumer.setColorModel(model);
75: }
76:
77: public void setPixels(int x, int y, int w, int h, ColorModel model,
78: int[] pixels, int off, int scansize) {
79: consumer.setPixels(x, y, w, h, model, pixels, off, scansize);
80: }
81:
82: public void setPixels(int x, int y, int w, int h, ColorModel model,
83: byte[] pixels, int off, int scansize) {
84: consumer.setPixels(x, y, w, h, model, pixels, off, scansize);
85: }
86:
87: public void setDimensions(int width, int height) {
88: consumer.setDimensions(width, height);
89: }
90:
91: public void setHints(int hints) {
92: consumer.setHints(hints);
93: }
94:
95: public void imageComplete(int status) {
96: consumer.imageComplete(status);
97: }
98:
99: }
|