Class AbstractMultiResolutionImage
java.lang.Object
java.awt.Image
java.awt.image.AbstractMultiResolutionImage
- All Implemented Interfaces:
MultiResolutionImage
- Direct Known Subclasses:
BaseMultiResolutionImage
public abstract class AbstractMultiResolutionImage extends Image implements MultiResolutionImage
This class provides default implementations of several
Image methods for classes that want to implement the MultiResolutionImage interface. For example, public class CustomMultiResolutionImage extends AbstractMultiResolutionImage {
final Image[] resolutionVariants;
public CustomMultiResolutionImage(Image... resolutionVariants) {
this.resolutionVariants = resolutionVariants;
}
public Image getResolutionVariant(
double destImageWidth, double destImageHeight) {
// return a resolution variant based on the given destination image size
}
public List<Image> getResolutionVariants() {
return Collections.unmodifiableList(Arrays.asList(resolutionVariants));
}
protected Image getBaseImage() {
return resolutionVariants[0];
}
}
- Since:
- 9
- See Also:
Field Summary
Fields declared in class Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty | Modifier and Type | Field | Description |
|---|---|---|
protected float |
accelerationPriority |
Priority for accelerating this image. |
static final int |
SCALE_AREA_AVERAGING |
Use the Area Averaging image scaling algorithm. |
static final int |
SCALE_DEFAULT |
Use the default image-scaling algorithm. |
static final int |
SCALE_FAST |
Choose an image-scaling algorithm that gives higher priority to scaling speed than smoothness of the scaled image. |
static final int |
SCALE_REPLICATE |
Use the image scaling algorithm embodied in the ReplicateScaleFilter class. |
static final int |
SCALE_SMOOTH |
Choose an image-scaling algorithm that gives higher priority to image smoothness than scaling speed. |
static final Object |
UndefinedProperty |
The UndefinedProperty object should be returned whenever a property which was not defined for a particular image is fetched. |
Constructor Summary
| Modifier | Constructor | Description |
|---|---|---|
protected |
Constructor for subclasses to call. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
protected abstract Image |
getBaseImage() |
Return the base image representing the best version of the image for rendering at the default width and height. |
Graphics |
getGraphics() |
As per the contract of the base Image#getGraphics() method, this implementation will always throw UnsupportedOperationException since only off-screen images can return a Graphics object. |
int |
getHeight |
This method simply delegates to the same method on the base image and it is equivalent to: getBaseImage().getHeight(observer). |
Object |
getProperty |
This method simply delegates to the same method on the base image and it is equivalent to: getBaseImage().getProperty(name, observer). |
ImageProducer |
getSource() |
This method simply delegates to the same method on the base image and it is equivalent to: getBaseImage().getSource(). |
int |
getWidth |
This method simply delegates to the same method on the base image and it is equivalent to: getBaseImage().getWidth(observer). |
Methods declared in class Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority | Modifier and Type | Method | Description |
|---|---|---|
void |
flush() |
Flushes all reconstructable resources being used by this Image object. |
float |
getAccelerationPriority() |
Returns the current value of the acceleration priority hint. |
ImageCapabilities |
getCapabilities |
Returns an ImageCapabilities object which can be inquired as to the capabilities of this Image on the specified GraphicsConfiguration. |
Image |
getScaledInstance |
Creates a scaled version of this image. |
void |
setAccelerationPriority |
Sets a hint for this image about how important acceleration is. |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Methods declared in interface MultiResolutionImage
getResolutionVariant, getResolutionVariants | Modifier and Type | Method | Description |
|---|---|---|
Image |
getResolutionVariant |
Gets a specific image that is the best variant to represent this logical image at the indicated size. |
List |
getResolutionVariants() |
Gets a readable list of all resolution variants. |
Constructor Details
AbstractMultiResolutionImage
protected AbstractMultiResolutionImage()
Constructor for subclasses to call.
Method Details
getWidth
public int getWidth(ImageObserver observer)
This method simply delegates to the same method on the base image and it is equivalent to:
getBaseImage().getWidth(observer).getHeight
public int getHeight(ImageObserver observer)
This method simply delegates to the same method on the base image and it is equivalent to:
getBaseImage().getHeight(observer).getSource
getGraphics
public Graphics getGraphics()
As per the contract of the base
Image#getGraphics() method, this implementation will always throw UnsupportedOperationException since only off-screen images can return a Graphics object.- Specified by:
-
getGraphicsin classImage - Returns:
- throws
UnsupportedOperationException - Throws:
-
UnsupportedOperationException- this method is not supported - See Also:
getProperty
public Object getProperty(String name, ImageObserver observer)
This method simply delegates to the same method on the base image and it is equivalent to:
getBaseImage().getProperty(name, observer).- Specified by:
-
getPropertyin classImage - Parameters:
-
name- a property name. -
observer- an object waiting for this image to be loaded. - Returns:
- the value of the named property in the base image
- Since:
- 9
- See Also:
getBaseImage
protected abstract Image getBaseImage()
Return the base image representing the best version of the image for rendering at the default width and height.
- Returns:
- the base image of the set of multi-resolution images
- Since:
- 9
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.