Author: mes
Date: 2011-11-15 13:29:01 -0800 (Tue, 15 Nov 2011)
New Revision: 27480

Modified:
   
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
Log:
now returning the default visual style instead of throwing an NPE for a null 
network view

Modified: 
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
===================================================================
--- 
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
    2011-11-15 21:28:23 UTC (rev 27479)
+++ 
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/VisualMappingManagerImpl.java
    2011-11-15 21:29:01 UTC (rev 27480)
@@ -119,18 +119,17 @@
         */
        @Override
        public VisualStyle getVisualStyle(CyNetworkView nv) {
-               if (nv == null)
-                       throw new NullPointerException("network view is null.");
+               if (nv == null) {
+                       logger.warn("Attempting to get the visual style for a 
null network view; " + 
+                                   "returning the default visual style!");
+                       return getDefaultVisualStyle(); 
+               }
 
+               // Not registered yet. Provide default style.
                if (network2VisualStyleMap.containsKey(nv) == false) {
-                       if (this.defaultStyle == null)
-                               throw new IllegalStateException(
-                                               "No rendering engine is 
available, and cannot create default style!");
+                       network2VisualStyleMap.put(nv, getDefaultVisualStyle());
+               }
 
-                       // Not registered yet. Provide default style.
-                       network2VisualStyleMap.put(nv, defaultStyle);
-                       return defaultStyle;
-               }
                return network2VisualStyleMap.get(nv);
        }
 
@@ -216,6 +215,8 @@
 
        @Override
        public VisualStyle getDefaultVisualStyle() {
+               if (defaultStyle == null)
+                       throw new IllegalStateException("No rendering engine is 
available, and cannot create default style!");
                return defaultStyle;
        }
 

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