Author: clopes
Date: 2012-11-09 10:43:21 -0800 (Fri, 09 Nov 2012)
New Revision: 30767

Modified:
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEDiscardResultAction.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/event/AnalysisCompletedEvent.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
   
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/AbstractMCODETest.java
   
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/model/MCODEAlgorithmTest.java
   
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/util/MCODEUtilTest.java
Log:
Fixed bug that would set a blank image to the first cluster of the next MCODE 
result if the size threshold of a cluster in a previous result was changed.
Some refactoring.

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
     2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
     2012-11-09 18:43:21 UTC (rev 30767)
@@ -226,7 +226,7 @@
 
                                        // Display clusters in a new modal 
dialog box
                                        if (e.isSuccessful()) {
-                                               if (e.getClusters() != null && 
e.getClusters().length > 0) {
+                                               if (e.getClusters() != null && 
!e.getClusters().isEmpty()) {
                                                        resultFound = true;
                                                        
mcodeUtil.addNetworkResult(network.getSUID());
 
@@ -240,7 +240,7 @@
                                                                                
                                                                                
                                                mcodeUtil);
 
                                                        resultsPanel = new 
MCODEResultsPanel(e.getClusters(), alg, mcodeUtil, network, networkView,
-                                                                               
                                                 e.getImageList(), resultId, 
discardResultAction);
+                                                                               
                                                 resultId, discardResultAction);
 
                                                        
registrar.registerService(resultsPanel, CytoPanelComponent.class, new 
Properties());
                                                } else {

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEDiscardResultAction.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEDiscardResultAction.java
       2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEDiscardResultAction.java
       2012-11-09 18:43:21 UTC (rev 30767)
@@ -1,6 +1,7 @@
 package org.cytoscape.mcode.internal;
 
 import java.awt.event.ActionEvent;
+import java.util.List;
 
 import javax.swing.JOptionPane;
 
@@ -63,7 +64,7 @@
                        }
 
                        if (confirmed == JOptionPane.YES_OPTION) {
-                               final MCODECluster[] clusters = 
panel.getClusters();
+                               final List<MCODECluster> clusters = 
panel.getClusters();
                                
                                registrar.unregisterService(panel, 
CytoPanelComponent.class);
                                mcodeUtil.removeNetworkResult(resultId);

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/event/AnalysisCompletedEvent.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/event/AnalysisCompletedEvent.java
   2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/event/AnalysisCompletedEvent.java
   2012-11-09 18:43:21 UTC (rev 30767)
@@ -1,19 +1,17 @@
 package org.cytoscape.mcode.internal.event;
 
-import java.awt.Image;
+import java.util.List;
 
 import org.cytoscape.mcode.internal.model.MCODECluster;
 
 public class AnalysisCompletedEvent {
 
        private final boolean successful;
-       private final MCODECluster[] clusters;
-       private final Image[] imageList;
+       private final List<MCODECluster> clusters;
 
-       public AnalysisCompletedEvent(final boolean successful, final 
MCODECluster[] clusters, final Image[] imageList) {
+       public AnalysisCompletedEvent(final boolean successful, final 
List<MCODECluster> clusters) {
                this.successful = successful;
                this.clusters = clusters;
-               this.imageList = imageList;
        }
 
        /**
@@ -27,15 +25,7 @@
         * Get computed clusters once MCODE has been run.  Will be null if not 
computed.
         * @return
         */
-       public MCODECluster[] getClusters() {
+       public List<MCODECluster> getClusters() {
                return clusters;
        }
-
-       /**
-        * Get image list of computed clusters to be used for display.
-        * @return
-        */
-       public Image[] getImageList() {
-               return imageList;
-       }
 }

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   2012-11-09 18:43:21 UTC (rev 30767)
@@ -276,9 +276,9 @@
         *
         * @param inputNetwork The scored network to find clusters in.
         * @param resultSetName Title of the result
-        * @return An array containing an MCODECluster object for each cluster.
+        * @return A list containing an MCODECluster object for each cluster.
         */
-       public MCODECluster[] findClusters(final CyNetwork inputNetwork, int 
resultId) {
+       public List<MCODECluster> findClusters(final CyNetwork inputNetwork, 
final int resultId) {
                final SortedMap<Double, List<Long>> nodeScoreSortedMap;
                final Map<Long, NodeInfo> nodeInfoHashMap;
 
@@ -410,13 +410,10 @@
                        alClusters = selectedALClusters;
                }
 
-               // Finally convert the list into a fixed array
-               MCODECluster[] clusters = alClusters.toArray(new 
MCODECluster[alClusters.size()]);
-               
                long msTimeAfter = System.currentTimeMillis();
                lastFindTime = msTimeAfter - msTimeBefore;
 
-               return clusters;
+               return alClusters;
        }
 
        /**

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
     2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
     2012-11-09 18:43:21 UTC (rev 30767)
@@ -1,5 +1,6 @@
 package org.cytoscape.mcode.internal.model;
 
+import java.awt.Image;
 import java.util.List;
 import java.util.Map;
 
@@ -47,15 +48,16 @@
  */
 public class MCODECluster {
 
+       private int resultId;
+       private Long seedNode;
+       private MCODEGraph graph;
        private List<Long> alCluster;
-       private MCODEGraph graph;
        private CyNetworkView view; // keeps track of layout so that layout 
process doesn't have to be repeated unnecessarily
-       private Long seedNode;
        private Map<Long, Boolean> nodeSeenHashMap; // stores the nodes that 
have already been included in higher ranking clusters
        private double score;
        private String name; // pretty much unused so far, but could store name 
by user's input
        private int rank;
-       private int resultId;
+       private Image image;
        private boolean disposed;
 
        public MCODECluster(final int resultId,
@@ -136,6 +138,14 @@
                this.name = "Cluster " + (rank + 1);
        }
        
+       public synchronized Image getImage() {
+               return image;
+       }
+
+       public synchronized void setImage(Image image) {
+               this.image = image;
+       }
+
        public synchronized boolean isDisposed() {
                return disposed;
        }

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
  2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
  2012-11-09 18:43:21 UTC (rev 30767)
@@ -1,6 +1,7 @@
 package org.cytoscape.mcode.internal.task;
 
 import java.awt.Image;
+import java.util.List;
 
 import org.cytoscape.mcode.internal.MCODEAnalyzeAction;
 import org.cytoscape.mcode.internal.event.AnalysisCompletedEvent;
@@ -63,7 +64,6 @@
 
        private boolean interrupted;
        private CyNetwork network;
-       private Image imageList[];
        
        private static final Logger logger = 
LoggerFactory.getLogger(MCODEAnalyzeTask.class);
 
@@ -99,7 +99,8 @@
                }
 
                boolean success = false;
-               MCODECluster[] clusters = null;
+               List<MCODECluster> clusters = null;
+               mcodeUtil.resetLoading();
 
                try {
                        // Run MCODE scoring algorithm - node scores are saved 
in the alg object
@@ -132,17 +133,16 @@
                        taskMonitor.setStatusMessage("Drawing Results (Step 3 
of 3)");
 
                        // Also create all the images here for the clusters, 
since it can be a time consuming operation
-                       clusters = mcodeUtil.sortClusters(clusters);
-                       imageList = new Image[clusters.length];
+                       mcodeUtil.sortClusters(clusters);
                        int imageSize = 
mcodeUtil.getCurrentParameters().getResultParams(resultId).getDefaultRowHeight();
+                       int count = 0;
 
-                       for (int i = 0; i < clusters.length; i++) {
-                               if (interrupted) {
-                                       return;
-                               }
-
-                               imageList[i] = 
mcodeUtil.createClusterImage(clusters[i], imageSize, imageSize, null, true, 
null);
-                               taskMonitor.setProgress((i+1) / (double) 
clusters.length);
+                       for (final MCODECluster c : clusters) {
+                               if (interrupted) return;
+                               
+                               final Image img = 
mcodeUtil.createClusterImage(c, imageSize, imageSize, null, true, null);
+                               c.setImage(img);
+                               taskMonitor.setProgress((++count) / (double) 
clusters.size());
                        }
 
                        success = true;
@@ -152,7 +152,7 @@
                        mcodeUtil.destroyUnusedNetworks(network, clusters);
                        
                        if (listener != null) {
-                               listener.handleEvent(new 
AnalysisCompletedEvent(success, clusters, imageList));
+                               listener.handleEvent(new 
AnalysisCompletedEvent(success, clusters));
                        }
                }
        }

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
 2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
 2012-11-09 18:43:21 UTC (rev 30767)
@@ -38,10 +38,12 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -220,10 +222,10 @@
                createdSubNetworks = new HashMap<CyRootNetwork, 
Set<CySubNetwork>>();
        }       
        
-       public synchronized void destroyUnusedNetworks(final CyNetwork network, 
final MCODECluster[] clusters) {
+       public synchronized void destroyUnusedNetworks(final CyNetwork network, 
final List<MCODECluster> clusters) {
                final Map<CySubNetwork, Boolean> clusterNetworks = new 
HashMap<CySubNetwork, Boolean>();
                
-               if (clusters != null && clusters.length > 0) {
+               if (clusters != null) {
                        for (MCODECluster c : clusters)
                                clusterNetworks.put(c.getNetwork(), 
Boolean.TRUE);
                }
@@ -733,28 +735,23 @@
        }
 
        /**
-        * Converts a list of MCODE generated clusters to a list of networks 
that is sorted by the score of the cluster
+        * Sorts a list of MCODE generated clusters by the score.
         *
         * @param clusters   List of MCODE generated clusters
-        * @return A sorted array of cluster objects based on cluster score.
         */
-       public MCODECluster[] sortClusters(MCODECluster[] clusters) {
-               Arrays.sort(clusters, new Comparator<MCODECluster>() {
-
-                       //sorting clusters by decreasing score
+       public void sortClusters(final List<MCODECluster> clusters) {
+               Collections.sort(clusters, new Comparator<MCODECluster>() {
+                       @Override
                        public int compare(MCODECluster c1, MCODECluster c2) {
+                               //sorting clusters by decreasing score
                                double d1 = c1.getScore();
                                double d2 = c2.getScore();
-                               if (d1 == d2) {
-                                       return 0;
-                               } else if (d1 < d2) {
-                                       return 1;
-                               } else {
-                                       return -1;
-                               }
+                               
+                               if (d1 == d2)     return 0;
+                               else if (d1 < d2) return 1;
+                               return -1;
                        }
                });
-               return clusters;
        }
 
        /**
@@ -792,7 +789,7 @@
         * @param fileName  The file name to write to
         * @return True if the file was written, false otherwise
         */
-       public boolean exportMCODEResults(MCODEAlgorithm alg, MCODECluster[] 
clusters, CyNetwork network) {
+       public boolean exportMCODEResults(final MCODEAlgorithm alg, final 
List<MCODECluster> clusters, CyNetwork network) {
                if (alg == null || clusters == null || network == null) {
                        return false;
                }
@@ -822,12 +819,13 @@
 
                                // Get sub-networks for all clusters, score and 
rank them
                                // convert the ArrayList to an array of 
CyNetworks and sort it by cluster score
-                               for (int i = 0; i < clusters.length; i++) {
-                                       CyNetwork clusterNetwork = 
clusters[i].getNetwork();
+                               for (int i = 0; i < clusters.size(); i++) {
+                                       final MCODECluster c = clusters.get(i);
+                                       final CyNetwork clusterNetwork = 
c.getNetwork();
                                        fout.write((i + 1) + "\t"); //rank
                                        NumberFormat nf = 
NumberFormat.getInstance();
                                        nf.setMaximumFractionDigits(3);
-                                       
fout.write(nf.format(clusters[i].getScore()) + "\t");
+                                       fout.write(nf.format(c.getScore()) + 
"\t");
                                        // cluster size - format: (# prot, # 
intx)
                                        
fout.write(clusterNetwork.getNodeCount() + "\t");
                                        
fout.write(clusterNetwork.getEdgeCount() + "\t");

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
 2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
 2012-11-09 18:43:21 UTC (rev 30767)
@@ -19,6 +19,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Dictionary;
 import java.util.HashMap;
@@ -129,12 +130,12 @@
        private static final int graphPicSize = 80;
        private static final int defaultRowHeight = graphPicSize + 8;
        
-       private int resultId;
-       private MCODEAlgorithm alg;
-       private MCODECluster[] clusters;
+       private final int resultId;
+       private final MCODEAlgorithm alg;
+       private final List<MCODECluster> clusters;
        
        // Actual cluster data
-       private CyNetwork network; // Keep a record of the original input 
record for use in
+       private final CyNetwork network; // Keep a record of the original input 
record for use in
        // the table row selection listener
        private CyNetworkView networkView; // Keep a record of this too, if it 
exists
        private MCODECollapsiblePanel explorePanel;
@@ -163,12 +164,11 @@
         * @param clusterImages A list of images of the found clusters
         * @param resultId Title of this result as determined by 
MCODESCoreAndFindAction
         */
-       public MCODEResultsPanel(final MCODECluster[] clusters,
+       public MCODEResultsPanel(final List<MCODECluster> clusters,
                                                         final MCODEAlgorithm 
alg,
                                                         final MCODEUtil 
mcodeUtil,
                                                         final CyNetwork 
network,
                                                         final CyNetworkView 
networkView,
-                                                        final Image[] 
clusterImages,
                                                         final int resultId,
                                                         final 
MCODEDiscardResultAction discardResultAction) {
                setLayout(new BorderLayout());
@@ -176,14 +176,14 @@
                this.alg = alg;
                this.mcodeUtil = mcodeUtil;
                this.resultId = resultId;
-               this.clusters = clusters;
+               this.clusters = Collections.synchronizedList(clusters);
                this.network = network;
                // The view may not exist, but we only test for that when we 
need to (in the TableRowSelectionHandler below)
                this.networkView = networkView;
                this.discardResultAction = discardResultAction;
                this.currentParamsCopy = 
mcodeUtil.getCurrentParameters().getResultParams(resultId);
                
-               this.clusterBrowserPanel = new 
MCODEClusterBrowserPanel(clusterImages);
+               this.clusterBrowserPanel = new MCODEClusterBrowserPanel();
                add(clusterBrowserPanel, BorderLayout.CENTER);
                add(createBottomPanel(), BorderLayout.SOUTH);
 
@@ -219,7 +219,7 @@
                return networkView;
        }
        
-       public MCODECluster[] getClusters() {
+       public List<MCODECluster> getClusters() {
                return clusters;
        }
 
@@ -418,9 +418,7 @@
                        nodeRow.set(NODE_STATUS_ATTR, "Unclustered");
                        nodeRow.set(SCORE_ATTR, alg.getNodeScore(n.getSUID(), 
resultId));
 
-                       for (int c = 0; c < clusters.length; c++) {
-                               MCODECluster cluster = clusters[c];
-                               
+                       for (final MCODECluster cluster : clusters) {
                                if (cluster.getALCluster().contains(rgi)) {
                                        Set<String> clusterNameSet = new 
LinkedHashSet<String>();
 
@@ -481,7 +479,7 @@
                public void actionPerformed(final ActionEvent evt) {
                        final NumberFormat nf = NumberFormat.getInstance();
                        nf.setMaximumFractionDigits(3);
-                       final MCODECluster cluster = clusters[selectedRow];
+                       final MCODECluster cluster = clusters.get(selectedRow);
                        final CyNetwork clusterNetwork = cluster.getNetwork();
                        final String title = trigger.getResultId() + ": " + 
cluster.getName() + " (Score: " +
                                                                 
nf.format(cluster.getScore()) + ")";
@@ -559,13 +557,13 @@
                private final MCODEResultsPanel.MCODEClusterBrowserTableModel 
browserModel;
                private final JTable table;
                
-               public MCODEClusterBrowserPanel(final Image[] images) {
+               public MCODEClusterBrowserPanel() {
                        super();
                        setLayout(new BorderLayout());
                        setBorder(BorderFactory.createTitledBorder("Cluster 
Browser"));
 
                        // main data table
-                       browserModel = new 
MCODEResultsPanel.MCODEClusterBrowserTableModel(images);
+                       browserModel = new 
MCODEResultsPanel.MCODEClusterBrowserTableModel();
 
                        table = new JTable(browserModel);
                        
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
@@ -609,17 +607,18 @@
                private final String[] columnNames = { "Network", "Details" };
                private final Object[][] data; // the actual table data
 
-               public MCODEClusterBrowserTableModel(Image[] imageList) {
-                       exploreContent = new JPanel[clusters.length];
-                       data = new Object[clusters.length][columnNames.length];
+               public MCODEClusterBrowserTableModel() {
+                       exploreContent = new JPanel[clusters.size()];
+                       data = new Object[clusters.size()][columnNames.length];
 
-                       for (int i = 0; i < clusters.length; i++) {
-                               clusters[i].setRank(i);
-                               StringBuffer details = 
getClusterDetails(clusters[i]);
+                       for (int i = 0; i < clusters.size(); i++) {
+                               final MCODECluster c = clusters.get(i);
+                               c.setRank(i);
+                               StringBuffer details = getClusterDetails(c);
                                data[i][1] = new StringBuffer(details);
 
                                // get an image for each cluster - make it a 
nice layout of the cluster
-                               final Image image = imageList[i];
+                               final Image image = c.getImage();
                                data[i][0] = image != null ? new 
ImageIcon(image) : new ImageIcon();
                        }
                }
@@ -796,7 +795,7 @@
 
                        // If its the generic 'please select' option then we 
don't do any enumeration
                        if (!attributeName.equals("Please Select")) {
-                               final CyNetwork net = 
clusters[selectedRow].getNetwork();
+                               final CyNetwork net = 
clusters.get(selectedRow).getNetwork();
                                
                                // Otherwise, we want to get the selected 
attribute's value for each node in the selected cluster
                                for (CyNode node : net.getNodeList()) {
@@ -869,7 +868,8 @@
 
                        if (!lsm.isSelectionEmpty()) {
                                final int selectedRow = 
lsm.getMinSelectionIndex();
-                               gpCluster = clusters[selectedRow].getNetwork();
+                               final MCODECluster c = 
clusters.get(selectedRow);
+                               gpCluster = c.getNetwork();
                                selectCluster(gpCluster);
 
                                // Upon selection of a cluster, we must show 
the corresponding explore panel content
@@ -901,8 +901,8 @@
                                // event to display the new content with the 
name of the cluster, if it exists
                                String title = "Explore: ";
 
-                               if (clusters[selectedRow].getName() != null) {
-                                       title = title + 
clusters[selectedRow].getName();
+                               if (c.getName() != null) {
+                                       title = title + c.getName();
                                } else {
                                        title = title + "Cluster " + 
(selectedRow + 1);
                                }
@@ -1053,13 +1053,13 @@
                        final double nodeScoreCutoff = (((double) 
source.getValue()) / 1000);
                        final int clusterRow = selectedRow;
                        // Store current cluster content for comparison
-               final MCODECluster oldCluster = clusters[clusterRow];
+               final MCODECluster oldCluster = clusters.get(clusterRow);
                        
                        if (futureLoader != null && !futureLoader.isDone()) {
                                drawer.stop();
                                futureLoader.cancel(false);
                                
-                               if (!oldCluster.equals(clusters[clusterRow]))
+                               if 
(!oldCluster.equals(clusters.get(clusterRow)))
                                        oldCluster.dispose();
                        }
                        
@@ -1082,7 +1082,7 @@
                                        if (!newALCluster.equals(oldALCluster)) 
{ // TODO
                                                // If the cluster has changed, 
then we conduct all non-rate-limiting steps:
                                                // Update the cluster array
-                                               clusters[clusterRow] = 
newCluster;
+                                               clusters.set(clusterRow, 
newCluster);
                                                // Update the cluster details
                                                
clusterBrowserPanel.update(newCluster, clusterRow);
                                                // Fire the enumeration action
@@ -1186,6 +1186,7 @@
                                                        loader.setProgress(100, 
"Selecting Nodes");
                                                        
selectCluster(cluster.getNetwork());
                                                        clusterSelected = true;
+                                                       cluster.setImage(image);
                                                        // Update the table
                                                        
clusterBrowserPanel.update(new ImageIcon(image), cluster.getRank());
                                                        drawGraph = false;
@@ -1196,6 +1197,7 @@
                                        } else if (drawPlaceHolder && 
!placeHolderDrawn) {
                                                // draw place holder, only once 
though (as per the if statement)
                                                Image image = 
mcodeUtil.getPlaceHolderImage(graphPicSize, graphPicSize);
+                                               cluster.setImage(image);
                                                // Update the table
                                                clusterBrowserPanel.update(new 
ImageIcon(image), cluster.getRank());
                                                // select the cluster

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/AbstractMCODETest.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/AbstractMCODETest.java
      2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/AbstractMCODETest.java
      2012-11-09 18:43:21 UTC (rev 30767)
@@ -22,11 +22,11 @@
                netViewTestSupport = new NetworkViewTestSupport();
        }
 
-       protected MCODECluster[] findClusters(CyNetwork net, int resultId) {
+       protected List<MCODECluster> findClusters(final CyNetwork net, final 
int resultId) {
                return findClusters(net, resultId, new MCODEParameterSet());
        }
 
-       protected MCODECluster[] findClusters(CyNetwork net, int resultId, 
MCODEParameterSet params) {
+       protected List<MCODECluster> findClusters(CyNetwork net, int resultId, 
MCODEParameterSet params) {
                mcodeUtil.getCurrentParameters().setParams(params, resultId, 
net.getSUID());
                alg = new MCODEAlgorithm(net.getSUID(), mcodeUtil);
                alg.scoreGraph(net, resultId);

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/model/MCODEAlgorithmTest.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/model/MCODEAlgorithmTest.java
       2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/model/MCODEAlgorithmTest.java
       2012-11-09 18:43:21 UTC (rev 30767)
@@ -3,6 +3,8 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.util.List;
+
 import org.cytoscape.application.CyApplicationManager;
 import org.cytoscape.application.swing.CySwingApplication;
 import org.cytoscape.ding.NetworkViewTestSupport;
@@ -116,11 +118,11 @@
        public void testCompleteGraphWithDefaultParameters() {
                CyNetwork net = createCompleteGraph(16);
                int resultId = 1;
-               MCODECluster[] clusters = findClusters(net, resultId);
+               List<MCODECluster> clusters = findClusters(net, resultId);
                
-               assertEquals(1, clusters.length);
+               assertEquals(1, clusters.size());
                
-               MCODECluster c = clusters[0];
+               MCODECluster c = clusters.get(0);
                CySubNetwork cn = c.getNetwork();
                
                assertNotNull(cn);
@@ -143,11 +145,11 @@
                MCODEParameterSet params = new MCODEParameterSet();
                params.setIncludeLoops(true);
                
-               MCODECluster[] clusters = findClusters(net, resultId, params);
+               List<MCODECluster> clusters = findClusters(net, resultId, 
params);
                
-               assertEquals(1, clusters.length);
+               assertEquals(1, clusters.size());
                
-               MCODECluster c = clusters[0];
+               MCODECluster c = clusters.get(0);
                CySubNetwork cn = c.getNetwork();
                
                assertNotNull(cn);

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/util/MCODEUtilTest.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/util/MCODEUtilTest.java
     2012-11-09 00:27:05 UTC (rev 30766)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/test/java/org/cytoscape/mcode/internal/util/MCODEUtilTest.java
     2012-11-09 18:43:21 UTC (rev 30767)
@@ -2,6 +2,8 @@
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.List;
+
 import org.cytoscape.application.CyApplicationManager;
 import org.cytoscape.application.swing.CySwingApplication;
 import org.cytoscape.event.CyEventHelper;
@@ -95,11 +97,11 @@
                final CyRootNetwork rn = 
netViewTestSupport.getRootNetworkFactory().getRootNetwork(net);
                int originalNetCount = rn.getSubNetworkList().size(); 
                int resultId = 1;
-               MCODECluster[] clusters = findClusters(net, resultId);
-               assertEquals(1, clusters.length);
+               List<MCODECluster> clusters = findClusters(net, resultId);
+               assertEquals(1, clusters.size());
                
                mcodeUtil.destroyUnusedNetworks(net, clusters);
                
-               assertEquals(originalNetCount + clusters.length, 
rn.getSubNetworkList().size());
+               assertEquals(originalNetCount + clusters.size(), 
rn.getSubNetworkList().size());
        }
 }

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