Author: kono
Date: 2009-12-01 12:01:47 -0800 (Tue, 01 Dec 2009)
New Revision: 18623

Modified:
   corelibs/trunk/ding/src/ding/view/DNodeView.java
Log:
Resource loader fixed.

Modified: corelibs/trunk/ding/src/ding/view/DNodeView.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-01 20:01:12 UTC 
(rev 18622)
+++ corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-01 20:01:47 UTC 
(rev 18623)
@@ -54,6 +54,7 @@
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -73,8 +74,17 @@
 public class DNodeView implements NodeView, Label {
        // For Cytoscape 2.7: Nested Network Image size
        private static final float NESTED_IMAGE_SCALE_FACTOR = 0.7f;
-       private static BufferedImage defaultNestedNetworkImage = null;
-
+       private static BufferedImage DEFAULT_NESTED_NETWORK_IMAGE;
+       
+       static {
+               try {
+                       DEFAULT_NESTED_NETWORK_IMAGE = 
ImageIO.read(DNodeView.class.getClassLoader().getResource("resources/images/default_network.png"));
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       DEFAULT_NESTED_NETWORK_IMAGE = null;
+               }
+       }
+       
        static final float DEFAULT_WIDTH = 20.0f;
        static final float DEFAULT_HEIGHT = 20.0f;
        static final byte DEFAULT_SHAPE = GraphGraphics.SHAPE_ELLIPSE;
@@ -1414,17 +1424,11 @@
                                        return 
nestedNetworkView.getSnapshot(IMAGE_WIDTH, IMAGE_HEIGHT);
                                }
                                else {
-                                       if (defaultNestedNetworkImage == null) {
-//                                             try {
-//                                                     
defaultNestedNetworkImage = ImageIO.read(new 
File("/cellar/users/ruschein/code/cytoscape/images/default_network.png"));
-//                                             }
-//                                             catch (final Exception e) {
-                                                       return null;
-//                                             }
+                                       if (DEFAULT_NESTED_NETWORK_IMAGE == 
null) {
+                                               return null;
                                        }
-
                                        final Rectangle2D rect = new 
Rectangle2D.Double(-IMAGE_WIDTH/2, -IMAGE_HEIGHT/2, IMAGE_WIDTH, IMAGE_HEIGHT);
-                                       return new 
TexturePaint(defaultNestedNetworkImage, rect);
+                                       return new 
TexturePaint(DEFAULT_NESTED_NETWORK_IMAGE, rect);
                                }
                        } else {
                                return null;

--

You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.


Reply via email to