Author: pwang
Date: 2012-06-05 16:51:24 -0700 (Tue, 05 Jun 2012)
New Revision: 29474

Modified:
   
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/ActivePaths.java
Log:
Load VisualStyles

Modified: 
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/ActivePaths.java
===================================================================
--- 
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/ActivePaths.java
      2012-06-05 23:49:03 UTC (rev 29473)
+++ 
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/ActivePaths.java
      2012-06-05 23:51:24 UTC (rev 29474)
@@ -33,6 +33,8 @@
 import csplugins.jActiveModules.data.ActivePathFinderParameters;
 //import csplugins.jActiveModules.util.Scaler;
 import csplugins.jActiveModules.util.ScalerFactory;
+import csplugins.jActiveModules.util.Util;
+
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyTable;
@@ -50,6 +52,9 @@
 import org.cytoscape.work.TaskMonitor;
 import csplugins.jActiveModules.ServicesUtil;
 import java.io.File;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 
 
 
//-----------------------------------------------------------------------------------
@@ -95,38 +100,30 @@
        
        private static final String NODE_SCORE = MODULE_FINDER_PREFIX + 
"activepathScore";
 
-//     static {
-//             
-//             // Create visualStyles based on the definition in property files
-//             //Cytoscape.firePropertyChange(Cytoscape.VIZMAP_LOADED, null, 
vizmapPropsLocation);
-//             //overviewVS = 
Cytoscape.getVisualMappingManager().getCalculatorCatalog().getVisualStyle(VS_OVERVIEW_NAME);
-//             //moduleVS = 
Cytoscape.getVisualMappingManager().getCalculatorCatalog().getVisualStyle(VS_MODULE_NAME);
-//             
-//             
-//             System.out.println("\n\nvizmapPropsLocation 
="+vizmapPropsLocation+ "\n");
-//             System.out.println("\n\nvizmapPropsLocation.getFile() 
="+vizmapPropsLocation.getFile()+ "\n");
-//             
-//             
-//             Iterator<VisualStyle> it = 
ServicesUtil.visualMappingManagerRef.getAllVisualStyles().iterator();
-//             while (it.hasNext()){
-//                     VisualStyle vs = it.next();
-//                     if (vs.getTitle().equalsIgnoreCase(VS_OVERVIEW_NAME)){
-//                             overviewVS = vs;
-//                     }
-//                     if (vs.getTitle().equalsIgnoreCase(VS_MODULE_NAME)){
-//                             moduleVS = vs;
-//                     }
-//             }
-//             if (overviewVS == null && moduleVS == null){
-//                     String filename = vizmapPropsLocation.getFile();
-//                     File f = new File(filename);    
-//                     
-//                     System.out.println("f.getAbsolutePath() 
="+f.getAbsolutePath() + "\tf.length = "+f.length()+ "\n");
-//                     
-//                     ServicesUtil.loadVizmapFileTaskFactory.loadStyles(f);
-//             }
-//     }
+       static {
+               if (overviewVS == null && moduleVS == null){
+                       // Create visualStyles based on the definition in 
property files
+                       File f = 
Util.getFileFromFar("jActiveModules_VS.props");                        
+                       ServicesUtil.loadVizmapFileTaskFactory.loadStyles(f);
+               }
+               populateVS();
+       }
        
+       private static void populateVS(){
+               
+               Iterator<VisualStyle> it = 
ServicesUtil.visualMappingManagerRef.getAllVisualStyles().iterator();
+               while (it.hasNext()){
+                       VisualStyle vs = it.next();
+                       if (vs.getTitle().equalsIgnoreCase(VS_OVERVIEW_NAME)){
+                               overviewVS = vs;
+                       }
+                       if (vs.getTitle().equalsIgnoreCase(VS_MODULE_NAME)){
+                               moduleVS = vs;
+                       }
+               }
+       }
+       
+       
        private static boolean eventFired = false;
        
        private static CyLayoutAlgorithm layoutAlgorithm = 
ServicesUtil.cyLayoutsServiceRef.getLayout("force-directed");
@@ -284,15 +281,12 @@
                
ServicesUtil.cyNetworkViewManagerServiceRef.addNetworkView(newView);
                
                // Apply layout for overview
-//             layoutAlgorithm.setNetworkView(newView);
-//             
this.insertTasksAfterCurrentTask(layoutAlgorithm.getTaskIterator());
                Object context = layoutAlgorithm.getDefaultLayoutContext();
                
insertTasksAfterCurrentTask(layoutAlgorithm.createTaskIterator(newView, 
context, CyLayoutAlgorithm.ALL_NODE_VIEWS,""));
+                       
+               ServicesUtil.visualMappingManagerRef.setVisualStyle(overviewVS, 
newView);
+               newView.updateView();
 
-                               
-//             this.visualMappingManager.setVisualStyle(overviewVS, newView);
-//             newView.updateView();
-
                taskMonitor.setStatusMessage("Create views for top n 
modules...");
 
                // Create view for top n modules
@@ -312,12 +306,10 @@
                                CyNetworkView theView = 
ServicesUtil.cyNetworkViewFactoryServiceRef.createNetworkView(subnetworks[i]);
                                
ServicesUtil.cyNetworkViewManagerServiceRef.addNetworkView(theView);
                                                                
-//                             layoutAlgorithm.setNetworkView(theView);
-//                             
this.insertTasksAfterCurrentTask(layoutAlgorithm.getTaskIterator());
                                
insertTasksAfterCurrentTask(layoutAlgorithm.createTaskIterator(theView, 
context, CyLayoutAlgorithm.ALL_NODE_VIEWS,""));
 
-//                             
this.visualMappingManager.setVisualStyle(moduleVS, theView);
-//                             theView.updateView();
+                               
ServicesUtil.visualMappingManagerRef.setVisualStyle(moduleVS, theView);
+                               theView.updateView();
                 }
                 
                        taskMonitor.setProgress(1.0);

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