< prev index next >

src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java

Print this page




  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 sun.awt.image;
  26 
  27 import java.awt.Image;
  28 import java.awt.image.ImageObserver;
  29 import java.awt.image.MultiResolutionImage;
  30 import java.util.Arrays;
  31 import java.util.List;
  32 import sun.misc.SoftCache;
  33 
  34 public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage {
  35 
  36     Image resolutionVariant;
  37 
  38     public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
  39         super(lowResolutionImage.getSource());
  40         this.resolutionVariant = resolutionVariant;
  41     }
  42 
  43     @Override
  44     public Image getResolutionVariant(double destWidth, double destHeight) {
  45         checkSize(destWidth, destHeight);
  46         return ((destWidth <= getWidth() && destHeight <= getHeight()))
  47                 ? this : resolutionVariant;
  48     }
  49 
  50     private static void checkSize(double width, double height) {
  51         if (width <= 0 || height <= 0) {
  52             throw new IllegalArgumentException(String.format(




  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 sun.awt.image;
  26 
  27 import java.awt.Image;
  28 import java.awt.image.ImageObserver;
  29 import java.awt.image.MultiResolutionImage;
  30 import java.util.Arrays;
  31 import java.util.List;
  32 import sun.awt.SoftCache;
  33 
  34 public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage {
  35 
  36     Image resolutionVariant;
  37 
  38     public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
  39         super(lowResolutionImage.getSource());
  40         this.resolutionVariant = resolutionVariant;
  41     }
  42 
  43     @Override
  44     public Image getResolutionVariant(double destWidth, double destHeight) {
  45         checkSize(destWidth, destHeight);
  46         return ((destWidth <= getWidth() && destHeight <= getHeight()))
  47                 ? this : resolutionVariant;
  48     }
  49 
  50     private static void checkSize(double width, double height) {
  51         if (width <= 0 || height <= 0) {
  52             throw new IllegalArgumentException(String.format(


< prev index next >