1 | /* Image.java -- superclass for images
|
---|
2 | Copyright (C) 1999, 2002 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., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 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;
|
---|
40 |
|
---|
41 | import java.awt.image.AreaAveragingScaleFilter;
|
---|
42 | import java.awt.image.ImageObserver;
|
---|
43 | import java.awt.image.ImageProducer;
|
---|
44 | import java.awt.image.ReplicateScaleFilter;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * This is the abstract superclass of all image objects in Java.
|
---|
48 | *
|
---|
49 | * @author Aaron M. Renn <arenn@urbanophile.com>
|
---|
50 | * @since 1.0
|
---|
51 | * @status updated to 1.4
|
---|
52 | */
|
---|
53 | public abstract class Image
|
---|
54 | {
|
---|
55 | /**
|
---|
56 | * This variable is returned whenever a property that is not defined
|
---|
57 | * is requested.
|
---|
58 | */
|
---|
59 | // For debug purposes, this might as well be a unique string.
|
---|
60 | public static final Object UndefinedProperty
|
---|
61 | = new String("undefined property");
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Constant indicating that the default scaling algorithm should be used.
|
---|
65 | *
|
---|
66 | * @since 1.1
|
---|
67 | */
|
---|
68 | public static final int SCALE_DEFAULT = 1;
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Constant indicating that a fast scaling algorithm should be used.
|
---|
72 | *
|
---|
73 | * @since 1.1
|
---|
74 | */
|
---|
75 | public static final int SCALE_FAST = 2;
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Constant indicating that a smooth scaling algorithm should be used.
|
---|
79 | *
|
---|
80 | * @since 1.1
|
---|
81 | */
|
---|
82 | public static final int SCALE_SMOOTH = 4;
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Constant indicating that the <code>ReplicateScaleFilter</code> class
|
---|
86 | * algorithm should be used for scaling.
|
---|
87 | *
|
---|
88 | * @see ReplicateScaleFilter
|
---|
89 | * @since 1.1
|
---|
90 | */
|
---|
91 | public static final int SCALE_REPLICATE = 8;
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Constant indicating that the area averaging scaling algorithm should be
|
---|
95 | * used.
|
---|
96 | *
|
---|
97 | * @see AreaAveragingScaleFilter
|
---|
98 | * @since 1.1
|
---|
99 | */
|
---|
100 | public static final int SCALE_AREA_AVERAGING = 16;
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * A default constructor for subclasses.
|
---|
104 | */
|
---|
105 | public Image()
|
---|
106 | {
|
---|
107 | }
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Returns the width of the image, or -1 if it is unknown. If the
|
---|
111 | * image width is unknown, the observer object will be notified when
|
---|
112 | * the value is known.
|
---|
113 | *
|
---|
114 | * @param observer the image observer for this object
|
---|
115 | * @return the width in pixels
|
---|
116 | * @see #getHeight(ImageObserver)
|
---|
117 | */
|
---|
118 | public abstract int getWidth(ImageObserver observer);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Returns the height of the image, or -1 if it is unknown. If the
|
---|
122 | * image height is unknown, the observer object will be notified when
|
---|
123 | * the value is known.
|
---|
124 | *
|
---|
125 | * @param observer the image observer for this object
|
---|
126 | * @return the height in pixels
|
---|
127 | * @see #getWidth(ImageObserver)
|
---|
128 | */
|
---|
129 | public abstract int getHeight(ImageObserver observer);
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * Returns the image producer object for this object. The producer is the
|
---|
133 | * object which generates pixels for this image.
|
---|
134 | *
|
---|
135 | * @return the image producer for this object
|
---|
136 | */
|
---|
137 | public abstract ImageProducer getSource();
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Returns a graphics context object for drawing an off-screen object.
|
---|
141 | * This method is only valid for off-screen objects.
|
---|
142 | *
|
---|
143 | * @return a graphics context object for an off-screen object
|
---|
144 | * @see Graphics#createImage(int, int)
|
---|
145 | */
|
---|
146 | public abstract Graphics getGraphics();
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * This method requests a named property for an object. The value of the
|
---|
150 | * property is returned. The value <code>UndefinedProperty</code> is
|
---|
151 | * returned if there is no property with the specified name. The value
|
---|
152 | * <code>null</code> is returned if the properties for the object are
|
---|
153 | * not yet known. In this case, the specified image observer is notified
|
---|
154 | * when the properties are known.
|
---|
155 | *
|
---|
156 | * @param name the requested property name
|
---|
157 | * @param observer the image observer for this object
|
---|
158 | * @return the named property, if available
|
---|
159 | * @see #UndefinedProperty
|
---|
160 | */
|
---|
161 | public abstract Object getProperty(String name, ImageObserver observer);
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Scales the image to the requested dimension. A new Image with asynchronous
|
---|
165 | * loading will be produced according to the hints of the algorithm
|
---|
166 | * requested. If either the width or height is non-positive, it is adjusted
|
---|
167 | * to preserve the original aspect ratio.
|
---|
168 | *
|
---|
169 | * @param width the width of the scaled image
|
---|
170 | * @param height the height of the scaled image
|
---|
171 | * @param flags a value indicating the algorithm to use
|
---|
172 | * @return the scaled <code>Image</code> object
|
---|
173 | * @see #SCALE_DEFAULT
|
---|
174 | * @see #SCALE_FAST
|
---|
175 | * @see #SCALE_SMOOTH
|
---|
176 | * @see #SCALE_REPLICATE
|
---|
177 | * @see #SCALE_AREA_AVERAGING
|
---|
178 | * @since 1.1
|
---|
179 | */
|
---|
180 | public Image getScaledInstance(int width, int height, int flags)
|
---|
181 | {
|
---|
182 | throw new Error("not implemented");
|
---|
183 | }
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Flushes (that is, destroys) any resources used for this image. This
|
---|
187 | * includes the actual image data.
|
---|
188 | */
|
---|
189 | public abstract void flush();
|
---|
190 | } // class Image
|
---|