< 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      * Returns the width of the base image. If the width is not yet known,
  69      * this method returns <code>-1</code> and the specified
  70      * <code>ImageObserver</code> object is notified later.
  71      * @param observer an object waiting for the image to be loaded.
  72      * @return the width of this image, or <code>-1</code>
  73      * if the width is not yet known.
  74      */
  75     
  76     @Override
  77     public int getWidth(ImageObserver observer) {
  78         return getBaseImage().getWidth(observer);
  79     }
  80     
  81     /**
  82      * Returns the height of the base image. If the height is not yet known,
  83      * this method returns <code>-1</code> and the specified
  84      * <code>ImageObserver</code> object is notified later.
  85      * @param observer an object waiting for the image to be loaded.
  86      * @return the height of this image, or <code>-1</code>
  87      * if the height is not yet known.
  88      */
  89     
  90     @Override
  91     public int getHeight(ImageObserver observer) {
  92         return getBaseImage().getHeight(observer);
  93     }
  94 
  95     /**
  96      * Gets the object that produces the pixels for the base image.
  97      * This method is called by the image filtering classes and by
  98      * methods that perform image conversion and scaling.
  99      * @return the {@code ImageProducer} that produces the pixels
 100      * for this image.
 101      */
 102     
 103     @Override
 104     public ImageProducer getSource() {
 105         return getBaseImage().getSource();
 106     }
 107     
 108      /**
 109      * This method is not supported by {@code AbstractMultiResolutionImage}
 110      * and always throws {@code UnsupportedOperationException}
 111      *
 112      * @return {@code UnsupportedOperationException} is thrown
 113      * @throws UnsupportedOperationException this method is not supported
 114      */
 115     
 116     @Override
 117     public Graphics getGraphics() {
 118         throw new UnsupportedOperationException("getGraphics() not supported"
 119                 + " on Multi-Resolution Images");
 120     }
 121 
 122     /**
 123      * Gets a property of this image by name.
 124      * 
 125      * Individual property names are defined by the various image
 126      * formats. If a property is not defined for a particular image, this
 127      * method returns the {@code UndefinedProperty} object.
 128      * 
 129      * If the properties for this image are not yet known, this method
 130      * returns {@code null}, and the {@code ImageObserver}
 131      * object is notified later.
 132      * 
 133      * The property name {@code "comment"} should be used to store
 134      * an optional comment which can be presented to the application as a
 135      * description of the image, its source, or its author.
 136      * @param name a property name.
 137      * @param observer an object waiting for this image to be loaded.
 138      * @return the value of the named property if the property name is not null.
 139      * @throws      NullPointerException if the property name is null.
 140      */
 141     
 142     @Override
 143     public Object getProperty(String name, ImageObserver observer) {
 144         return getBaseImage().getProperty(name, observer);
 145     }
 146 
 147     /**
 148      * Return the base image representing the best version of the image for
 149      * rendering at the default width and height.
 150      *
 151      * @return the base image of the set of multi-resolution images
 152      *
 153      * @since 9
 154      */
 155     protected abstract Image getBaseImage();
 156 }
< prev index next >