import javax.swing.*;\r
import javax.swing.event.*;\r
import java.util.*;\r
-\r
+import java.util.regex.*;\r
\r
public class Finder extends GFinder\r
{\r
\r
item = seq.getSequence();\r
\r
+ Pattern pattern = Pattern.compile(searchString);\r
+ Matcher matcher = pattern.matcher(item);\r
+\r
for(int r = resIndex; r<item.length(); r++)\r
{\r
- if(item.indexOf(searchString,r)>-1)\r
+\r
+ if( matcher.find( r ) )\r
{\r
- resIndex = item.indexOf(searchString,r);\r
+ resIndex = matcher.start();\r
\r
- searchResults.add( Integer.toString(seqIndex) );\r
+ searchResults.add( Integer.toString( seqIndex) );\r
searchResults.add( Integer.toString( resIndex) );\r
- searchResults.add( Integer.toString( (resIndex+searchString.length()-1) ) );\r
+ searchResults.add( Integer.toString( matcher.end()-1 ) );\r
if(!findAll)\r
{\r
// thats enough, break and display the result\r
\r
if(searchResults.size()>0)\r
{\r
-\r
allResults = new int[searchResults.size()];\r
for(int i=0; i<searchResults.size(); i++)\r
allResults[i] = Integer.parseInt(searchResults.get(i).toString());\r
\r
- if (findAll)\r
- {\r
- String message = (searchResults.size()/3) + " matches found.";\r
- JOptionPane.showInternalMessageDialog(this, message, null,\r
- JOptionPane.INFORMATION_MESSAGE);\r
- }\r
-\r
-\r
}\r
else\r
{\r
// if allResults is null, this effectively switches displaySearch flag in seqCanvas\r
ap.highlightSearchResults( allResults );\r
\r
+ if (findAll)\r
+ {\r
+ String message = (searchResults.size()/3) + " matches found.";\r
+ JOptionPane.showInternalMessageDialog(this, message, null,\r
+ JOptionPane.INFORMATION_MESSAGE);\r
+ }\r
\r
}\r
\r