Author: jm
Date: 2011-01-14 12:45:07 -0800 (Fri, 14 Jan 2011)
New Revision: 23464
Modified:
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/util/SelectUtil.java
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
Log:
Improved performance of selection-state-handling bits
Modified:
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/util/SelectUtil.java
===================================================================
---
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/util/SelectUtil.java
2011-01-14 20:25:56 UTC (rev 23463)
+++
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/util/SelectUtil.java
2011-01-14 20:45:07 UTC (rev 23464)
@@ -70,4 +70,25 @@
}
}
}
+
+ public static int getSelectedNodeCount(CyNetwork cyNetwork) {
+ return countSelected(cyNetwork.getNodeList());
+ }
+
+ public static int getSelectedEdgeCount(CyNetwork cyNetwork) {
+ return countSelected(cyNetwork.getNodeList());
+ }
+
+ static <T extends CyTableEntry> int countSelected(Collection<T> items) {
+ int count = 0;
+ for (T item : items) {
+ CyRow row = item.getCyRow();
+ if (row.get(CyNetwork.SELECTED, Boolean.class)) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+
}
Modified:
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
===================================================================
---
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
2011-01-14 20:25:56 UTC (rev 23463)
+++
core3/filter-impl/trunk/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
2011-01-14 20:45:07 UTC (rev 23464)
@@ -278,12 +278,10 @@
String title = VisualPropertyUtil.get(lexicon, view,
"NETWORK_TITLE", TwoDVisualLexicon.NETWORK, String.class);
tblFeedBack.getModel().setValueAt(title, 0, 0);
- // TODO: Review performance. This is a bad way to handle
counting.
- String nodeStr = "" + cyNetwork.getNodeCount() + "(" +
SelectUtil.getSelectedNodes(cyNetwork).size() + ")";
+ String nodeStr = "" + cyNetwork.getNodeCount() + "(" +
SelectUtil.getSelectedNodeCount(cyNetwork) + ")";
tblFeedBack.getModel().setValueAt(nodeStr, 0, 1);
- // TODO: Review performance. This is a bad way to handle
counting.
- String edgeStr = "" + cyNetwork.getEdgeCount() + "(" +
SelectUtil.getSelectedEdges(cyNetwork).size() + ")";
+ String edgeStr = "" + cyNetwork.getEdgeCount() + "(" +
SelectUtil.getSelectedEdgeCount(cyNetwork) + ")";
tblFeedBack.getModel().setValueAt(edgeStr, 0, 2);
}
@@ -468,7 +466,6 @@
cmbAttributes.addItemListener(this);
// // TODO: Port this
-//
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(Cytoscape.NETWORK_LOADED,
this);
//
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(Cytoscape.NETWORK_TITLE_MODIFIED,
this);
//
btnSelectAll.addActionListener(this);
--
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.