Author: pwang
Date: 2011-11-02 12:08:30 -0700 (Wed, 02 Nov 2011)
New Revision: 27377

Modified:
   
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActiveModulesUI.java
   
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActivePaths.java
   
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/CyActivator.java
Log:
Add loadVisualStyle

Modified: 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActiveModulesUI.java
===================================================================
--- 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActiveModulesUI.java
     2011-11-02 18:52:25 UTC (rev 27376)
+++ 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActiveModulesUI.java
     2011-11-02 19:08:30 UTC (rev 27377)
@@ -28,6 +28,7 @@
 import org.cytoscape.model.CyNetworkManager;
 import org.cytoscape.model.subnetwork.CyRootNetworkFactory;
 import org.cytoscape.property.CyProperty;
+import org.cytoscape.task.creation.LoadVisualStyles;
 import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
 import org.cytoscape.view.model.CyNetworkViewFactory;
 import org.cytoscape.view.model.CyNetworkViewManager;
@@ -69,12 +70,13 @@
        private TaskManager taskManagerService;
        private CyApplicationManager cyApplicationManagerService;
        private CyEventHelper cyEventHelperService;
+       private LoadVisualStyles loadVizmapFileTaskFactory;
        
        public ActiveModulesUI(CyApplicationManager appMgr, CySwingApplication 
desktopApp,CyProperty<Properties> cytoscapeProperties,
                        CyNetworkManager cyNetworkManager, CyNetworkViewManager 
cyNetworkViewManager, VisualMappingManager visualMappingManager,
                        CyNetworkFactory cyNetworkFactory, CyRootNetworkFactory 
cyRootNetworkFactory, 
                        CyNetworkViewFactory 
cyNetworkViewFactory,CyLayoutAlgorithmManager cyLayoutsService, 
-                       TaskManager taskManagerService, CyEventHelper 
cyEventHelperService, 
+                       TaskManager taskManagerService, CyEventHelper 
cyEventHelperService, LoadVisualStyles loadVizmapFileTaskFactory,
                        ActivePathFinderParameters apfParams, 
ActivePathsParameterPanel mainPanel) {
                
                super("jActiveModules...", appMgr);
@@ -92,6 +94,7 @@
                this.taskManagerService = taskManagerService;
                this.cyApplicationManagerService = appMgr;
                this.cyEventHelperService = cyEventHelperService;
+               this.loadVizmapFileTaskFactory = loadVizmapFileTaskFactory;
                
                this.cytoscapeProperties = cytoscapeProperties;
                this.mainPanel = mainPanel;
@@ -160,7 +163,8 @@
                                                this.cyNetworkManager, 
this.cyNetworkViewManager, this.visualMappingManager, 
                                                this.cyNetworkFactory, 
this.cyRootNetworkFactory, 
                                                this.cyNetworkViewFactory, 
this.cyLayoutsService, this.taskManagerService, 
-                                               
this.cyApplicationManagerService, this.cyEventHelperService);
+                                               
this.cyApplicationManagerService, this.cyEventHelperService,
+                                               this.loadVizmapFileTaskFactory);
                                Thread t = new Thread(activePaths);
                                t.start();
                        }
@@ -221,7 +225,7 @@
                                        this.visualMappingManager, 
this.cyNetworkFactory, this.cyRootNetworkFactory, 
                                        this.cyNetworkViewFactory, 
this.cyLayoutsService,
                                        this.taskManagerService, 
this.cyApplicationManagerService,
-                                       this.cyEventHelperService);
+                                       this.cyEventHelperService, 
this.loadVizmapFileTaskFactory);
                        
                } catch (final Exception e) {
                        e.printStackTrace(System.err);
@@ -278,7 +282,7 @@
                                        
ActiveModulesUI.this.visualMappingManager, 
ActiveModulesUI.this.cyNetworkFactory, 
ActiveModulesUI.this.cyRootNetworkFactory, 
                                        
ActiveModulesUI.this.cyNetworkViewFactory, 
ActiveModulesUI.this.cyLayoutsService,
                                        
ActiveModulesUI.this.taskManagerService, 
ActiveModulesUI.this.cyApplicationManagerService,
-                                       
ActiveModulesUI.this.cyEventHelperService);
+                                       
ActiveModulesUI.this.cyEventHelperService,ActiveModulesUI.this.loadVizmapFileTaskFactory
 );
                        activePaths.scoreActivePath();
                }
        }
@@ -288,7 +292,7 @@
                                this.cyNetworkManager, 
this.cyNetworkViewManager, ActiveModulesUI.this.visualMappingManager,
                                ActiveModulesUI.this.cyNetworkFactory, 
ActiveModulesUI.this.cyRootNetworkFactory, 
ActiveModulesUI.this.cyNetworkViewFactory,
                                ActiveModulesUI.this.cyLayoutsService, 
this.taskManagerService, this.cyApplicationManagerService,
-                               ActiveModulesUI.this.cyEventHelperService);
+                               ActiveModulesUI.this.cyEventHelperService, 
ActiveModulesUI.this.loadVizmapFileTaskFactory);
                Thread t = new ScoreDistributionThread(desktopApp.getJFrame(), 
network, activePaths, apfParams);
                t.setUncaughtExceptionHandler(xHandler);
                t.start();

Modified: 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActivePaths.java
===================================================================
--- 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActivePaths.java
 2011-11-02 18:52:25 UTC (rev 27376)
+++ 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/ActivePaths.java
 2011-11-02 19:08:30 UTC (rev 27377)
@@ -45,6 +45,7 @@
 import org.cytoscape.model.CyTable;
 import org.cytoscape.property.CyProperty;
 //import cytoscape.data.Semantics;
+import org.cytoscape.task.creation.LoadVisualStyles;
 import org.cytoscape.view.layout.CyLayoutAlgorithm;
 import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
 import org.cytoscape.view.model.CyNetworkView;
@@ -60,6 +61,7 @@
 import org.cytoscape.model.subnetwork.CySubNetwork;
 import org.cytoscape.model.CyRow;
 import java.util.Collection;
+import java.io.File;
 
 
//-----------------------------------------------------------------------------------
 public class ActivePaths implements ActivePathViewer, Runnable {
@@ -127,6 +129,8 @@
     private TaskManager taskManagerService;
        private CyApplicationManager cyApplicationManagerService;
        private CyEventHelper cyEventHelperService;
+       private LoadVisualStyles loadVizmapFileTaskFactory;
+       private static boolean visualStylesLoaded = false;
        
        // ----------------------------------------------------------------
        public ActivePaths(CyNetwork cyNetwork, ActivePathFinderParameters 
apfParams, ActiveModulesUI parentUI,
@@ -134,7 +138,8 @@
                        CyNetworkViewManager cyNetworkViewManager, 
VisualMappingManager visualMappingManager, 
                        CyNetworkFactory cyNetworkFactory, CyRootNetworkFactory 
cyRootNetworkFactory, CyNetworkViewFactory cyNetworkViewFactory, 
                        CyLayoutAlgorithmManager cyLayoutsService, TaskManager 
taskManagerService,      
-                       CyApplicationManager cyApplicationManagerService, 
CyEventHelper cyEventHelperService) {
+                       CyApplicationManager cyApplicationManagerService, 
CyEventHelper cyEventHelperService,
+                       LoadVisualStyles loadVizmapFileTaskFactory) {
                this.apfParams = apfParams;
                this.cytoscapeProperties = cytoscapeProperties;
                this.desktopApp = desktopApp;
@@ -149,6 +154,7 @@
                this.taskManagerService = taskManagerService;
                this.cyApplicationManagerService = cyApplicationManagerService;
                this.cyEventHelperService = cyEventHelperService;
+               this.loadVizmapFileTaskFactory = loadVizmapFileTaskFactory;
 
                try {                   
                        MAX_NETWORK_VIEWS = new 
Integer(this.cytoscapeProperties.getProperties().getProperty("moduleNetworkViewCreationThreshold")).intValue();
                 
@@ -162,18 +168,32 @@
                //}
 
 //             Set<VisualStyle> visualStyles = 
this.visualMappingManager.getAllVisualStyles(); 
-//             Iterator<VisualStyle> it = visualStyles.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;
-//                     }
-//             }
+
+               // Load jActiveModules defined Visual styles if not loaded yet
+               Set<VisualStyle> visualStyles= null;
+               if (!visualStylesLoaded){                       
+                       File f = new File(vizmapPropsLocation.toString());
+                       visualStyles = 
this.loadVizmapFileTaskFactory.loadStyles(f);
+                       visualStylesLoaded = true;
+               }
+
+               // Get the styles for overview and module
+               Iterator<VisualStyle> it = visualStyles.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;
+                       }
+               }
+                       
+               System.out.println("overviewVS = "+ overviewVS);
+               System.out.println("moduleVS = "+ moduleVS);
+                       
                
-                       
+               //
                if (cyNetwork == null || cyNetwork.getNodeCount() == 0) {
                        throw new IllegalArgumentException("Please select a 
network");
                }

Modified: 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/CyActivator.java
===================================================================
--- 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/CyActivator.java
 2011-11-02 18:52:25 UTC (rev 27376)
+++ 
csplugins/trunk/ucsd/pwang/jActiveModules31/src/main/java/csplugins/jActiveModules/CyActivator.java
 2011-11-02 19:08:30 UTC (rev 27377)
@@ -19,10 +19,13 @@
 
 import org.osgi.framework.BundleContext;
 import org.cytoscape.service.util.AbstractCyActivator;
+import org.cytoscape.task.creation.LoadVisualStyles;
+
 import java.util.Properties;
 import csplugins.jActiveModules.dialogs.ActivePathsParameterPanel;
 import csplugins.jActiveModules.data.ActivePathFinderParameters;
 import org.cytoscape.util.swing.NetworkSelectorPanel;
+import org.cytoscape.task.creation.LoadVisualStyles;
 
 public class CyActivator extends AbstractCyActivator {
        public CyActivator() {
@@ -49,6 +52,9 @@
                CyNetworkViewFactory cyNetworkViewFactoryServiceRef = 
getService(bc,CyNetworkViewFactory.class);
                CyLayoutAlgorithmManager cyLayoutsServiceRef = 
getService(bc,CyLayoutAlgorithmManager.class);
 
+               LoadVisualStyles loadVizmapFileTaskFactory =  
getService(bc,LoadVisualStyles.class);
+
+               //
                
                ActivePathFinderParameters apfParams = new 
ActivePathFinderParameters(cytoscapePropertiesServiceRef);
 
@@ -62,7 +68,7 @@
                ActiveModulesUI activeModulesUI = new 
ActiveModulesUI(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
                                cytoscapePropertiesServiceRef, 
cyNetworkManagerServiceRef,cyNetworkViewManagerServiceRef, 
visualMappingManagerRef, 
                                cyNetworkFactoryServiceRef, 
cyRootNetworkFactory, cyNetworkViewFactoryServiceRef,cyLayoutsServiceRef,
-                               
taskManagerServiceRef,cyEventHelperServiceRef,apfParams, mainPanel);
+                               
taskManagerServiceRef,cyEventHelperServiceRef,loadVizmapFileTaskFactory,apfParams,
 mainPanel);
                
                registerAllServices(bc,mainPanel, new Properties());
                

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