OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [java/] [awt/] [image/] [ImageFilter.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* ImageFilter.java -- Java class for filtering images
2
   Copyright (C) 1999 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package java.awt.image;
40
 
41
import java.util.Hashtable;
42
 
43
/**
44
 * The <code>ImageFilter</code> class is a base class which can be
45
 * extended to provide different types of filters for an image.  By
46
 * default this class does nothing to an image passing through it.
47
 *
48
 * @author C. Brian Jones (cbj@gnu.org)
49
 */
50
public class ImageFilter implements ImageConsumer, Cloneable
51
{
52
    /**
53
     * The consumer this filter is filtering an image data stream for.
54
     * It is initialized in the method <code>getFilterInstance</code>.
55
     */
56
    protected ImageConsumer consumer = null;
57
 
58
    /**
59
     * The <code>ImageConsumer</code> can use this method to request
60
     * the pixels be delivered in top-down, left-right order.
61
     * <br>
62
     * The filter can respond in three different ways.
63
     * <ul>
64
     *   <li>The default behavior is to forward the request to the
65
     *       <code>ImageProducer</code>
66
     *       using the method <code>requestTopDownLeftRightResend</code>
67
     *       and using the filter as the consumer.</li>
68
     *   <li>The filter has the pixels and can retransmit them in the
69
     *       top-down, left-right order.</li>
70
     *   <li>The filter can do nothing when this method is called.</li>
71
     * </ul>
72
     */
73
    public void resendTopDownLeftRight(ImageProducer ip)
74
    {
75
        ip.requestTopDownLeftRightResend(this);
76
    }
77
 
78
    /**
79
     * By default, returns a shallow copy of the object created by
80
     * <code>Object.clone()</code>
81
     *
82
     * @see java.lang.Object#clone ()
83
     */
84
    public Object clone()
85
    {
86
      try
87
        {
88
          return super.clone();
89
        }
90
      catch (CloneNotSupportedException e)
91
        {
92
          // This should never happen as this class implements the
93
          // Cloneable interface.
94
          throw new InternalError ();
95
        }
96
    }
97
 
98
    /**
99
     * This is the only method which can set the
100
     * <code>ImageConsumer</code> for this filter.  By default a clone
101
     * of this filter with the appropriate consumer set is returned.
102
     *
103
     * @see #clone ()
104
     */
105
    public ImageFilter getFilterInstance(ImageConsumer ic)
106
    {
107
        if ( ic == null )
108
            throw new IllegalArgumentException("null argument for ImageFilter.getFilterInstance(ImageConsumer)");
109
 
110
        consumer = ic;
111
        ImageFilter f = (ImageFilter)clone();
112
        consumer = null;
113
        return f;
114
    }
115
 
116
    /**
117
     * An <code>ImageProducer</code> indicates the size of the image
118
     * being produced using this method.  A filter can override this
119
     * method to intercept these calls from the producer in order to
120
     * change either the width or the height before in turn calling
121
     * the consumer's <code>setDimensions</code> method.
122
     *
123
     * @param width the width of the image
124
     * @param height the height of the image
125
     */
126
    public void setDimensions(int width, int height)
127
    {
128
      if (consumer != null)
129
        consumer.setDimensions(width, height);
130
    }
131
 
132
    /**
133
     * An <code>ImageProducer</code> can set a list of properties
134
     * associated with this image by using this method.
135
     *
136
     * @param props the list of properties associated with this image
137
     */
138
    public void setProperties(Hashtable props)
139
    {
140
        props.put("filters", "ImageFilter");
141
        if (consumer != null)
142
          consumer.setProperties(props);
143
    }
144
 
145
    /**
146
     * Override this method to process calls to this method from the
147
     * <code>ImageProducer</code>.  By default the <code>setColorModel</code>
148
     * method of the consumer is called with the specified <code>model</code>.
149
     *
150
     * @param model the color model to be used most often by setPixels
151
     * @see ColorModel */
152
    public void setColorModel(ColorModel model)
153
    {
154
      if (consumer != null)
155
        consumer.setColorModel(model);
156
    }
157
 
158
    /**
159
     * The <code>ImageProducer</code> should call this method with a
160
     * bit mask of hints from any of <code>RANDOMPIXELORDER</code>,
161
     * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,
162
     * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the
163
     * <code>ImageConsumer</code> interface.
164
     *
165
     * @param flags a bit mask of hints
166
     * @see ImageConsumer
167
     */
168
    public void setHints(int flags)
169
    {
170
      if (consumer != null)
171
        consumer.setHints(flags);
172
    }
173
 
174
    /**
175
     * This function delivers a rectangle of pixels where any
176
     * pixel(m,n) is stored in the array as a <code>byte</code> at
177
     * index (n * scansize + m + offset).
178
     *
179
     * @param x the x coordinate of the rectangle
180
     * @param y the y coordinate of the rectangle
181
     * @param w the width of the rectangle
182
     * @param h the height of the rectangle
183
     * @param model the <code>ColorModel</code> used to translate the pixels
184
     * @param pixels the array of pixel values
185
     * @param offset the index of the first pixels in the <code>pixels</code> array
186
     * @param scansize the width to use in extracting pixels from the <code>pixels</code> array
187
     */
188
    public void setPixels(int x, int y, int w, int h,
189
           ColorModel model, byte[] pixels, int offset, int scansize)
190
    {
191
      if (consumer != null)
192
        consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
193
    }
194
 
195
    /**
196
     * This function delivers a rectangle of pixels where any
197
     * pixel(m,n) is stored in the array as an <code>int</code> at
198
     * index (n * scansize + m + offset).
199
     *
200
     * @param x the x coordinate of the rectangle
201
     * @param y the y coordinate of the rectangle
202
     * @param w the width of the rectangle
203
     * @param h the height of the rectangle
204
     * @param model the <code>ColorModel</code> used to translate the pixels
205
     * @param pixels the array of pixel values
206
     * @param offset the index of the first pixels in the <code>pixels</code> array
207
     * @param scansize the width to use in extracting pixels from the <code>pixels</code> array
208
     */
209
    public void setPixels(int x, int y, int w, int h,
210
           ColorModel model, int[] pixels, int offset, int scansize)
211
    {
212
      if (consumer != null)
213
        consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
214
    }
215
 
216
    /**
217
     * The <code>ImageProducer</code> calls this method to indicate a
218
     * single frame or the entire image is complete.  The method is
219
     * also used to indicate an error in loading or producing the
220
     * image.
221
     */
222
    public void imageComplete(int status)
223
    {
224
      if (consumer != null)
225
        consumer.imageComplete(status);
226
    }
227
}
228
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.