Module java.desktop
Package java.awt.image

## 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 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:
  `Image`, `MultiResolutionImage`

### Field Summary

### Fields inherited from class java.awt.Image

`accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty`

### Constructor Summary

Constructors
Constructor and Description
`AbstractMultiResolutionImage()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`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()` Creates a graphics context for drawing to an off-screen image.
`int` `getHeight(ImageObserver observer)` Determines the height of the image.
`Object` `getProperty(String name, ImageObserver observer)` Gets a property of this image by name.
`ImageProducer` `getSource()` Gets the object that produces the pixels for the image.
`int` `getWidth(ImageObserver observer)` Determines the width of the image.

### Methods inherited from class java.awt.Image

`flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority`

### Methods inherited from interface java.awt.image.MultiResolutionImage

`getResolutionVariant, getResolutionVariants`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractMultiResolutionImage

    public AbstractMultiResolutionImage()

### Method Detail

#### getWidth

    public int getWidth(ImageObserver observer)

Description copied from class: `Image`
Determines the width of the image. If the width is not yet known, this method returns `-1` and the specified `ImageObserver` object is notified later.

Specified by:
  `getWidth` in class `Image`
Parameters:
  `observer` - an object waiting for the image to be loaded.
Returns:
  the width of this image, or `-1` if the width is not yet known.
See Also:
  `Image.getHeight(java.awt.image.ImageObserver)`, `ImageObserver`

#### getHeight

    public int getHeight(ImageObserver observer)

Description copied from class: `Image`
Determines the height of the image. If the height is not yet known, this method returns `-1` and the specified `ImageObserver` object is notified later.

Specified by:
  `getHeight` in class `Image`
Parameters:
  `observer` - an object waiting for the image to be loaded.
Returns:
  the height of this image, or `-1` if the height is not yet known.
See Also:
  `Image.getWidth(java.awt.image.ImageObserver)`, `ImageObserver`

#### getSource

    public ImageProducer getSource()

Description copied from class: `Image`
Gets the object that produces the pixels for the image. This method is called by the image filtering classes and by methods that perform image conversion and scaling.

Specified by:
  `getSource` in class `Image`
Returns:
  the image producer that produces the pixels for this image.
See Also:
  `ImageProducer`

#### getGraphics

    public Graphics getGraphics()

Description copied from class: `Image`
Creates a graphics context for drawing to an off-screen image. This method can only be called for off-screen images.

Specified by:
  `getGraphics` in class `Image`
Returns:
  a graphics context to draw to the off-screen image.
See Also:
  `Graphics`, `Component.createImage(int, int)`

#### getProperty

    public Object getProperty(String name,
                              ImageObserver observer)

Description copied from class: `Image`
Gets a property of this image by name.

Individual property names are defined by the various image formats. If a property is not defined for a particular image, this method returns the `UndefinedProperty` object.

If the properties for this image are not yet known, this method returns `null`, and the `ImageObserver` object is notified later.

The property name `"comment"` should be used to store an optional comment which can be presented to the application as a description of the image, its source, or its author.

Specified by:
  `getProperty` in class `Image`
Parameters:
  `name` - a property name.
  `observer` - an object waiting for this image to be loaded.
Returns:
  the value of the named property.
See Also:
  `ImageObserver`, `Image.UndefinedProperty`

#### 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