-public class Finder {
- /**
- * Implements the search algorithms for the Find dialog box.
- */
- SearchResults searchResults;
- AlignmentI alignment;
- jalview.datamodel.SequenceGroup selection=null;
- Vector idMatch=null;
- boolean caseSensitive=false;
- boolean findAll=false;
- com.stevesoft.pat.Regex regex=null;
- public Finder(AlignmentI alignment, SequenceGroup selection) {
- this.alignment=alignment;
- this.selection = selection;
+public class Finder
+{
+ /**
+ * Implements the search algorithms for the Find dialog box.
+ */
+ SearchResults searchResults;
+
+ AlignmentI alignment;
+
+ jalview.datamodel.SequenceGroup selection = null;
+
+ Vector idMatch = null;
+
+ 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 = -1;
+
+ public Finder(AlignmentI alignment, SequenceGroup selection)
+ {
+ this.alignment = alignment;
+ this.selection = selection;
+ }
+
+ /**
+ * restart search at given sequence and residue on alignment and (optionally)
+ * contained in selection
+ *
+ * @param alignment
+ * @param selectionGroup
+ * @param seqIndex
+ * @param resIndex
+ */
+ 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)
+ {
+ searchString = searchString.toUpperCase();
+ }
+ regex = new com.stevesoft.pat.Regex(searchString);
+ regex.setIgnoreCase(!caseSensitive);
+ searchResults = new SearchResults();
+ idMatch = new Vector();
+ Sequence seq;
+ String item = null;
+ boolean found = false;
+ int end = alignment.getHeight();
+
+ // /////////////////////////////////////////////
+
+ if (selection != null)
+ {
+ if ((selection.getSize() < 1)
+ || ((selection.getEndRes() - selection.getStartRes()) < 2))
+ {
+ selection = null;
+ }