< prev index next >

src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java

Print this page


   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


  47  *         // return a resolution variant based on the given destination image size
  48  *     }
  49  *
  50  *     public List<Image> getResolutionVariants() {
  51  *         return Collections.unmodifiableList(Arrays.asList(resolutionVariants));
  52  *     }
  53  *
  54  *     protected Image getBaseImage() {
  55  *         return resolutionVariants[0];
  56  *     }
  57  * }
  58  * } </pre>
  59  *
  60  * @see java.awt.Image
  61  * @see java.awt.image.MultiResolutionImage
  62  *
  63  * @since 9
  64  */
  65 public abstract class AbstractMultiResolutionImage extends java.awt.Image
  66         implements MultiResolutionImage {





  67 
  68     /**
  69      * This method simply delegates to the same method on the base image and
  70      * it is equivalent to: {@code getBaseImage().getWidth(observer)}.
  71      *
  72      * @return the width of the base image, or -1 if the width is not yet known
  73      * @see #getBaseImage()
  74      *
  75      * @since 9
  76      */
  77     @Override
  78     public int getWidth(ImageObserver observer) {
  79         return getBaseImage().getWidth(observer);
  80     }
  81 
  82     /**
  83      * This method simply delegates to the same method on the base image and
  84      * it is equivalent to: {@code getBaseImage().getHeight(observer)}.
  85      *
  86      * @return the height of the base image, or -1 if the height is not yet known


   1 /*
   2  * Copyright (c) 2015, 2020, 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


  47  *         // return a resolution variant based on the given destination image size
  48  *     }
  49  *
  50  *     public List<Image> getResolutionVariants() {
  51  *         return Collections.unmodifiableList(Arrays.asList(resolutionVariants));
  52  *     }
  53  *
  54  *     protected Image getBaseImage() {
  55  *         return resolutionVariants[0];
  56  *     }
  57  * }
  58  * } </pre>
  59  *
  60  * @see java.awt.Image
  61  * @see java.awt.image.MultiResolutionImage
  62  *
  63  * @since 9
  64  */
  65 public abstract class AbstractMultiResolutionImage extends java.awt.Image
  66         implements MultiResolutionImage {
  67 
  68     /**
  69      * Creates an {@code AbstractMultiResolutionImage}.
  70      */
  71     protected AbstractMultiResolutionImage() {}
  72 
  73     /**
  74      * This method simply delegates to the same method on the base image and
  75      * it is equivalent to: {@code getBaseImage().getWidth(observer)}.
  76      *
  77      * @return the width of the base image, or -1 if the width is not yet known
  78      * @see #getBaseImage()
  79      *
  80      * @since 9
  81      */
  82     @Override
  83     public int getWidth(ImageObserver observer) {
  84         return getBaseImage().getWidth(observer);
  85     }
  86 
  87     /**
  88      * This method simply delegates to the same method on the base image and
  89      * it is equivalent to: {@code getBaseImage().getHeight(observer)}.
  90      *
  91      * @return the height of the base image, or -1 if the height is not yet known


< prev index next >