Class BaseMultiResolutionImage

All Implemented Interfaces:
MultiResolutionImage

public class BaseMultiResolutionImage extends AbstractMultiResolutionImage
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, UndefinedProperty
    Modifier and Type
    Field
    Description
    protected float
    Priority for accelerating this image.
    static final int
    Use the Area Averaging image scaling algorithm.
    static final int
    Use the default image-scaling algorithm.
    static final int
    Choose an image-scaling algorithm that gives higher priority to scaling speed than smoothness of the scaled image.
    static final int
    Use the image scaling algorithm embodied in the ReplicateScaleFilter class.
    static final int
    Choose an image-scaling algorithm that gives higher priority to image smoothness than scaling speed.
    static final Object
    The UndefinedProperty object should be returned whenever a property which was not defined for a particular image is fetched.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseMultiResolutionImage(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 Type
    Method
    Description
    protected Image
    Return 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, getWidth
    Modifier and Type
    Method
    Description
    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
    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
    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
    Flushes all reconstructable resources being used by this Image object.
    float
    Returns 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.
    void
    setAccelerationPriority(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, wait
    Modifier and Type
    Method
    Description
    protected Object
    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.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    Answers a string containing a concise, human-readable description of the receiver.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(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 by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(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 by notify or notifyAll) or the expiration of the timeout.
  • Constructor Details

    • BaseMultiResolutionImage

      public BaseMultiResolutionImage(Image... resolutionVariants)
      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 passed
      NullPointerException - if the specified resolutionVariants contains one or more null elements
      Since:
      9
    • BaseMultiResolutionImage

      public BaseMultiResolutionImage(int baseImageIndex, Image... resolutionVariants)
      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 array
      resolutionVariants - array of resolution variants sorted by image size
      Throws:
      IllegalArgumentException - if null or zero-length array is passed
      NullPointerException - if the specified resolutionVariants contains one or more null elements
      IndexOutOfBoundsException - if baseImageIndex is negative or greater than or equal to resolutionVariants length.
      Since:
      9
  • Method Details

    • getResolutionVariant

      public Image getResolutionVariant(double destImageWidth, double destImageHeight)
      Description copied from interface: MultiResolutionImage
      Gets 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

      public List<Image> getResolutionVariants()
      Description copied from interface: MultiResolutionImage
      Gets 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

      protected Image getBaseImage()
      Description copied from class: AbstractMultiResolutionImage
      Return the base image representing the best version of the image for rendering at the default width and height.
      Specified by:
      getBaseImage in class AbstractMultiResolutionImage
      Returns:
      the base image of the set of multi-resolution images