refactoring (added seqIndex/resIndex state for incremental search)
[jalview.git] / src / jalview / analysis / Finder.java
index f3ec514..e24a6c0 100644 (file)
@@ -14,10 +14,21 @@ public class Finder {
     boolean caseSensitive=false;
     boolean findAll=false;
     com.stevesoft.pat.Regex regex=null;
+    /**
+     * hold's last-searched position between calles to find(false)
+     */
+    int seqIndex=0,resIndex=0;
     public Finder(AlignmentI alignment, SequenceGroup selection) {
         this.alignment=alignment;
         this.selection = selection;
     }
+    
+    public Finder(AlignmentI alignment, SequenceGroup selectionGroup, int seqIndex, int resIndex) {
+        this(alignment, selectionGroup);
+        this.seqIndex=seqIndex;
+        this.resIndex=resIndex;
+    }
+
     public boolean find(String searchString) {
         boolean hasResults=false;
         if(!caseSensitive)
@@ -26,7 +37,6 @@ public class Finder {
         searchResults = new SearchResults();
         idMatch = new Vector();
         Sequence seq;
-        int seqIndex=0,resIndex=0;
         String item = null;
         boolean found = false;
 
@@ -232,4 +242,32 @@ public class Finder {
     public SearchResults getSearchResults() {
         return searchResults;
     }
+
+    /**
+     * @return the resIndex
+     */
+    public int getResIndex() {
+        return resIndex;
+    }
+
+    /**
+     * @param resIndex the resIndex to set
+     */
+    public void setResIndex(int resIndex) {
+        this.resIndex = resIndex;
+    }
+
+    /**
+     * @return the seqIndex
+     */
+    public int getSeqIndex() {
+        return seqIndex;
+    }
+
+    /**
+     * @param seqIndex the seqIndex to set
+     */
+    public void setSeqIndex(int seqIndex) {
+        this.seqIndex = seqIndex;
+    }
 }