X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FFinder.java;fp=src%2Fjalview%2Fanalysis%2FFinder.java;h=3cbef6d89175201f0f9029cf3dfca2260bf0295c;hb=9b5106c49c8fa0a7269f38ad1825851eb8ba5b85;hp=0996830bf806ef4fcb7aadc31ce04a81138f8298;hpb=24de2d6a6f3db1b9d55f367e2bf8ba112e202a8a;p=jalview.git diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 0996830..3cbef6d 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -20,6 +20,7 @@ */ package jalview.analysis; +import jalview.api.AlignViewportI; import jalview.api.FinderI; import jalview.datamodel.AlignmentI; import jalview.datamodel.Range; @@ -52,14 +53,9 @@ public class Finder implements FinderI private Vector idMatches; /* - * the alignment to search over + * the viewport to search over */ - private AlignmentI alignment; - - /* - * (optional) selection to restrict search to - */ - private SequenceGroup selection; + private AlignViewportI viewport; /* * sequence index in alignment to search from @@ -74,20 +70,20 @@ public class Finder implements FinderI private int columnIndex; /** - * Constructor for searching an alignment + * Constructor for searching a viewport * - * @param al + * @param av */ - public Finder(AlignmentI al) + public Finder(AlignViewportI av) { - this.alignment = al; + this.viewport = av; this.sequenceIndex = 0; this.columnIndex = -1; } @Override - public void findAll(String theSearchString, SequenceGroup sg, - boolean matchCase, boolean searchDescription) + public void findAll(String theSearchString, boolean matchCase, + boolean searchDescription) { /* * search from the start @@ -95,7 +91,7 @@ public class Finder implements FinderI sequenceIndex = 0; columnIndex = -1; - doFind(theSearchString, sg, matchCase, searchDescription, true); + doFind(theSearchString, matchCase, searchDescription, true); /* * reset to start for next search @@ -105,10 +101,10 @@ public class Finder implements FinderI } @Override - public void findNext(String theSearchString, SequenceGroup sg, - boolean matchCase, boolean searchDescription) + public void findNext(String theSearchString, boolean matchCase, + boolean searchDescription) { - doFind(theSearchString, sg, matchCase, searchDescription, false); + doFind(theSearchString, matchCase, searchDescription, false); if (searchResults.isEmpty() && idMatches.isEmpty()) { @@ -121,19 +117,16 @@ public class Finder implements FinderI } /** - * Performs a 'find next' or 'find all', optionally restricted to the - * specified selection region + * Performs a 'find next' or 'find all' * * @param theSearchString - * @param selectionRegion * @param matchCase * @param searchDescription * @param findAll */ - protected void doFind(String theSearchString, SequenceGroup selectionRegion, - boolean matchCase, boolean searchDescription, boolean findAll) + protected void doFind(String theSearchString, boolean matchCase, + boolean searchDescription, boolean findAll) { - this.selection = selectionRegion; String searchString = matchCase ? theSearchString : theSearchString.toUpperCase(); Regex searchPattern = new Regex(searchString); @@ -142,11 +135,13 @@ public class Finder implements FinderI searchResults = new SearchResults(); idMatches = new Vector<>(); + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null && selection.getSize() < 1) { selection = null; // ? ignore column-only selection } + AlignmentI alignment = viewport.getAlignment(); int end = alignment.getHeight(); while (sequenceIndex < end) @@ -184,6 +179,7 @@ public class Finder implements FinderI * restrict search to (next) visible column region, * in case there are hidden columns */ + AlignmentI alignment = viewport.getAlignment(); VisibleContigsIterator visibleRegions = alignment.getHiddenColumns() .getVisContigsIterator(column, alignment.getWidth(), false); @@ -199,6 +195,7 @@ public class Finder implements FinderI /* * restrict search to selected region if there is one */ + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null) { int selectionStart = selection.getStartRes(); @@ -233,6 +230,7 @@ public class Finder implements FinderI protected boolean findNextMatch(SequenceI seq, String searchString, Regex searchPattern, boolean matchDescription) { + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null && !selection.contains(seq)) { /*