1 /*
   2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.awt.image;
  26 
  27 import java.awt.Image;
  28 import java.util.List;
  29 
  30 /**
  31  * This interface is designed to be an optional additional API supported by
  32  * some implementations of {@link java.awt.Image} to allow them to provide
  33  * alternate images for various rendering resolutions. The various
  34  * {@code Graphics.drawImage(...)} variant methods will consult the methods
  35  * of this interface if it is implemented on the argument {@code Image} object
  36  * in order to choose the best representation to use for each rendering operation.
  37  * <p>
  38  * The {@code MultiResolutionImage} interface should be implemented by any
  39  * subclass of {@code java.awt.Image} whose instances are intended to provide
  40  * image resolution variants according to the given image width and height.
  41  * For convenience, toolkit images obtained from
  42  * {@code Toolkit.getImage(String name)} and {@code Toolkit.getImage(URL url)}
  43  * will implement this interface on platforms that support naming conventions
  44  * for resolution variants of stored image media and the
  45  * {@code AbstractMultiResolutionImage} and {@code BaseMultiResolutionImage}
  46  * classes are provided to facilitate easy construction of custom multi-resolution
  47  * images from a list of related images.
  48  *
  49  * @see java.awt.Image
  50  * @see java.awt.image.AbstractMultiResolutionImage
  51  * @see java.awt.image.BaseMultiResolutionImage
  52  * @see java.awt.Toolkit#getImage(java.lang.String filename)
  53  * @see java.awt.Toolkit#getImage(java.net.URL url)
  54  *
  55  * @since 1.9
  56  */
  57 public interface MultiResolutionImage {
  58 
  59     /**
  60      * Gets a specific image that is the best variant to represent
  61      * this logical image at the indicated size.
  62      *
  63      * @param destImageWidth the width of the destination image, in pixels.
  64      * @param destImageHeight the height of the destination image, in pixels.
  65      * @return image resolution variant.
  66      * @throws IllegalArgumentException if {@code destImageWidth} or
  67      *         {@code destImageHeight} is less than or equal to zero, infinity,
  68      *         or NaN.
  69      *
  70      * @since 1.9
  71      */
  72     Image getResolutionVariant(double destImageWidth, double destImageHeight);
  73 
  74     /**
  75      * Gets a readable list of all resolution variants.
  76      * The list must be nonempty and contain at least one resolution variant.
  77      * <p>
  78      * Note that many implementations might return an unmodifiable list.
  79      * <p>
  80      * @return list of resolution variants.
  81      * @since 1.9
  82      */
  83     public List<Image> getResolutionVariants();
  84 }