Formatting
[jalview.git] / src / jalview / datamodel / SearchResults.java
index c29b0e7..f8e1c5a 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
@@ -21,29 +21,31 @@ package jalview.datamodel;
 public class SearchResults\r
 {\r
 \r
-  Match [] matches;\r
+  Match[] matches;\r
 \r
-    /**\r
-     * This method replaces the old search results which merely\r
-     * held an alignment index of search matches. This broke\r
-     * when sequences were moved around the alignment\r
-     * @param seq Sequence\r
-     * @param start int\r
-     * @param end int\r
-     */\r
+  /**\r
+   * This method replaces the old search results which merely\r
+   * held an alignment index of search matches. This broke\r
+   * when sequences were moved around the alignment\r
+   * @param seq Sequence\r
+   * @param start int\r
+   * @param end int\r
+   */\r
   public void addResult(SequenceI seq, int start, int end)\r
   {\r
-    if(matches == null)\r
+    if (matches == null)\r
     {\r
-      matches = new Match[]{new Match(seq, start, end)};\r
+      matches = new Match[]\r
+          {\r
+          new Match(seq, start, end)};\r
       return;\r
     }\r
 \r
     int mSize = matches.length;\r
 \r
-    Match [] tmp = new Match[mSize+1];\r
+    Match[] tmp = new Match[mSize + 1];\r
     int m;\r
-    for(m=0; m<mSize; m++)\r
+    for (m = 0; m < mSize; m++)\r
     {\r
       tmp[m] = matches[m];\r
     }\r
@@ -54,45 +56,54 @@ public class SearchResults
   }\r
 \r
   /**\r
-  * This Method returns the search matches which lie between the\r
-  * start and end points of the sequence in question. It is\r
-  * optimised for returning objects for drawing on SequenceCanvas\r
-  */\r
-  public int [] getResults(SequenceI sequence, int start, int end)\r
+   * This Method returns the search matches which lie between the\r
+   * start and end points of the sequence in question. It is\r
+   * optimised for returning objects for drawing on SequenceCanvas\r
+   */\r
+  public int[] getResults(SequenceI sequence, int start, int end)\r
   {\r
-    if(matches==null)\r
+    if (matches == null)\r
+    {\r
       return null;\r
+    }\r
 \r
-    int [] result = null;\r
-    int [] tmp = null;\r
+    int[] result = null;\r
+    int[] tmp = null;\r
     int resultLength;\r
 \r
-    for(int m=0; m<matches.length; m++)\r
+    for (int m = 0; m < matches.length; m++)\r
     {\r
-      if( matches[m].sequence == sequence )\r
+      if (matches[m].sequence == sequence)\r
       {\r
-        int matchStart = matches[m].sequence.findIndex( matches[m].start ) - 1;\r
-        int matchEnd = matches[m].sequence.findIndex( matches[m].end ) - 1;\r
+        int matchStart = matches[m].sequence.findIndex(matches[m].start) - 1;\r
+        int matchEnd = matches[m].sequence.findIndex(matches[m].end) - 1;\r
 \r
-        if(matchStart<=end && matchEnd>=start)\r
+        if (matchStart <= end && matchEnd >= start)\r
         {\r
-          if(matchStart<start)\r
+          if (matchStart < start)\r
+          {\r
             matchStart = start;\r
+          }\r
 \r
-          if(matchEnd>end)\r
+          if (matchEnd > end)\r
+          {\r
             matchEnd = end;\r
+          }\r
 \r
-\r
-          if(result==null)\r
-            result = new int[]{matchStart, matchEnd};\r
+          if (result == null)\r
+          {\r
+            result = new int[]\r
+                {\r
+                matchStart, matchEnd};\r
+          }\r
           else\r
           {\r
             resultLength = result.length;\r
-            tmp = new int[resultLength+2];\r
-            System.arraycopy(result,0,tmp,0,resultLength);\r
+            tmp = new int[resultLength + 2];\r
+            System.arraycopy(result, 0, tmp, 0, resultLength);\r
             result = tmp;\r
             result[resultLength] = matchStart;\r
-            result[resultLength+1] = matchEnd;\r
+            result[resultLength + 1] = matchEnd;\r
           }\r
         }\r
       }\r
@@ -102,17 +113,23 @@ public class SearchResults
 \r
   public int getSize()\r
   {\r
-    return matches==null ? 0 : matches.length;\r
+    return matches == null ? 0 : matches.length;\r
   }\r
 \r
   public SequenceI getResultSequence(int index)\r
-  {    return matches[index].sequence;  }\r
+  {\r
+    return matches[index].sequence;\r
+  }\r
 \r
   public int getResultStart(int index)\r
-  {    return matches[index].start;  }\r
+  {\r
+    return matches[index].start;\r
+  }\r
 \r
   public int getResultEnd(int index)\r
-  {    return matches[index].end;  }\r
+  {\r
+    return matches[index].end;\r
+  }\r
 \r
   class Match\r
   {\r
@@ -122,9 +139,9 @@ public class SearchResults
 \r
     public Match(SequenceI seq, int start, int end)\r
     {\r
-     sequence = seq;\r
-     this.start = start;\r
-     this.end = end;\r
+      sequence = seq;\r
+      this.start = start;\r
+      this.end = end;\r
     }\r
   }\r
 }\r