java.lang.Object
java.awt.Image
java.awt.image.AbstractMultiResolutionImage
- All Implemented Interfaces:
MultiResolutionImage
- Direct Known Subclasses:
BaseMultiResolutionImage
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
ModifierConstructorDescriptionprotected
Constructor for subclasses to call. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Image
Return the base image representing the best version of the image for rendering at the default width and height.As per the contract of the baseImage#getGraphics()
method, this implementation will always throwUnsupportedOperationException
since only off-screen images can return aGraphics
object.int
getHeight
(ImageObserver observer) This method simply delegates to the same method on the base image and it is equivalent to:getBaseImage().getHeight(observer)
.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)
.This method simply delegates to the same method on the base image and it is equivalent to:getBaseImage().getSource()
.int
getWidth
(ImageObserver observer) 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
This method simply delegates to the same method on the base image and it is equivalent to:getBaseImage().getWidth(observer)
. -
getHeight
This method simply delegates to the same method on the base image and it is equivalent to:getBaseImage().getHeight(observer)
. -
getSource
This method simply delegates to the same method on the base image and it is equivalent to:getBaseImage().getSource()
. -
getGraphics
As per the contract of the baseImage#getGraphics()
method, this implementation will always throwUnsupportedOperationException
since only off-screen images can return aGraphics
object.- Specified by:
getGraphics
in classImage
- Returns:
- throws
UnsupportedOperationException
- Throws:
UnsupportedOperationException
- this method is not supported- See Also:
-
getProperty
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
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
-