Author: oriol
Date: 2012-03-23 04:41:51 -0700 (Fri, 23 Mar 2012)
New Revision: 28625

Modified:
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
Log:
Fix bug #817. A new map has been added to store layout context and avoid 
charging it everytime so modified parameters are kept

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
    2012-03-22 23:44:14 UTC (rev 28624)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutSettingsDialog.java
    2012-03-23 11:41:51 UTC (rev 28625)
@@ -35,6 +35,9 @@
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.swing.BorderFactory;
@@ -89,6 +92,10 @@
        private CyProperty cytoscapePropertiesServiceRef;
        private DynamicTaskFactoryProvisioner factoryProvisioner;
        private boolean initialized;
+       /**
+        *  Store the layout context.
+        */
+       private Map<CyLayoutAlgorithm, CyLayoutContext> contextMap;
 
        /**
         * Creates a new LayoutSettingsDialog object.
@@ -111,6 +118,7 @@
                this.taskManager = taskManager;
                this.cytoscapePropertiesServiceRef = 
cytoscapePropertiesServiceRef;
                this.factoryProvisioner = new 
DynamicTaskFactoryProvisioner(appMgr);
+               this.contextMap = new HashMap<CyLayoutAlgorithm, 
CyLayoutContext>();
                
                Properties props = 
(Properties)this.cytoscapePropertiesServiceRef.getProperties();
                
@@ -366,7 +374,13 @@
                        // if it's a string, that means it's the instructions
                        if (!(o instanceof String)) {
                                final CyLayoutAlgorithm newLayout = 
(CyLayoutAlgorithm)o;
-                               CyLayoutContext context = 
newLayout.createLayoutContext();
+                               //Checking if the context has already been 
charged, if so there is no need to do it again
+                               CyLayoutContext context = 
contextMap.get(newLayout);
+                               if (context == null)
+                               {
+                                       context = 
newLayout.createLayoutContext();
+                                       contextMap.put(newLayout, context);
+                               }
                                TaskFactory provisioner = 
factoryProvisioner.createFor(wrapWithContext(newLayout, context));
                                if (!provisioner.isReady()) {
                                        throw new 
IllegalArgumentException("Layout is not fully configured");

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