private void applySelectionToNetwork() { CyNetwork network = Cytoscape.getCurrentNetwork(); network.unselectAllNodes(); network.unselectAllEdges(); Set<String> selection = new HashSet<String>(); for (int i : currentTable.getSelectedRows()) { selection.add(currentTable.getValueAt(i, 0).toString()); } NetworkData networkData = MetScapePlugin.getPluginData().getNetworkData(Networks.getUUID(network)); if (networkData == null) return; NetworkType networkType = networkData.getNetworkType(); if (networkType == NetworkType.CREG) applySelectionToCREGNetwork(network, selection); else if (networkType == NetworkType.COMPOUND_REACTION) applySelectionToCRNetwork(network, selection); else if (networkType == NetworkType.COMPOUND_GENE) applySelectionToCGNetwork(network, selection); else if (networkType == NetworkType.COMPOUND) applySelectionToCompoundNetwork(network, selection); CyNetworkView view = Cytoscape.getNetworkView(network.getIdentifier()); if (view != null && initialized) view.redrawGraph(true, true); else if (!initialized) initialized = true; }
private void refreshPathwayListForCurrentNetwork() { Set<String> selectedPathwaySet = new HashSet<String>(); for (int i : currentTable.getSelectedRows()) selectedPathwaySet.add(currentTable.getValueAt(i, 0).toString()); currentModel.setRowCount(0); SortedSet<String> pathwaySet; CyNetwork network = Cytoscape.getCurrentNetwork(); NetworkData networkData = MetScapePlugin.getPluginData().getNetworkData(Networks.getUUID(network)); NetworkType networkType = null; if (networkData != null) networkType = networkData.getNetworkType(); if (networkType == NetworkType.COMPOUND_REACTION || networkType == NetworkType.CREG) { // for C-R and C-R-E-G pathwaySet = getPathwaySetFromReactionNodes(network); } else if (networkType == NetworkType.COMPOUND) { pathwaySet = getPathwaySetFromReactionEdges(network); } else if (networkType == NetworkType.COMPOUND_GENE) { pathwaySet = getPathwaySetFromEnzymeReactionEdges(network); } else { pathwaySet = new TreeSet<String>(); } for (String pathway : pathwaySet) { currentModel.addRow(new Object[] {pathway}); if (selectedPathwaySet.contains(pathway)) currentTable.addRowSelectionInterval( currentTable.getRowCount() - 1, currentTable.getRowCount() - 1); } applySelectionToNetwork(); }
private void switchActiveTable() { if (tables.get(Cytoscape.getCurrentNetwork()) != currentTable) { currentTable.getSelectionModel().removeListSelectionListener(PathwayFilterPanel.this); scrollPane.getViewport().setView(null); currentTable = tables.get(Cytoscape.getCurrentNetwork()); if (currentTable == null) { currentTable = new ExtendedJTable(); tables.put(Cytoscape.getCurrentNetwork(), currentTable); ((ExtendedTableModel) currentTable.getModel()).addColumn("Pathways"); currentTable.getRowSorter().toggleSortOrder(0); currentModel = (ExtendedTableModel) currentTable.getModel(); refreshPathwayListForCurrentNetwork(); } currentModel = (ExtendedTableModel) currentTable.getModel(); scrollPane.getViewport().setView(currentTable); currentTable.getSelectionModel().addListSelectionListener(PathwayFilterPanel.this); } applySelectionToNetwork(); }
private void createControls() { buttonPanel = new JPanel(); selectAll = new JButton("Select All Pathways"); selectAll.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selectAll(); } }); buttonPanel.add(selectAll); deselectAll = new JButton("Deselect All Pathways"); deselectAll.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { deselectAll(); } }); buttonPanel.add(deselectAll); createSubnetwork = new JButton("Create Subnetwork"); createSubnetwork.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { buildSubnetwork(); } }); buttonPanel.add(createSubnetwork); reapplySelection = new JButton("Reapply Selection"); reapplySelection.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { applySelectionToNetwork(); } }); buttonPanel.add(reapplySelection); close = new JButton("Close"); close.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { close(); } }); buttonPanel.add(close); add(buttonPanel, BorderLayout.NORTH); tables = new HashMap<CyNetwork, ExtendedJTable>(); currentTable = new ExtendedJTable(); tables.put(Cytoscape.getCurrentNetwork(), currentTable); currentTable.getSelectionModel().addListSelectionListener(this); currentModel = (ExtendedTableModel) currentTable.getModel(); currentModel.addColumn("Pathways"); currentTable.getRowSorter().toggleSortOrder(0); scrollPane = new JScrollPane(currentTable); refreshPathwayListForCurrentNetwork(); add(scrollPane, BorderLayout.CENTER); addComponentListener(this); }
private void deselectAll() { currentTable.clearSelection(); }
private void selectAll() { currentTable.selectAll(); }