Author: pwang
Date: 2011-03-03 17:08:20 -0800 (Thu, 03 Mar 2011)
New Revision: 24312

Modified:
   
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
Log:
Add null pointer check when recovery networkviews

Modified: 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
--- 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
     2011-03-04 01:04:25 UTC (rev 24311)
+++ 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
     2011-03-04 01:08:20 UTC (rev 24312)
@@ -207,48 +207,52 @@
 
             // Get network frames info
             Cysession cysess = sess.getCysession();
-            List<NetworkFrame> frames = 
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
-            Map<String, NetworkFrame> framesLookup = new Hashtable<String, 
NetworkFrame>();
             
-            for (NetworkFrame nf : frames) {
-                framesLookup.put(nf.getFrameID(), nf);
-            }
-            
-            // Set visual styles to network views
-            Map<CyNetworkView, String> netStyleMap = 
sess.getViewVisualStyleMap();
+            if (cysess.getSessionState().getDesktop().getNetworkFrames() != 
null){
+                List<NetworkFrame> frames = 
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
+                Map<String, NetworkFrame> framesLookup = new Hashtable<String, 
NetworkFrame>();
+                
+                for (NetworkFrame nf : frames) {
+                    framesLookup.put(nf.getFrameID(), nf);
+                }
+                
+                // Set visual styles to network views
+                Map<CyNetworkView, String> netStyleMap = 
sess.getViewVisualStyleMap();
 
-            for (Entry<CyNetworkView, String> entry : netStyleMap.entrySet()) {
-                CyNetworkView netView = entry.getKey();
-                String stName = entry.getValue();
-                VisualStyle vs = stylesMap.get(stName);
+                for (Entry<CyNetworkView, String> entry : 
netStyleMap.entrySet()) {
+                    CyNetworkView netView = entry.getKey();
+                    String stName = entry.getValue();
+                    VisualStyle vs = stylesMap.get(stName);
 
-                if (vs != null) {
-                    vmMgr.setVisualStyle(vs, netView);
-                    vs.apply(netView);
-                    
-                    // TODO: Set network width/height
-                    String name = 
netView.getModel().getCyRow().get(CyNetwork.NAME, String.class);
-                    
-                    if (name != null && name.length() > 0) {
-                        
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_TITLE, name);
-                        NetworkFrame nf = framesLookup.get(name);
+                    if (vs != null) {
+                        vmMgr.setVisualStyle(vs, netView);
+                        vs.apply(netView);
                         
-                        if (nf != null) {
-                            BigInteger w = nf.getWidth();
-                            BigInteger h = nf.getHeight();
+                        // TODO: Set network width/height
+                        String name = 
netView.getModel().getCyRow().get(CyNetwork.NAME, String.class);
+                        
+                        if (name != null && name.length() > 0) {
+                            
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_TITLE, name);
+                            NetworkFrame nf = framesLookup.get(name);
                             
-                            if (w != null)
-                                
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_WIDTH, w.doubleValue());
-                            if (h != null)
-                                
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_HEIGHT, h.doubleValue());
-                            
-                            // TODO: how to set network view's x,y position?
+                            if (nf != null) {
+                                BigInteger w = nf.getWidth();
+                                BigInteger h = nf.getHeight();
+                                
+                                if (w != null)
+                                    
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_WIDTH, w.doubleValue());
+                                if (h != null)
+                                    
netView.setVisualProperty(TwoDVisualLexicon.NETWORK_HEIGHT, h.doubleValue());
+                                
+                                // TODO: how to set network view's x,y 
position?
+                            }
                         }
+                        
+                        netView.updateView();
                     }
-                    
-                    netView.updateView();
                 }
             }
+            
         }
 
         currentSession = sess;

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