sdedic commented on a change in pull request #3414:
URL: https://github.com/apache/netbeans/pull/3414#discussion_r780805915



##########
File path: platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
##########
@@ -825,22 +850,62 @@ private static final ToolTipImage doMergeImages(Image 
image1, Image image2, int
             str.append(toolTip);
         }
         Object firstUrl = image1.getProperty("url", null);
+        Object firstUri = image1.getProperty("uri", null);
         
         ColorModel model = colorModel(bitmask? Transparency.BITMASK: 
Transparency.TRANSLUCENT);
         // Provide a delegate Icon for scalable rendering.
         Icon delegateIcon = new MergedIcon(image2Icon(image1), 
image2Icon(image2), x, y);
         ToolTipImage buffImage = new ToolTipImage(str.toString(), delegateIcon,
-                model, model.createCompatibleWritableRaster(w, h), 
model.isAlphaPremultiplied(), null, firstUrl instanceof URL ? (URL)firstUrl : 
null
+                model, model.createCompatibleWritableRaster(w, h), 
model.isAlphaPremultiplied(), null, 
+                firstUrl instanceof URL ? (URL)firstUrl : null,
+                firstUri instanceof URI ? (URI)firstUri : null
             );
 
         // Also provide an Image-based rendering for backwards-compatibility.
         java.awt.Graphics g = buffImage.createGraphics();
-        g.drawImage(image1, 0, 0, null);
-        g.drawImage(image2, x, y, null);
+        drawImage(g, image1, 0, 0, null);
+        drawImage(g, image2, x, y, null);
         g.dispose();
 
         return buffImage;
     }
+    
+    /**
+     * Retrieves the original icon from a possible wrapper.
+     * @param image image
+     * @return the icon, if reachable.
+     */
+    private static Icon originalIcon(Image image) {
+        if (image instanceof ToolTipImage) {
+            return ((ToolTipImage) image).getDelegateIcon();
+        }
+        Object o = image.getProperty("originalIcon", null); // NOI18N
+        if (o instanceof Icon) {
+            // do not bother if the property is not loaded now.
+            return (Icon)o;
+        }
+        return null;
+    }
+    
+    private static Image originalImage(Image image) {
+        Object o = image.getProperty("originalImage", null); // NOI18N
+        return o instanceof Image ? (Image)o : image;
+    }
+
+    /**
+     * Draws an image on graphics. The difference between a direct {@link 
Graphics#drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)} call
+     * and this is that if the image is wrapped (i.e. as an attempt to add 
some metadata to it), the original will be used if the wrapper is cooperative. 
The
+     * wrapper image may not be compatible with the SurfaceManager and a 
direct draw would result in an IllegalArgumentException.
+     * 
+     * @param g graphics
+     * @param image image to draw
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param observer the image observer callback.
+     */
+    private static void drawImage(Graphics g, Image image, int x, int y, 
ImageObserver observer) {

Review comment:
       Removed from 2b887f0




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to