Author: kono
Date: 2012-01-24 16:40:19 -0800 (Tue, 24 Jan 2012)
New Revision: 28096

Modified:
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
Log:
fixes #582 Apply timing had been fixed and Visual Style will be inherited from 
the parent network view.

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
    2012-01-24 23:30:26 UTC (rev 28095)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
    2012-01-25 00:40:19 UTC (rev 28096)
@@ -96,7 +96,7 @@
                        throw new NullPointerException("Source network is 
null.");
                tm.setProgress(0.0);
 
-               final CyNetworkView curView = 
networkViewManager.getNetworkView(parentNetwork);
+               final CyNetworkView sourceView = 
networkViewManager.getNetworkView(parentNetwork);
                tm.setProgress(0.1);
 
                // Get the selected nodes, but only create network if nodes are 
actually
@@ -124,20 +124,19 @@
                networkManager.addNetwork(newNet);
                tm.setProgress(0.6);
 
+               // Set the new network as current network
                appManager.setCurrentNetwork(newNet);
-
-               if (curView == null) {
                
+               // No view is available for parent network.
+               if (sourceView == null) {
                        // inserted first, happens second
                        final Task setCurrentNetworkView = new 
SetCurrentNetworkViewTask(newNet); 
                        insertTasksAfterCurrentTask(setCurrentNetworkView);
-
                        
                        // inserted second, happens first
                        final Task createViewTask = new 
CreateNetworkViewTask(undoSupport, newNet, viewFactory,
                                                                              
networkViewManager, null, eventHelper);
                        insertTasksAfterCurrentTask(createViewTask);
-
                        return;
                }
                tm.setProgress(0.7);
@@ -145,12 +144,12 @@
                // create new view
                final CyNetworkView newView = 
viewFactory.createNetworkView(newNet);
 
-               networkViewManager.addNetworkView(newView);
+//             networkViewManager.addNetworkView(newView);
                tm.setProgress(0.8);
 
                // copy node location only.
                for (View<CyNode> newNodeView : newView.getNodeViews()) {
-                       View<CyNode> origNodeView = 
curView.getNodeView(parentNetwork.getNode(newNodeView.getModel().getIndex()));
+                       View<CyNode> origNodeView = 
sourceView.getNodeView(parentNetwork.getNode(newNodeView.getModel().getIndex()));
                        
newNodeView.setVisualProperty(MinimalVisualLexicon.NODE_X_LOCATION,
                                        
origNodeView.getVisualProperty(MinimalVisualLexicon.NODE_X_LOCATION));
                        
newNodeView.setVisualProperty(MinimalVisualLexicon.NODE_Y_LOCATION,
@@ -166,11 +165,12 @@
                }
                tm.setProgress(0.9);
 
-               final VisualStyle style = vmm.getVisualStyle(curView);
-               vmm.setVisualStyle(vmm.getVisualStyle(curView), newView);
+               final VisualStyle style = vmm.getVisualStyle(sourceView);
+               vmm.setVisualStyle(style, newView);
                style.apply(newView);
                newView.fitContent();
-
+               
+               networkViewManager.addNetworkView(newView);
                appManager.setCurrentNetworkView(newView);
                tm.setProgress(1.0);
        }
@@ -182,7 +182,7 @@
                }
                public void run(TaskMonitor tm) {
                        tm.setProgress(0.0);
-                       CyNetworkView view = 
networkViewManager.getNetworkView(net);                    
+                       final CyNetworkView view = 
networkViewManager.getNetworkView(net);                      
                        tm.setProgress(0.5);
                        if ( view != null )
                                appManager.setCurrentNetworkView( view );

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
       2012-01-24 23:30:26 UTC (rev 28095)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
       2012-01-25 00:40:19 UTC (rev 28096)
@@ -207,6 +207,8 @@
                // Apply style to the current network view if necessary.
                final CyNetworkView currentView = 
applicationManager.getCurrentNetworkView();
                final VisualStyle selectedStyle = (VisualStyle) 
visualStyleComboBox.getModel().getSelectedItem();
+               
+               // Apply only if necessary.
                if (currentView != null && 
style.equals(manager.getCurrentVisualStyle()) == false) {
                        SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
@@ -384,12 +386,12 @@
        @Override
        public void handleEvent(final NetworkViewAddedEvent e) {
                final CyNetworkView newView = e.getNetworkView();
-               final VisualStyle targetStyle = manager.getCurrentVisualStyle();
+               final VisualStyle selectedStyle = 
manager.getCurrentVisualStyle();
                final VisualStyle curStyle = vmm.getVisualStyle(newView);
                
-               if (curStyle == null || 
curStyle.equals(vmm.getDefaultVisualStyle()) || curStyle.equals(targetStyle) == 
false ) {
-                       vmm.setVisualStyle(targetStyle, newView);
-                       targetStyle.apply(newView);
+               if (curStyle == null || 
curStyle.equals(vmm.getDefaultVisualStyle()) || curStyle.equals(selectedStyle) 
== false ) {
+                       vmm.setVisualStyle(selectedStyle, newView);
+                       selectedStyle.apply(newView);
                        newView.updateView();
                }
        }
@@ -459,7 +461,7 @@
                final VisualStyle newStyle = vmm.getVisualStyle(view);
                
                final Object currentSelected = 
visualStyleComboBox.getSelectedItem();
-               if(newStyle.equals(currentSelected) == false)
+               if(newStyle != currentSelected)
                        this.visualStyleComboBox.setSelectedItem(newStyle);
        }
 

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