< prev index next >

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

Print this page




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









  67     @Override
  68     public int getWidth(ImageObserver observer) {
  69         return getBaseImage().getWidth(observer);
  70     }
  71 









  72     @Override
  73     public int getHeight(ImageObserver observer) {
  74         return getBaseImage().getHeight(observer);
  75     }
  76 









  77     @Override
  78     public ImageProducer getSource() {
  79         return getBaseImage().getSource();
  80     }
  81 








  82     @Override
  83     public Graphics getGraphics() {
  84         throw new UnsupportedOperationException("getGraphics() not supported"
  85                 + " on Multi-Resolution Images");
  86     }
  87 









  88     @Override
  89     public Object getProperty(String name, ImageObserver observer) {
  90         return getBaseImage().getProperty(name, observer);
  91     }
  92 
  93     /**
  94      * Return the base image representing the best version of the image for
  95      * rendering at the default width and height.
  96      *
  97      * @return the base image of the set of multi-resolution images
  98      *
  99      * @since 9
 100      */
 101     protected abstract Image getBaseImage();
 102 }


  47  *     }
  48  *
  49  *     public List<Image> getResolutionVariants() {
  50  *         return Collections.unmodifiableList(Arrays.asList(resolutionVariants));
  51  *     }
  52  *
  53  *     protected Image getBaseImage() {
  54  *         return resolutionVariants[0];
  55  *     }
  56  * }
  57  * } </pre>
  58  *
  59  * @see java.awt.Image
  60  * @see java.awt.image.MultiResolutionImage
  61  *
  62  * @since 9
  63  */
  64 public abstract class AbstractMultiResolutionImage extends java.awt.Image
  65         implements MultiResolutionImage {
  66 
  67     /**
  68      * This method simply delegates to the same method on the base image and
  69      * it is equivalent to: {@code getBaseImage().getWidth(observer)}.
  70      *
  71      * @return the width of the base image, or -1 if the width is not yet known
  72      * @see #getBaseImage()
  73      *
  74      * @since 9
  75      */
  76     @Override
  77     public int getWidth(ImageObserver observer) {
  78         return getBaseImage().getWidth(observer);
  79     }
  80 
  81     /**
  82      * This method simply delegates to the same method on the base image and
  83      * it is equivalent to: {@code getBaseImage().getHeight(observer)}.
  84      *
  85      * @return the height of the base image, or -1 if the height is not yet known
  86      * @see #getBaseImage()
  87      *
  88      * @since 9
  89      */
  90     @Override
  91     public int getHeight(ImageObserver observer) {
  92         return getBaseImage().getHeight(observer);
  93     }
  94 
  95     /**
  96      * This method simply delegates to the same method on the base image and
  97      * it is equivalent to: {@code getBaseImage().getSource()}.
  98      *
  99      * @return the image producer that produces the pixels for the base image
 100      * @see #getBaseImage()
 101      *
 102      * @since 9
 103      */
 104     @Override
 105     public ImageProducer getSource() {
 106         return getBaseImage().getSource();
 107     }
 108 
 109     /**
 110      * As per the contract of the base {@code Image#getGraphics()} method,
 111      * this implementation will always throw {@code UnsupportedOperationException}
 112      * since only off-screen images can return a {@code Graphics} object.
 113      *
 114      * @return throws {@code UnsupportedOperationException}
 115      * @throws UnsupportedOperationException this method is not supported
 116      */
 117     @Override
 118     public Graphics getGraphics() {
 119         throw new UnsupportedOperationException("getGraphics() not supported"
 120                 + " on Multi-Resolution Images");
 121     }
 122 
 123     /**
 124      * This method simply delegates to the same method on the base image and
 125      * it is equivalent to: {@code getBaseImage().getProperty(name, observer)}.
 126      *
 127      * @return the value of the named property in the base image
 128      * @see #getBaseImage()
 129      *
 130      * @since 9
 131      */
 132     @Override
 133     public Object getProperty(String name, ImageObserver observer) {
 134         return getBaseImage().getProperty(name, observer);
 135     }
 136 
 137     /**
 138      * Return the base image representing the best version of the image for
 139      * rendering at the default width and height.
 140      *
 141      * @return the base image of the set of multi-resolution images
 142      *
 143      * @since 9
 144      */
 145     protected abstract Image getBaseImage();
 146 }
< prev index next >