2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.datamodel;
21 public class SearchResults
27 * This method replaces the old search results which merely
28 * held an alignment index of search matches. This broke
29 * when sequences were moved around the alignment
34 public void addResult(SequenceI seq, int start, int end)
38 matches = new Match[]{new Match(seq, start, end)};
42 int mSize = matches.length;
44 Match [] tmp = new Match[mSize+1];
46 for(m=0; m<mSize; m++)
51 tmp[m] = new Match(seq, start, end);
57 * This Method returns the search matches which lie between the
58 * start and end points of the sequence in question. It is
59 * optimised for returning objects for drawing on SequenceCanvas
61 public int [] getResults(SequenceI sequence, int start, int end)
70 for(int m=0; m<matches.length; m++)
72 if( matches[m].sequence == sequence )
74 int matchStart = matches[m].sequence.findIndex( matches[m].start ) - 1;
75 int matchEnd = matches[m].sequence.findIndex( matches[m].end ) - 1;
77 if(matchStart<=end && matchEnd>=start)
87 result = new int[]{matchStart, matchEnd};
90 resultLength = result.length;
91 tmp = new int[resultLength+2];
92 System.arraycopy(result,0,tmp,0,resultLength);
94 result[resultLength] = matchStart;
95 result[resultLength+1] = matchEnd;
105 return matches==null ? 0 : matches.length;
108 public SequenceI getResultSequence(int index)
109 { return matches[index].sequence; }
111 public int getResultStart(int index)
112 { return matches[index].start; }
114 public int getResultEnd(int index)
115 { return matches[index].end; }
123 public Match(SequenceI seq, int start, int end)