< prev index next >

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

Print this page




  63     }
  64 
  65     public static ImageObserver getResolutionVariantObserver(
  66             final Image image, final ImageObserver observer,
  67             final int imgWidth, final int imgHeight,
  68             final int rvWidth, final int rvHeight) {
  69         return getResolutionVariantObserver(image, observer,
  70                 imgWidth, imgHeight, rvWidth, rvHeight, false);
  71     }
  72 
  73     public static ImageObserver getResolutionVariantObserver(
  74             final Image image, final ImageObserver observer,
  75             final int imgWidth, final int imgHeight,
  76             final int rvWidth, final int rvHeight, boolean concatenateInfo) {
  77 
  78         if (observer == null) {
  79             return null;
  80         }
  81 
  82         synchronized (ObserverCache.INSTANCE) {
  83             ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(image);
  84 
  85             if (o == null) {
  86 
  87                 o = (Image resolutionVariant, int flags,
  88                         int x, int y, int width, int height) -> {
  89 
  90                             if ((flags & (ImageObserver.WIDTH | BITS_INFO)) != 0) {
  91                                 width = (width + 1) / 2;
  92                             }
  93 
  94                             if ((flags & (ImageObserver.HEIGHT | BITS_INFO)) != 0) {
  95                                 height = (height + 1) / 2;
  96                             }
  97 
  98                             if ((flags & BITS_INFO) != 0) {
  99                                 x /= 2;
 100                                 y /= 2;
 101                             }
 102 
 103                             if(concatenateInfo){
 104                                 flags &= ((ToolkitImage) image).
 105                                         getImageRep().check(null);
 106                             }
 107 
 108                             return observer.imageUpdate(
 109                                     image, flags, x, y, width, height);
 110                         };
 111 
 112                 ObserverCache.INSTANCE.put(image, o);
 113             }
 114             return o;
 115         }
 116     }
 117 }


  63     }
  64 
  65     public static ImageObserver getResolutionVariantObserver(
  66             final Image image, final ImageObserver observer,
  67             final int imgWidth, final int imgHeight,
  68             final int rvWidth, final int rvHeight) {
  69         return getResolutionVariantObserver(image, observer,
  70                 imgWidth, imgHeight, rvWidth, rvHeight, false);
  71     }
  72 
  73     public static ImageObserver getResolutionVariantObserver(
  74             final Image image, final ImageObserver observer,
  75             final int imgWidth, final int imgHeight,
  76             final int rvWidth, final int rvHeight, boolean concatenateInfo) {
  77 
  78         if (observer == null) {
  79             return null;
  80         }
  81 
  82         synchronized (ObserverCache.INSTANCE) {
  83             ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(observer);
  84 
  85             if (o == null) {
  86 
  87                 o = (Image resolutionVariant, int flags,
  88                         int x, int y, int width, int height) -> {
  89 
  90                             if ((flags & (ImageObserver.WIDTH | BITS_INFO)) != 0) {
  91                                 width = (width + 1) / 2;
  92                             }
  93 
  94                             if ((flags & (ImageObserver.HEIGHT | BITS_INFO)) != 0) {
  95                                 height = (height + 1) / 2;
  96                             }
  97 
  98                             if ((flags & BITS_INFO) != 0) {
  99                                 x /= 2;
 100                                 y /= 2;
 101                             }
 102 
 103                             if(concatenateInfo){
 104                                 flags &= ((ToolkitImage) image).
 105                                         getImageRep().check(null);
 106                             }
 107 
 108                             return observer.imageUpdate(
 109                                     image, flags, x, y, width, height);
 110                         };
 111 
 112                 ObserverCache.INSTANCE.put(observer, o);
 113             }
 114             return o;
 115         }
 116     }
 117 }
< prev index next >