Author: kono
Date: 2010-02-02 12:24:09 -0800 (Tue, 02 Feb 2010)
New Revision: 19137

Modified:
   cytoscape/trunk/src/cytoscape/Cytoscape.java
   
cytoscape/trunk/src/cytoscape/data/webservice/ui/UnifiedNetworkImportDialog.java
   cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
Log:
Tweaked Visual Style update timing.

Modified: cytoscape/trunk/src/cytoscape/Cytoscape.java
===================================================================
--- cytoscape/trunk/src/cytoscape/Cytoscape.java        2010-02-02 20:20:04 UTC 
(rev 19136)
+++ cytoscape/trunk/src/cytoscape/Cytoscape.java        2010-02-02 20:24:09 UTC 
(rev 19137)
@@ -1730,6 +1730,7 @@
                }
 
                final DingNetworkView view = new DingNetworkView(network, 
title);
+               final VisualMappingManager vmm = 
Cytoscape.getVisualMappingManager();
                
                view.setIdentifier(network.getIdentifier());
                view.setTitle(network.getTitle());
@@ -1738,23 +1739,21 @@
 
                if (vs != null) {
                        view.setVisualStyle(vs.getName());
-                       getVisualMappingManager().setVisualStyle(vs);
-                       getVisualMappingManager().setNetworkView(view);
+                       vmm.setVisualStyle(vs);
+               } else {
+                       view.setVisualStyle(vmm.getVisualStyle().getName());
                }
 
                if (layout == null) {
                        layout = CyLayouts.getDefaultLayout();
                }
-               final VisualMappingManager vmm = 
Cytoscape.getVisualMappingManager();
+               
                vmm.setNetworkView(view);
                vmm.applyAppearances();
                layout.doLayout(view);
                view.setGraphLOD(new CyGraphLOD());
                
Cytoscape.firePropertyChange(cytoscape.view.CytoscapeDesktop.NETWORK_VIEW_CREATED,
 null, view);
                
-               //view.fitContent();
-               //view.redrawGraph(false, true);
-               
                return view;
        }
 

Modified: 
cytoscape/trunk/src/cytoscape/data/webservice/ui/UnifiedNetworkImportDialog.java
===================================================================
--- 
cytoscape/trunk/src/cytoscape/data/webservice/ui/UnifiedNetworkImportDialog.java
    2010-02-02 20:20:04 UTC (rev 19136)
+++ 
cytoscape/trunk/src/cytoscape/data/webservice/ui/UnifiedNetworkImportDialog.java
    2010-02-02 20:24:09 UTC (rev 19137)
@@ -747,18 +747,18 @@
                        if (evt.getNewValue() == null)
                                return;
 
-                       VisualStyle style = ((NetworkImportWebServiceClient) 
WebServiceClientManager
-                                       
.getClient(selectedClientID)).getDefaultVisualStyle();
-                       if (style == null) {
-                               style = 
Cytoscape.getVisualMappingManager().getVisualStyle();
-                       }
-
-                       if 
(Cytoscape.getVisualMappingManager().getCalculatorCatalog()
-                                       .getVisualStyle(style.getName()) == 
null)
-                               
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
-                                               .addVisualStyle(style);
-
-                       
Cytoscape.getVisualMappingManager().setVisualStyle(style);
+//                     VisualStyle style = ((NetworkImportWebServiceClient) 
WebServiceClientManager
+//                                     
.getClient(selectedClientID)).getDefaultVisualStyle();
+//                     if (style == null) {
+//                             style = 
Cytoscape.getVisualMappingManager().getVisualStyle();
+//                     }
+//
+//                     if 
(Cytoscape.getVisualMappingManager().getCalculatorCatalog()
+//                                     .getVisualStyle(style.getName()) == 
null)
+//                             
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
+//                                             .addVisualStyle(style);
+//
+//                     
Cytoscape.getVisualMappingManager().setVisualStyle(style);
                        
                        // Name the network
                        final String[] message = { "Network Loaded from " + 
selectedClientID,

Modified: cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java     
2010-02-02 20:20:04 UTC (rev 19136)
+++ cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java     
2010-02-02 20:24:09 UTC (rev 19137)
@@ -827,7 +827,7 @@
 
                Cytoscape.getCurrentNetworkView().setVisualStyle(vsName);
 
-               if (redraw)
+               if (redraw && Cytoscape.getCurrentNetworkView() != 
Cytoscape.getNullNetworkView())
                        Cytoscape.getCurrentNetworkView().redrawGraph(false, 
true);
 
                /*
@@ -3675,45 +3675,35 @@
                if (ignore)
                        return;
                
-               // Save currently selected Visual Style name
-               final String selectedName = (String) 
vsNameComboBox.getSelectedItem();
-               
                // Get current Visual Style
                final String currentName = vmm.getVisualStyle().getName();
+               final Object selected = vsNameComboBox.getSelectedItem();
                
-               final CyNetworkView curView = Cytoscape.getCurrentNetworkView();
-
-               if ((selectedName == null) || (currentName == null) || (curView 
== null)
-                   || curView.equals(Cytoscape.getNullNetworkView()))
+               if (selected != null && 
selected.toString().equals(currentName)) {
                        return;
-
+               }
+               
                // Update GUI based on CalcCatalog's state.
                if (!findVSName(currentName)) {
                        syncStyleBox();
-               } else {
-                       for (int i = 0; i < vsNameComboBox.getItemCount(); i++) 
{
-                               if 
(vsNameComboBox.getItemAt(i).equals(currentName)) {
-                                       vsNameComboBox.setSelectedIndex(i);
-                                       break;
-                               }
-                       }
-               }
+               } else
+                       vsNameComboBox.setSelectedItem(currentName);
                
                lastVSName = currentName;
        }
 
        private void syncStyleBox() {
 
-               String curStyleName = vmm.getVisualStyle().getName();
-
+               final String curStyleName = vmm.getVisualStyle().getName();
+               final CalculatorCatalog catalog = vmm.getCalculatorCatalog();
+               
                String styleName;
-               List<String> namesInBox = new ArrayList<String>();
-               
namesInBox.addAll(vmm.getCalculatorCatalog().getVisualStyleNames());
-
+               final List<String> namesInBox = new ArrayList<String>();
+               namesInBox.addAll(catalog.getVisualStyleNames());
                for (int i = 0; i < vsNameComboBox.getItemCount(); i++) {
                        styleName = vsNameComboBox.getItemAt(i).toString();
 
-                       if 
(vmm.getCalculatorCatalog().getVisualStyle(styleName) == null) {
+                       if (catalog.getVisualStyle(styleName) == null) {
                                // No longer exists in the VMM.  Remove.
                                vsNameComboBox.removeItem(styleName);
                                defaultImageManager.remove(styleName);
@@ -3726,13 +3716,10 @@
                // Reset combobox items.
                vsNameComboBox.removeAllItems();
 
-               for (String name : namesInBox)
+               for (final String name : namesInBox)
                        vsNameComboBox.addItem(name);
 
-               if ((curStyleName == null) || curStyleName.trim().equals(""))
-                       switchVS(vmm.getVisualStyle().getName());
-               else
-                       switchVS(curStyleName);
+               switchVS(curStyleName);
        }
 
        // return true iff 'match' is found as a name within the

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