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 java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
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 java.awt.Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface java.awt.image.MultiResolutionImage
getResolutionVariant, getResolutionVariants
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
public ImageProducer getSource()
This method simply delegates to the same method on the base image and it is equivalent to:
getBaseImage().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:
-
getGraphics
in 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:
-
getProperty
in 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, 2021, 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.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/image/AbstractMultiResolutionImage.html