You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2019/06/01 15:22:00 UTC

[GitHub] [netbeans] emilianbold commented on a change in pull request #1278: [NETBEANS-2604] Support SVG icon loading from ImageUtilities

emilianbold 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_r289608816
 
 

 ##########
 File path: platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
 ##########
 @@ -353,62 +429,122 @@ public static Icon createDisabledIcon(Icon icon)  {
      */
     public static Image createDisabledImage(Image image)  {
         Parameters.notNull("image", image);
-        return LazyDisabledIcon.createDisabledImage(image);
+        // Go through FilteredIcon to preserve scalable icons.
+        return icon2Image(createDisabledIcon(image2Icon(image)));
+    }
+
+    /**
+     * Get an SVG icon loader, if the appropriate service provider module is installed. To ensure
+     * lazy loading of the SVG loader module, this method should only be called when there actually
+     * exists an SVG file to load. The result is cached.
+     *
+     * @return may be null
+     */
+    private static SVGLoader getSVGLoader() {
+        /* "Objects contained in the default lookup are instantiated lazily when first requested."
+        ( http://wiki.netbeans.org/DevFaqLookupDefault ) So the SVGLoader implementation module will
+        only be loaded the first time an SVG file is actually encountered for loading, rather than,
+        for instance, when the startup splash screen initializes ImageUtilities to load its PNG
+        image. This was confirmed by printing a debugging message from a static initializer in
+        SVGLoaderImpl in the implementation module; the message appears well after the splash
+        screen's PNG graphics first becomes visible. */
+        return svgLoaderLoader.getLoader();
     }
 
     /**
      * Get the class loader from lookup.
      * Since this is done very frequently, it is wasteful to query lookup each time.
      * Instead, remember the last result and just listen for changes.
      */
-    static ClassLoader getLoader() {
-        Object is = currentLoader;
-        if (is instanceof ClassLoader) {
-            return (ClassLoader)is;
-        }
-            
-        currentLoader = Thread.currentThread();
-            
-        if (loaderQuery == null) {
-            loaderQuery = Lookup.getDefault().lookup(new Lookup.Template<ClassLoader>(ClassLoader.class));
-            loaderQuery.addLookupListener(
-                new LookupListener() {
-                    public void resultChanged(LookupEvent ev) {
-                        ERR.fine("Loader cleared"); // NOI18N
-                        currentLoader = null;
-                    }
-                }
-            );
+    static ClassLoader getClassLoader() {
+        return classLoaderLoader.getLoader();
+    }
+
+    private static final class CachedLookupLoader<T> {
 
 Review comment:
   This is a bit heavy for me...

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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