Author: kono
Date: 2011-10-26 16:21:12 -0700 (Wed, 26 Oct 2011)
New Revision: 27315

Modified:
   csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
   csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/GoBin.java
   csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ResultPanel.java
   csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ZSelectNodes.java
   csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/SettingsPanelActionListener.java
Log:
Selection function fixed.

Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java  
2011-10-26 22:05:35 UTC (rev 27314)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/DisplayBiNGOWindow.java  
2011-10-26 23:21:12 UTC (rev 27315)
@@ -59,6 +59,7 @@
 import org.cytoscape.view.model.CyNetworkViewFactory;
 import org.cytoscape.view.model.CyNetworkViewManager;
 import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskManager;
 import org.cytoscape.work.TaskMonitor;
 
 import BiNGO.ontology.Ontology;
@@ -216,8 +217,13 @@
                buildNodeAttributes(network);
                buildEdgeAttributes(network);
                
-               final CyNetworkViewFactory viewFactory = 
adapter.getCyNetworkViewFactory();
-               final CyNetworkView bingoCyNetworkView = 
viewFactory.getNetworkView(network);
+               
+               // Create View
+               final TaskManager tm = adapter.getTaskManager();
+               tm.execute(new GenericTaskFactory(new CreateViewTask(network)));
+               
+//             final CyNetworkViewFactory viewFactory = 
adapter.getCyNetworkViewFactory();
+//             final CyNetworkView bingoCyNetworkView = 
viewFactory.getNetworkView(network);
 //             
 //             // from MCODE plugin, MCODEResultsDialog class layout graph and 
fit it to window
 //             // randomize node positions before layout so that they don't 
all layout in a line

Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/GoBin.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/GoBin.java      
2011-10-26 22:05:35 UTC (rev 27314)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/GoBin.java      
2011-10-26 23:21:12 UTC (rev 27315)
@@ -47,6 +47,7 @@
 import javax.swing.JTable;
 
 import org.cytoscape.model.CyNetwork;
+import org.cytoscape.plugin.CyPluginAdapter;
 import org.cytoscape.view.model.CyNetworkView;
 
 import BiNGO.SettingsPanel;
@@ -92,9 +93,11 @@
        // private JFrame bingoWindow = new JFrame("BiNGO Settings");
        private SettingsPanel settingsPanel;
        private CyNetworkView networkView;
+       
+       private final CyPluginAdapter adapter;
 
-       public GoBin(BiNGO.SettingsPanel settingsPanel, CyNetworkView 
networkView) {
-
+       public GoBin(BiNGO.SettingsPanel settingsPanel, CyNetworkView 
networkView, final CyPluginAdapter adapter) {
+               this.adapter = adapter;
                this.setTitle("BiNGO output");
                this.settingsPanel = settingsPanel;
                this.networkView = networkView;
@@ -289,7 +292,7 @@
                ResultPanel result = new ResultPanel(testMap, correctionMap, 
mapSmallX, mapSmallN, mapBigX, mapBigN,
                                alphaString, annotation, alias, ontology, 
annotationFile, ontologyFile, testString, correctionString,
                                overUnderString, dirName, fileName, 
clusterVsString, catString, selectedCanonicalNameVector,
-                               currentNetwork, currentNetworkview, this);
+                               currentNetwork, currentNetworkview, this, 
adapter);
 
                if (getResultPanelCount() != 0)
                        result.setTabName(trouveBonNom(result.getTabName()));

Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ResultPanel.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ResultPanel.java        
2011-10-26 22:05:35 UTC (rev 27314)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ResultPanel.java        
2011-10-26 23:21:12 UTC (rev 27315)
@@ -66,6 +66,7 @@
 import javax.swing.table.TableColumnModel;
 
 import org.cytoscape.model.CyNetwork;
+import org.cytoscape.plugin.CyPluginAdapter;
 import org.cytoscape.view.model.CyNetworkView;
 
 import BiNGO.Browser;
@@ -169,6 +170,8 @@
        final static int SELECT_COLUMN = 0;
        final static int GO_TERM_COLUMN = 1;
        final static int DESCRIPTION_COLUMN = 2;
+       
+       private final CyPluginAdapter adapter;
 
        /**
         * Creates a new instance of ResultPanel
@@ -178,9 +181,10 @@
                        Map mapBigN, String alphaString, Annotation annotation, 
Map alias, Ontology ontology,
                        String annotationFile, String ontologyFile, String 
testString, String correctionString,
                        String overUnderString, String dirName, String fileNam, 
String clusterVsString, String catString,
-                       Set selectedCanonicalNameVector, CyNetwork 
currentNetwork, CyNetworkView currentNetworkview, GoBin goB) {
+                       Set selectedCanonicalNameVector, CyNetwork 
currentNetwork, CyNetworkView currentNetworkview, GoBin goB, final 
CyPluginAdapter adapter) {
                this.fileName = fileNam.substring(0, fileNam.length() - 4);
-
+               
+               this.adapter = adapter;
                this.testMap = testMap;
                this.correctionMap = correctionMap;
                this.mapSmallX = mapSmallX;
@@ -376,7 +380,7 @@
                constr.weightx = 100;
                constr.anchor = constr.EAST;
                JButton jButton4 = new JButton("Select nodes");
-               jButton4.addActionListener(new 
ZSelectNodes((ResultAndStartPanel) this));
+               jButton4.addActionListener(new 
ZSelectNodes((ResultAndStartPanel) this, adapter));
                jPanelApplyButtons.add(jButton4, constr);
 
                jPanelDeBase.add(jPanelApplyButtons, 
java.awt.BorderLayout.SOUTH);

Modified: csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ZSelectNodes.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ZSelectNodes.java       
2011-10-26 22:05:35 UTC (rev 27314)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/GOlorize/ZSelectNodes.java       
2011-10-26 23:21:12 UTC (rev 27315)
@@ -45,9 +45,12 @@
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.plugin.CyPluginAdapter;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.View;
 
+import com.sun.xml.internal.bind.v2.model.core.Adapter;
+
 import BiNGO.ontology.Annotation;
 
 public class ZSelectNodes implements ActionListener {
@@ -55,69 +58,81 @@
        ResultAndStartPanel result;
        Annotation annotation;
 
+       private final CyPluginAdapter adapter;
+       
        /** Creates a new instance of ZSelectNodes */
-       public ZSelectNodes(ResultAndStartPanel result) {
+       public ZSelectNodes(ResultAndStartPanel result, final CyPluginAdapter 
adapter) {
                this.result = result;
-
+               this.adapter = adapter;
        }
 
        public void actionPerformed(ActionEvent ev) {
                
-               // TODO:  FIXME 
-               System.out.println("Not implemented yet!!");
+               System.out.println("Selection start!!");
                
-//             this.annotation = result.getAnnotation();
-//             Map<String, HashSet<String>> alias = result.getAlias();
-//             JTable jTable = result.getJTable();
-//             // goSelected = ZDisplayGoNodes3.getSelectedGoSet(jTable);
-//             goSelected = getSelectedGoSet(jTable);
-//             CyNetworkView currentNetworkView = result.getNetworkView();
-//             if (currentNetworkView != null) {
-//                     final CyNetwork model = currentNetworkView.getModel();
-//                     final List<CyNode> nodes = model.getNodeList();
-//                     for (final CyNode node : nodes)
-//                             node.getCyRow().set(CyNetwork.SELECTED, false);
-//
-//                     currentNetworkView.updateView();
-//
-//                     HashSet selectedNodesSet = new HashSet();
-//
-//                     if (result instanceof ResultPanel) {
-//                             this.annotation = result.getAnnotation();
-//                             final Collection<View<CyNode>> nodeViews = 
currentNetworkView.getNodeViews();                           
-//                             for(View<CyNode> nodeView: nodeViews) {
-//                                     Set goAnnot = new HashSet();
-//                                     
-//                                     String nodeName = 
nodeView.getNode().getIdentifier().toUpperCase();
-//                                     HashSet identifiers = alias.get(node);
-//                                     if (identifiers != null) {
-//                                             Iterator it = 
identifiers.iterator();
-//                                             while (it.hasNext()) {
-//                                                     int[] goID = 
annotation.getClassifications(it.next() + "");
-//                                                     for (int t = 0; t < 
goID.length; t++) {
-//                                                             
goAnnot.add(goID[t] + "");
-//                                                     }
-//                                             }
-//                                     }
-//
-//                                     if (goAnnot != null) {
-//                                             Iterator it = 
goAnnot.iterator();
-//                                             while (it.hasNext()) {
-//                                                     if 
(goSelected.contains((new Integer(it.next() + "")).toString())) {
-//                                                             
selectedNodesSet.add(nodeView.getNode());
-//                                                             continue;
-//                                                     }
-//                                             }
-//                                     }
-//
-//                                     // this.annotation=null;
-//                             }
-//                             
currentNetworkView.getNetwork().setSelectedNodeState(selectedNodesSet, true);
-//                             currentNetworkView.updateView();
-//                     }
-//
-//                     this.annotation = null;
-//             }
+               this.annotation = result.getAnnotation();
+               Map<String, Set<String>> alias = result.getAlias();
+               JTable jTable = result.getJTable();
+               goSelected = getSelectedGoSet(jTable);
+               CyNetworkView currentNetworkView = result.getNetworkView();
+               if (currentNetworkView != null) {
+                       final CyNetwork model = currentNetworkView.getModel();
+                       final List<CyNode> nodes = model.getNodeList();
+                       for (final CyNode node : nodes)
+                               node.getCyRow().set(CyNetwork.SELECTED, false);
+
+                       //currentNetworkView.updateView();
+
+                       System.out.println("Selection cleared!!----------" + 
model.getCyRow().get(CyTableEntry.NAME, String.class));
+                       
+                       final Set<CyNode> selectedNodesSet = new 
HashSet<CyNode>();
+
+                       if (result instanceof ResultPanel) {
+                               this.annotation = result.getAnnotation();
+                               final Collection<View<CyNode>> nodeViews = 
currentNetworkView.getNodeViews();                           
+                               for(View<CyNode> nodeView: nodeViews) {
+                                       Set goAnnot = new HashSet();
+                                       
+                                       final CyNode node = nodeView.getModel();
+                                       final String nodeName = 
node.getCyRow().get(CyTableEntry.NAME, String.class);
+                                       Set identifiers = alias.get(nodeName);
+                                       if (identifiers != null) {
+                                               Iterator it = 
identifiers.iterator();
+                                               while (it.hasNext()) {
+                                                       int[] goID = 
annotation.getClassifications(it.next() + "");
+                                                       for (int t = 0; t < 
goID.length; t++) {
+                                                               
goAnnot.add(goID[t] + "");
+                                                       }
+                                               }
+                                               System.out.println("Selected 
Node name = " + nodeName);
+                                       }
+
+                                       
+                                       if (goAnnot != null) {
+                                               Iterator it = 
goAnnot.iterator();
+                                               while (it.hasNext()) {
+                                                       if 
(goSelected.contains((new Integer(it.next() + "")).toString())) {
+                                                               
selectedNodesSet.add(nodeView.getModel());
+                                                               continue;
+                                                       }
+                                               }
+                                       }
+                                       // this.annotation=null;
+                               }
+                               
+                               System.out.println("Nodes selected = " + 
selectedNodesSet.size());
+
+                               for(final CyNode node: selectedNodesSet)
+                                       node.getCyRow().set(CyNetwork.SELECTED, 
true);
+
+                               adapter.getCyEventHelper().flushPayloadEvents();
+                               currentNetworkView.updateView();
+                       }
+
+                       this.annotation = null;
+               }
+               
+               System.out.println("Selection DONE!!");
        }
 
        private HashSet getSelectedGoSet(JTable jTable1) {

Modified: 
csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/SettingsPanelActionListener.java
===================================================================
--- csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/SettingsPanelActionListener.java 
2011-10-26 22:05:35 UTC (rev 27314)
+++ csplugins/trunk/ucsd/kono/bingo3/src/BiNGO/SettingsPanelActionListener.java 
2011-10-26 23:21:12 UTC (rev 27315)
@@ -1059,7 +1059,7 @@
                                display.makeWindow();
                        }
                        if ((goBin == null) || goBin.isWindowClosed()) {
-                               goBin = new BiNGO.GOlorize.GoBin(settingsPanel, 
startNetworkView);
+                               goBin = new BiNGO.GOlorize.GoBin(settingsPanel, 
startNetworkView, adapter);
                        }
 
                        if (params.getAnnotationFile() == null) {

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