in progress...
[jalview.git] / forester / java / src / org / forester / archaeopteryx / tools / ImageLoader.java
index b81cc25..899d8ce 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 //
 // Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.archaeopteryx.tools;
 
+import java.awt.color.CMMException;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -34,8 +35,8 @@ import java.util.List;
 
 import javax.imageio.ImageIO;
 
+import org.forester.archaeopteryx.AptxConstants;
 import org.forester.archaeopteryx.AptxUtil;
-import org.forester.archaeopteryx.Constants;
 import org.forester.archaeopteryx.TreePanel;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Taxonomy;
@@ -52,6 +53,11 @@ public class ImageLoader implements Runnable {
         _tp = tp;
     }
 
+    @Override
+    public void run() {
+        load();
+    }
+
     private void load() {
         Hashtable<String, BufferedImage> image_map = null;
         if ( _tp.getImageMap() != null ) {
@@ -68,8 +74,10 @@ public class ImageLoader implements Runnable {
                     && !node.getNodeData().getTaxonomy().getUris().isEmpty() ) {
                 final List<Uri> us = new ArrayList<Uri>();
                 for( final Taxonomy t : node.getNodeData().getTaxonomies() ) {
-                    for( final Uri uri : t.getUris() ) {
-                        us.add( uri );
+                    if ( t.getUris() != null ) {
+                        for( final Uri uri : t.getUris() ) {
+                            us.add( uri );
+                        }
                     }
                 }
                 for( final Uri uri : us ) {
@@ -90,12 +98,20 @@ public class ImageLoader implements Runnable {
                                 bi = ImageIO.read( uri.getValue().toURL() );
                             }
                             catch ( final MalformedURLException e ) {
-                                AptxUtil.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
-                                        + "\": Malformed URL Exception: " + e.getLocalizedMessage() );
+                                AptxUtil.printWarningMessage( AptxConstants.PRG_NAME,
+                                                              "could not load image from \"" + uri.getValue()
+                                                              + "\": Malformed URL Exception: "
+                                                              + e.getLocalizedMessage() );
                             }
                             catch ( final IOException e ) {
-                                AptxUtil.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
-                                        + "\": IO Exception: " + e.getLocalizedMessage() );
+                                AptxUtil.printWarningMessage( AptxConstants.PRG_NAME,
+                                                              "could not load image from \"" + uri.getValue()
+                                                              + "\": IO Exception: " + e.getLocalizedMessage() );
+                            }
+                            catch ( final CMMException e ) {
+                                AptxUtil.printWarningMessage( AptxConstants.PRG_NAME,
+                                                              "could not load image from \"" + uri.getValue()
+                                                              + "\": CMMException: " + e.getLocalizedMessage() );
                             }
                             if ( bi != null ) {
                                 image_map.put( uri_str, bi );
@@ -110,9 +126,4 @@ public class ImageLoader implements Runnable {
             }
         }
     }
-
-    @Override
-    public void run() {
-        load();
-    }
 }