applied 2009 GPL license
[jalview.git] / src / jalview / datamodel / SearchResults.java
index c5f8e6f..7350c12 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -24,20 +24,23 @@ public class SearchResults
   Match[] matches;
 
   /**
-   * This method replaces the old search results which merely
-   * held an alignment index of search matches. This broke
-   * when sequences were moved around the alignment
-   * @param seq Sequence
-   * @param start int
-   * @param end int
+   * This method replaces the old search results which merely held an alignment
+   * index of search matches. This broke when sequences were moved around the
+   * alignment
+   * 
+   * @param seq
+   *                Sequence
+   * @param start
+   *                int
+   * @param end
+   *                int
    */
   public void addResult(SequenceI seq, int start, int end)
   {
     if (matches == null)
     {
       matches = new Match[]
-          {
-          new Match(seq, start, end)};
+      { new Match(seq, start, end) };
       return;
     }
 
@@ -56,9 +59,9 @@ public class SearchResults
   }
 
   /**
-   * This Method returns the search matches which lie between the
-   * start and end points of the sequence in question. It is
-   * optimised for returning objects for drawing on SequenceCanvas
+   * This Method returns the search matches which lie between the start and end
+   * points of the sequence in question. It is optimised for returning objects
+   * for drawing on SequenceCanvas
    */
   public int[] getResults(SequenceI sequence, int start, int end)
   {
@@ -69,25 +72,27 @@ public class SearchResults
 
     int[] result = null;
     int[] tmp = null;
-    int resultLength, matchStart=0, matchEnd=0;
+    int resultLength, matchStart = 0, matchEnd = 0;
     boolean mfound;
     for (int m = 0; m < matches.length; m++)
     {
-      mfound=false;
+      mfound = false;
       if (matches[m].sequence == sequence)
-        {
+      {
         mfound = true;
         // locate aligned position
         matchStart = sequence.findIndex(matches[m].start) - 1;
         matchEnd = sequence.findIndex(matches[m].end) - 1;
-        }
-      else if (matches[m].sequence == sequence.getDatasetSequence()) {
+      }
+      else if (matches[m].sequence == sequence.getDatasetSequence())
+      {
         mfound = true;
         // locate region in local context
         matchStart = sequence.findIndex(matches[m].start) - 1;
         matchEnd = sequence.findIndex(matches[m].end) - 1;
       }
-      if (mfound) {
+      if (mfound)
+      {
         if (matchStart <= end && matchEnd >= start)
         {
           if (matchStart < start)
@@ -103,8 +108,7 @@ public class SearchResults
           if (result == null)
           {
             result = new int[]
-                {
-                matchStart, matchEnd};
+            { matchStart, matchEnd };
           }
           else
           {
@@ -144,7 +148,9 @@ public class SearchResults
   class Match
   {
     SequenceI sequence;
+
     int start;
+
     int end;
 
     public Match(SequenceI seq, int start, int end)