eirikbakke commented on a change in pull request #1278: [NETBEANS-2604] Support
SVG icon loading from ImageUtilities
URL: https://github.com/apache/netbeans/pull/1278#discussion_r352216515
##########
File path: platform/openide.util.ui/src/org/openide/util/CachedHiDPIIcon.java
##########
@@ -133,33 +140,61 @@ public final int getIconHeight() {
}
/**
- * Create a scaled image containing the graphics of this icon. The result
may be cached.
+ * Create a scaled image containing the graphics of this icon. The result
may be cached. The
+ * dimensions are specfied in device pixels rather than logical pixels,
i.e. with HiDPI scaling
+ * applied.
*
* @param c the component that was passed to {@link
Icon#paintIcon(Component,Graphics,int,int)}.
* The cache will <em>not</em> be invalidated if {@code c} or its
state changes, so
* subclasses should avoid depending on it if possible. This
parameter exists mainly to
* ensure compatibility with existing Icon implementations that may
be used as delegates.
* Future implementations might also elect to simply pass a dummy
Component instance
* here.
- * @param graphicsConfiguration the configuration of the surface on which
the image will be
- * painted
- * @param deviceWidth the required width of the image, with scaling
already applied
- * @param deviceHeight the required height of the image, with scaling
already applied
+ * @param colorModel the {@link ColorModel} of the surface on which the
image will be painted
+ * (may be passed to {@link #createBufferedImage(ColorModel, int,
int)} in the common
+ * case)
+ * @param deviceWidth the required width of the image, in device pixels
+ * @param deviceHeight the required height of the image, in device pixels
* @param scale the HiDPI scaling factor detected in {@code
graphicsConfiguration}
*/
- protected abstract Image createImage(Component c, GraphicsConfiguration
graphicsConfiguration,
+ protected abstract Image createAndPaintImage(Component c, ColorModel
colorModel,
int deviceWidth, int deviceHeight, double scale);
+ /**
+ * Utility method to create a compatible {@link BufferedImage} from the
parameters passed to
+ * {@link #createAndPaintImage(Component, ColorModel, int, int, double)}.
May be called by
+ * implementors of the latter to create a surface to draw on and return.
+ *
+ * @param colorModel the required {@link ColorModel}
+ * @param deviceWidth the required width of the image, in device pixels
+ * @param deviceHeight the required height of the image, in device pixels
+ * @return an image compatible with the given parameters
+ */
Review comment:
Making it "protected" mainly makes it clear, from a documentation
perspective, that it's a method intended for use by implementors of
CachedHiDPIIcon, rather than clients of it.
> Who's supposed to call them? Any subclass?
Yes. If they want. It's just a way to show and document to implementors how
to create a suitable backbuffer.
> But in fact everyone can do abstract class MyDummySubclass extends
CachedHiDPIIcon { /* now call the method */ } and get access to that method.
That's fine. It's static, so it doesn't actually expose any object state.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
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