JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / datamodel / Alignment.java
index c4098e2..98510e3 100755 (executable)
@@ -47,7 +47,7 @@ import java.util.Vector;
  * @author JimP
  * 
  */
-public class Alignment implements AlignmentI, AutoCloseable
+public class Alignment implements AlignmentI
 {
   private Alignment dataset;
 
@@ -125,8 +125,7 @@ public class Alignment implements AlignmentI, AutoCloseable
   /**
    * Make a new alignment from an array of SeqCigars
    * 
-   * @param seqs
-   *          SeqCigar[]
+   * @param alseqs
    */
   public Alignment(SeqCigar[] alseqs)
   {
@@ -303,20 +302,15 @@ public class Alignment implements AlignmentI, AutoCloseable
   }
 
   @Override
-  public void close()
+  public void finalize() throws Throwable
   {
     if (getDataset() != null)
     {
-      try
-      {
-        getDataset().removeAlignmentRef();
-      } catch (Throwable e)
-      {
-        e.printStackTrace();
-      }
+      getDataset().removeAlignmentRef();
     }
 
     nullReferences();
+    super.finalize();
   }
 
   /**
@@ -404,6 +398,10 @@ public class Alignment implements AlignmentI, AutoCloseable
     return null;
   }
 
+  private static final SequenceGroup[] noGroups = new SequenceGroup[0];
+
+  private ArrayList<SequenceGroup> temp = new ArrayList<>();
+
   /*
    * (non-Javadoc)
    * 
@@ -413,11 +411,15 @@ public class Alignment implements AlignmentI, AutoCloseable
   @Override
   public SequenceGroup[] findAllGroups(SequenceI s)
   {
-    ArrayList<SequenceGroup> temp = new ArrayList<>();
 
     synchronized (groups)
     {
       int gSize = groups.size();
+      if (gSize == 0)
+      {
+        return noGroups;
+      }
+      temp.clear();
       for (int i = 0; i < gSize; i++)
       {
         SequenceGroup sg = groups.get(i);
@@ -2032,4 +2034,17 @@ public class Alignment implements AlignmentI, AutoCloseable
     }
   }
 
+  @Override
+  public void resetColors()
+  {
+    for (int i = getHeight(); --i >= 0;)
+    {
+      sequences.get(i).resetColors();
+    }
+    // if (dataset != null)
+    // {
+    // dataset.resetColors();
+    // }
+  }
+
 }