Class BaseMultiResolutionImage
java.lang.Object
java.awt.Image
java.awt.image.AbstractMultiResolutionImage
java.awt.image.BaseMultiResolutionImage
- All Implemented Interfaces:
MultiResolutionImage
This class is an array-based implementation of
the
AbstractMultiResolutionImage class.
This class will implement the
getResolutionVariant(double destImageWidth, double destImageHeight)
method using a simple algorithm which will return the first image variant
in the array that is large enough to satisfy the rendering request. The
last image in the array will be returned if no suitable image is found
that is as large as the rendering request.
For best effect the array of images should be sorted with each image being both wider and taller than the previous image. The base image need not be the first image in the array. No exception will be thrown if the images are not sorted as suggested.
- 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
ConstructorsConstructorDescriptionBaseMultiResolutionImage(int baseImageIndex, Image... resolutionVariants) Creates a multi-resolution image with the given base image index and resolution variants.BaseMultiResolutionImage(Image... resolutionVariants) Creates a multi-resolution image with the given resolution variants. -
Method Summary
Modifier and TypeMethodDescriptionprotected ImageReturn the base image representing the best version of the image for rendering at the default width and height.getResolutionVariant(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.Methods declared in class AbstractMultiResolutionImage
getGraphics, getHeight, getProperty, getSource, getWidthModifier and TypeMethodDescriptionAs 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()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()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 thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) 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 voidwait(long timeoutMillis, int nanos) 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.
-
Constructor Details
-
BaseMultiResolutionImage
Creates a multi-resolution image with the given resolution variants. The first resolution variant is used as the base image.- Parameters:
resolutionVariants- array of resolution variants sorted by image size- Throws:
IllegalArgumentException- if null or zero-length array is passedNullPointerException- if the specifiedresolutionVariantscontains one or more null elements- Since:
- 9
-
BaseMultiResolutionImage
Creates a multi-resolution image with the given base image index and resolution variants.- Parameters:
baseImageIndex- the index of base image in the resolution variants arrayresolutionVariants- array of resolution variants sorted by image size- Throws:
IllegalArgumentException- if null or zero-length array is passedNullPointerException- if the specifiedresolutionVariantscontains one or more null elementsIndexOutOfBoundsException- ifbaseImageIndexis negative or greater than or equal toresolutionVariantslength.- Since:
- 9
-
-
Method Details
-
getResolutionVariant
Description copied from interface:MultiResolutionImageGets a specific image that is the best variant to represent this logical image at the indicated size.- Parameters:
destImageWidth- the width of the destination image, in pixels.destImageHeight- the height of the destination image, in pixels.- Returns:
- image resolution variant.
-
getResolutionVariants
Description copied from interface:MultiResolutionImageGets a readable list of all resolution variants. The list must be nonempty and contain at least one resolution variant.Note that many implementations might return an unmodifiable list.
- Returns:
- list of resolution variants.
-
getBaseImage
Description copied from class:AbstractMultiResolutionImageReturn the base image representing the best version of the image for rendering at the default width and height.- Specified by:
getBaseImagein classAbstractMultiResolutionImage- Returns:
- the base image of the set of multi-resolution images
-