Module java.desktop

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