Class AbstractMultiResolutionImage
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 Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedPropertyModifier and TypeFieldDescriptionprotected floatPriority for accelerating this image.static final intUse the Area Averaging image scaling algorithm.static final intUse the default image-scaling algorithm.static final intChoose an image-scaling algorithm that gives higher priority to scaling speed than smoothness of the scaled image.static final intUse the image scaling algorithm embodied in theReplicateScaleFilterclass.static final intChoose an image-scaling algorithm that gives higher priority to image smoothness than scaling speed.static final ObjectTheUndefinedPropertyobject should be returned whenever a property which was not defined for a particular image is fetched. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for subclasses to call. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ImageReturn 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 throwUnsupportedOperationExceptionsince only off-screen images can return aGraphicsobject.intgetHeight(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().intgetWidth(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 Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriorityModifier and TypeMethodDescriptionvoidflush()Flushes all reconstructable resources being used by this Image object.floatReturns the current value of the acceleration priority hint.Returns an ImageCapabilities object which can be inquired as to the capabilities of this Image on the specified GraphicsConfiguration.getScaledInstance(int width, int height, int hints) Creates a scaled version of this image.voidsetAccelerationPriority(float priority) 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, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.Methods declared in interface MultiResolutionImage
getResolutionVariant, getResolutionVariantsModifier and TypeMethodDescriptiongetResolutionVariant(double destImageWidth, double destImageHeight) Gets a specific image that is the best variant to represent this logical image at the indicated size.Gets a readable list of all resolution variants.
-
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 throwUnsupportedOperationExceptionsince only off-screen images can return aGraphicsobject.- Specified by:
getGraphicsin 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:
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
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
-