+ updateViewport();
+ fastpainting = true;
+ fastPaint = true;
+
+ /*
+ * calculate the minimal rectangle to draw that includes
+ * both the new and any existing search results
+ */
+ SearchResultsI previous = av.getSearchResults();
+ int firstSeq = Integer.MAX_VALUE;
+ int lastSeq = -1;
+ int firstCol = Integer.MAX_VALUE;
+ int lastCol = -1;
+ boolean matchFound = false;
+
+ ViewportRanges ranges = av.getRanges();
+ for (int seqNo = ranges.getStartSeq(); seqNo <= ranges
+ .getEndSeq(); seqNo++)
+ {
+ SequenceI seq = av.getAlignment().getSequenceAt(seqNo);
+ if (previous != null)
+ {
+ /*
+ * find the bounding rectangle enclosing last search results
+ */
+ int[] visibleResults = previous.getResults(seq,
+ ranges.getStartRes(), ranges.getEndRes());
+ if (visibleResults != null)
+ {
+ int firstMatchedColumn = visibleResults[0];
+ int lastMatchedColumn = visibleResults[visibleResults.length - 1];
+ if (firstMatchedColumn <= ranges.getEndRes()
+ && lastMatchedColumn >= ranges.getStartRes())
+ {
+ /*
+ * a previous search results match in the visible region
+ * remember the first and last sequence matched, and the first
+ * and last visible columns in the matched positions
+ */
+ matchFound = true;
+ firstSeq = Math.min(firstSeq, seqNo);
+ lastSeq = Math.max(lastSeq, seqNo);
+ firstMatchedColumn = Math.max(firstMatchedColumn,
+ ranges.getStartRes());
+ lastMatchedColumn = Math.min(lastMatchedColumn,
+ ranges.getEndRes());
+ firstCol = Math.min(firstCol, firstMatchedColumn);
+ lastCol = Math.max(lastCol, lastMatchedColumn);
+ }
+ }
+ }
+
+ /*
+ * and repeat for the new search results
+ */
+ int[] visibleResults = results.getResults(seq, ranges.getStartRes(),
+ ranges.getEndRes());
+ if (visibleResults != null)
+ {
+ int firstMatchedColumn = visibleResults[0];
+ int lastMatchedColumn = visibleResults[visibleResults.length - 1];
+ if (firstMatchedColumn <= ranges.getEndRes()
+ && lastMatchedColumn >= ranges.getStartRes())
+ {
+ matchFound = true;
+ firstSeq = Math.min(firstSeq, seqNo);
+ lastSeq = Math.max(lastSeq, seqNo);
+ firstMatchedColumn = Math.max(firstMatchedColumn,
+ ranges.getStartRes());
+ lastMatchedColumn = Math.min(lastMatchedColumn,
+ ranges.getEndRes());
+ firstCol = Math.min(firstCol, firstMatchedColumn);
+ lastCol = Math.max(lastCol, lastMatchedColumn);
+ }
+ }
+ }