Revision: 5893
          http://sourceforge.net/p/jump-pilot/code/5893
Author:   edso
Date:     2018-06-22 12:49:54 +0000 (Fri, 22 Jun 2018)
Log Message:
-----------
restore formatting and state of r5322

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/workbench/ui/images/IconLoader.java

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/images/IconLoader.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/images/IconLoader.java  
2018-06-22 12:28:22 UTC (rev 5892)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/images/IconLoader.java  
2018-06-22 12:49:54 UTC (rev 5893)
@@ -1,3 +1,4 @@
+
 /*
  * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
  * for visualizing and manipulating spatial features with geometry and 
attributes.
@@ -47,88 +48,75 @@
  * Gets an icon from this class' package.
  */
 public class IconLoader {
-    // cache icons, in case they are requested more than once to speedup OJ
-    // start
-    private static HashMap<String, ImageIcon> iconCache = new HashMap<>();
+  // cache icons, in case they are requested more than once to speedup OJ start
+  private static HashMap<String, ImageIcon> iconCache = new HashMap<>();
 
-    // default icon if the choosen one doesn't exist
-    // Adapted from Kosmo SAIG
-    public final static ImageIcon DEFAULT_UNKNOW_ICON = new ImageIcon(
-            IconLoader.class.getResource("default_icon.png"));
+  public static ImageIcon icon(String filename) {
+    return getIcon(IconLoader.class.getResource(resolveFile(filename)));
+  }
 
-    public static ImageIcon icon(String filename) {
-        return getIcon(IconLoader.class.getResource(resolveFile(filename)));
-    }
+  public static BufferedImage image(String filename) {
+    ImageIcon icon = getIcon(
+        IconLoader.class.getResource(resolveFile(filename)));
+    Image image = icon.getImage();
 
-    public static BufferedImage image(String filename) {
-        final ImageIcon icon = getIcon(IconLoader.class
-                .getResource(resolveFile(filename)));
-        final Image image = icon.getImage();
+    // create a buffered image with transparency
+    BufferedImage bufImg = new BufferedImage(image.getWidth(null),
+        image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
 
-        // create a buffered image with transparency
-        final BufferedImage bufImg = new BufferedImage(image.getWidth(null),
-                image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
+    // draw the image on to the buffered image
+    Graphics2D bGr = bufImg.createGraphics();
+    bGr.drawImage(image, 0, 0, null);
+    bGr.dispose();
 
-        // draw the image on to the buffered image
-        final Graphics2D bGr = bufImg.createGraphics();
-        bGr.drawImage(image, 0, 0, null);
-        bGr.dispose();
+    return bufImg;
+  }
 
-        return bufImg;
-    }
+  protected static ImageIcon getIcon(URL url) {
+    // check for null
+    if (url == null)
+      throw new InvalidParameterException("parameter url must not be null.");
 
-    protected static ImageIcon getIcon(URL url) {
-        // check for null
-        if (url == null) {
-            throw new InvalidParameterException(
-                    "parameter url must not be null.");
-        }
+    String key = url.toExternalForm();
+    // System.out.println(key);
+    ImageIcon icon = null;
+    // check cache
+    icon = iconCache.get(key);
+    if (icon != null)
+      return icon;
 
-        final String key = url.toExternalForm();
-        // System.out.println(key);
-        ImageIcon icon = null;
-        // check cache
-        icon = iconCache.get(key);
-        if (icon != null) {
-            return icon;
-        }
+    // try loading the image
+    try {
+      // we keep using ImageIcon, as other loaders like ImageIO, commons 
Imaging
+      // choke on our icon gifs currently
+      icon = new ImageIcon(url);
+      // cache the image
+      iconCache.put(key, icon);
+    } catch (Exception e) {
+      Logger.error(e);
+    }
+    if (icon == null)
+      Logger.error("icon '" + key + "' is null!");
 
-        // try loading the image
-        try {
-            // we keep using ImageIcon, as other loaders like ImageIO, commons
-            // Imaging
-            // choke on our icon gifs currently
-            icon = new ImageIcon(url);
-            // cache the image
-            iconCache.put(key, icon);
-        } catch (final Exception e) {
-            Logger.error(e);
-        }
-        if (icon == null) {
-            icon = DEFAULT_UNKNOW_ICON;
-            Logger.error("icon '" + key + "' is null!");
-        }
+    return icon;
+  }
 
-        return icon;
+  /**
+   * utility method to automagically resolve images that moved into their
+   * appropriate iconset subfolders for legacy code
+   * 
+   * @param filename
+   * @return
+   */
+  protected static String resolveFile(String filename) {
+    // iterate over each location, return on first hit
+    for (String path : new String[] { "", "famfam/", "fugue/" }) {
+      if (IconLoader.class.getResource(path + filename) != null)
+        return path + filename;
     }
 
-    /**
-     * utility method to automagically resolve images that moved into their
-     * appropriate iconset subfolders for legacy code
-     * 
-     * @param filename
-     * @return
-     */
-    protected static String resolveFile(String filename) {
-        // iterate over each location, return on first hit
-        for (final String path : new String[] { "", "famfam/", "fugue/" }) {
-            if (IconLoader.class.getResource(path + filename) != null) {
-                return path + filename;
-            }
-        }
-
-        // if push comes to shove, we let the calling method deal w/ the
-        // consequences, exactly as it was before
-        return filename;
-    }
+    // if push comes to shove, we let the calling method deal w/ the
+    // consequences, exactly as it was before
+    return filename;
+  }
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to