X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSearchResults.java;h=f8e1c5af7a3794d2a847cac4c951f37e0213e646;hb=ed3ef4a5d351592f978b6d7e793e70de6ad247ca;hp=c29b0e7218489f9c4a19a9da5394cba7767e471c;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index c29b0e7..f8e1c5a 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,29 +21,31 @@ package jalview.datamodel; public class SearchResults { - Match [] matches; + Match[] matches; - /** - * This method replaces the old search results which merely - * held an alignment index of search matches. This broke - * when sequences were moved around the alignment - * @param seq Sequence - * @param start int - * @param end int - */ + /** + * This method replaces the old search results which merely + * held an alignment index of search matches. This broke + * when sequences were moved around the alignment + * @param seq Sequence + * @param start int + * @param end int + */ public void addResult(SequenceI seq, int start, int end) { - if(matches == null) + if (matches == null) { - matches = new Match[]{new Match(seq, start, end)}; + matches = new Match[] + { + new Match(seq, start, end)}; return; } int mSize = matches.length; - Match [] tmp = new Match[mSize+1]; + Match[] tmp = new Match[mSize + 1]; int m; - for(m=0; m=start) + if (matchStart <= end && matchEnd >= start) { - if(matchStartend) + if (matchEnd > end) + { matchEnd = end; + } - - if(result==null) - result = new int[]{matchStart, matchEnd}; + if (result == null) + { + result = new int[] + { + matchStart, matchEnd}; + } else { resultLength = result.length; - tmp = new int[resultLength+2]; - System.arraycopy(result,0,tmp,0,resultLength); + tmp = new int[resultLength + 2]; + System.arraycopy(result, 0, tmp, 0, resultLength); result = tmp; result[resultLength] = matchStart; - result[resultLength+1] = matchEnd; + result[resultLength + 1] = matchEnd; } } } @@ -102,17 +113,23 @@ public class SearchResults public int getSize() { - return matches==null ? 0 : matches.length; + return matches == null ? 0 : matches.length; } public SequenceI getResultSequence(int index) - { return matches[index].sequence; } + { + return matches[index].sequence; + } public int getResultStart(int index) - { return matches[index].start; } + { + return matches[index].start; + } public int getResultEnd(int index) - { return matches[index].end; } + { + return matches[index].end; + } class Match { @@ -122,9 +139,9 @@ public class SearchResults public Match(SequenceI seq, int start, int end) { - sequence = seq; - this.start = start; - this.end = end; + sequence = seq; + this.start = start; + this.end = end; } } }