{\r
public void keyPressed(KeyEvent evt)\r
{\r
+ System.out.println(evt.getKeyCode());\r
switch(evt.getKeyCode())\r
{\r
case 27: // escape key\r
seqPanel.seqCanvas.highlightSearchResults( results );\r
\r
// do we need to scroll the panel?\r
- if(results!=null && (av.getStartSeq()>results[0]\r
- || av.getEndSeq()<results[0]\r
- || av.getStartRes()>results[1]\r
- || av.getEndRes()<results[2]))\r
- setScrollValues(results[1], results[0]);\r
-\r
+ if(results!=null)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
+ int start = seq.findIndex( results[1] )-1;\r
+ int end = seq.findIndex( results[2] )-1;\r
+ if( av.getStartRes() > start\r
+ || av.getEndRes() < end\r
+ || (av.getStartSeq() > results[0]\r
+ || av.getEndSeq() < results[0]))\r
+ setScrollValues(start, results[0]);\r
+ }\r
\r
}\r
\r
AlignmentPanel ap;\r
Frame frame;\r
SuperGroup searchGroup;\r
+ Vector searchResults;\r
\r
int seqIndex = 0;\r
int resIndex = 0;\r
\r
public void createNewGroup_actionPerformed(ActionEvent e)\r
{\r
- for(int i=0; i<searchGroup.getSize(); i++)\r
- av.alignment.addGroup( searchGroup.getGroupeAt(i));\r
+ jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();\r
+ Color [] newColors = new Color[24];\r
+ for(int i=0; i<24; i++)\r
+ newColors[i] = new Color(60,160,115);\r
+\r
+ ucs.setColourScheme(newColors);\r
+ String searchString = textfield.getText();\r
+\r
+ searchGroup = new SuperGroup(searchString, ucs , true, true, false);\r
+\r
+\r
+ for(int i=0; i<searchResults.size(); i+=3)\r
+ {\r
+ // its possible edits may have occurred since search was performed\r
+ // account for this here\r
+\r
+ SequenceI seq = av.alignment.getSequenceAt( Integer.parseInt(searchResults.elementAt(i).toString()) );\r
+ int startRes = seq.findIndex( Integer.parseInt(searchResults.elementAt(i+1).toString()) )-1;\r
+ int endRes = seq.findIndex( Integer.parseInt(searchResults.elementAt(i+2).toString()) )-1;\r
+\r
+ SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, false, startRes , endRes );\r
+ sg.addSequence(seq);\r
+ av.alignment.addGroup(sg);\r
+ searchGroup.addGroup( sg );\r
+\r
+ }\r
\r
ap.av.alignment.addSuperGroup(searchGroup);\r
ap.highlightSearchResults( null );\r
\r
com.stevesoft.pat.Regex regex = new com.stevesoft.pat.Regex(searchString);\r
\r
- Vector searchResults = new Vector();\r
+ searchResults = new Vector();\r
int [] allResults = null;\r
\r
Sequence seq;\r
///////////////////////////////////////////////\r
\r
\r
- jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();\r
- Color [] newColors = new Color[24];\r
- for(int i=0; i<24; i++)\r
- newColors[i] = new Color(60,160,115);\r
-\r
- ucs.setColourScheme(newColors);\r
-\r
- searchGroup = new SuperGroup(searchString, ucs , true, true, false);\r
-\r
int end = av.alignment.getHeight();\r
\r
SequenceGroup selection = av.getSelectionGroup();\r
continue;\r
\r
searchResults.addElement( Integer.toString( seqIndex) );\r
- searchResults.addElement( Integer.toString( resIndex+ Integer.parseInt(spaces.elementAt(resIndex).toString()) ) );\r
- searchResults.addElement( Integer.toString( regex.matchedTo()-1 + Integer.parseInt(spaces.elementAt(regex.matchedTo()-1).toString()) ) );\r
-\r
- SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, false,\r
- resIndex+ Integer.parseInt(spaces.elementAt(resIndex).toString()) ,\r
- regex.matchedTo()-1 + Integer.parseInt(spaces.elementAt(regex.matchedTo()-1).toString())\r
- );\r
- sg.addSequence((Sequence)av.getAlignment().getSequenceAt(seqIndex));\r
- searchGroup.addGroup( sg );\r
+ int sres = seq.findPosition( resIndex+ Integer.parseInt(spaces.elementAt(resIndex).toString()) );\r
+ int eres = seq.findPosition( regex.matchedTo()-1 + Integer.parseInt(spaces.elementAt(regex.matchedTo()-1).toString()) );\r
+ searchResults.addElement( sres+"" );\r
+ searchResults.addElement( eres+"" );\r
+\r
\r
if(!findAll)\r
{\r
for(int r=0; r<searchResults.length; r+=3)\r
{\r
int searchSeq = searchResults[r];\r
- int searchStart = searchResults[r+1];\r
- int searchEnd = searchResults[r+2];\r
\r
if (searchSeq >= y1 && searchSeq < y2)\r
{\r
+ SequenceI seq = av.getAlignment().getSequenceAt(searchSeq);\r
+\r
+ int searchStart = seq.findIndex( searchResults[r+1] )-1;\r
+ int searchEnd = seq.findIndex( searchResults[r+2] )-1;\r
+\r
SequenceRenderer ssr = (SequenceRenderer) sr;\r
if(searchStart<x1)\r
searchStart = x1;\r
if(searchEnd > x2)\r
searchEnd = x2;\r
- ssr.drawHighlightedText(av.getAlignment().getSequenceAt(searchSeq),\r
+\r
+ ssr.drawHighlightedText(seq,\r
searchStart,\r
searchEnd,\r
(searchStart - startx) * av.charWidth,\r
{\r
\r
if ( jalview.util.Comparison.isGap( av.alignment.getSequenceAt(seq).getSequence().charAt(j)))\r
- av.alignment.getSequenceAt(seq).deleteCharAt(j);\r
+ av.alignment.getSequenceAt(seq).deleteCharAt(j);\r
\r
av.alignment.getWidth();\r
- seqCanvas.repaint();\r
+ repaint();\r
seqEditOccurred=seq;\r
}\r
\r
seqPanel.seqCanvas.highlightSearchResults( results );\r
\r
// do we need to scroll the panel?\r
- if(results!=null && (av.getStartSeq()>results[0]\r
- || av.getEndSeq()<results[0]\r
- || av.getStartRes()>results[1]\r
- || av.getEndRes()<results[2]))\r
- setScrollValues(results[1], results[0]);\r
-\r
+ if(results!=null)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
+ int start = seq.findIndex( results[1] )-1;\r
+ int end = seq.findIndex( results[2] )-1;\r
+ if( av.getStartRes() > start\r
+ || av.getEndRes() < end\r
+ || (av.getStartSeq() > results[0]\r
+ || av.getEndSeq() < results[0]))\r
+ setScrollValues(start, results[0]);\r
+ }\r
\r
}\r
\r
AlignmentPanel ap;\r
JInternalFrame frame;\r
SuperGroup searchGroup;\r
+ Vector searchResults;\r
\r
int seqIndex = 0;\r
int resIndex = 0;\r
\r
public void createNewGroup_actionPerformed(ActionEvent e)\r
{\r
- for(int i=0; i<searchGroup.getSize(); i++)\r
- av.alignment.addGroup( searchGroup.getGroupeAt(i));\r
+ jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();\r
+ Color [] newColors = new Color[24];\r
+ for(int i=0; i<24; i++)\r
+ newColors[i] = new Color(60,160,115);\r
+\r
+ ucs.setColourScheme(newColors);\r
+ String searchString = textfield.getText();\r
+\r
+ searchGroup = new SuperGroup(searchString, ucs , true, true, false);\r
+\r
+\r
+ for(int i=0; i<searchResults.size(); i+=3)\r
+ {\r
+ // its possible edits may have occurred since search was performed\r
+ // account for this here\r
+\r
+ SequenceI seq = av.alignment.getSequenceAt( Integer.parseInt(searchResults.elementAt(i).toString()) );\r
+ int startRes = seq.findIndex( Integer.parseInt(searchResults.elementAt(i+1).toString()) )-1;\r
+ int endRes = seq.findIndex( Integer.parseInt(searchResults.elementAt(i+2).toString()) )-1;\r
+\r
+ SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, false, startRes , endRes );\r
+ sg.addSequence(seq);\r
+ av.alignment.addGroup(sg);\r
+ searchGroup.addGroup( sg );\r
+\r
+ }\r
\r
ap.av.alignment.addSuperGroup(searchGroup);\r
ap.highlightSearchResults( null );\r
\r
com.stevesoft.pat.Regex regex = new com.stevesoft.pat.Regex(searchString);\r
\r
- ArrayList searchResults = new ArrayList();\r
+ searchResults = new Vector();\r
int [] allResults = null;\r
\r
Sequence seq;\r
///Shall we ignore gaps????\r
StringBuffer noGaps = new StringBuffer();\r
int insertCount=0;\r
- ArrayList spaces = new ArrayList();\r
+ Vector spaces = new Vector();\r
\r
for (int j=0; j < item.length(); j++)\r
{\r
continue;\r
\r
searchResults.add( Integer.toString( seqIndex) );\r
- searchResults.add( Integer.toString( resIndex+ Integer.parseInt(spaces.get(resIndex).toString()) ) );\r
- searchResults.add( Integer.toString( regex.matchedTo()-1 + Integer.parseInt(spaces.get(regex.matchedTo()-1).toString()) ) );\r
\r
- SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, false,\r
- resIndex+ Integer.parseInt(spaces.get(resIndex).toString()) ,\r
- regex.matchedTo()-1 + Integer.parseInt(spaces.get(regex.matchedTo()-1).toString())\r
- );\r
- sg.addSequence((Sequence)av.getAlignment().getSequenceAt(seqIndex));\r
- searchGroup.addGroup( sg );\r
+ int sres = seq.findPosition( resIndex+ Integer.parseInt(spaces.elementAt(resIndex).toString()) );\r
+ int eres = seq.findPosition( regex.matchedTo()-1 + Integer.parseInt(spaces.elementAt(regex.matchedTo()-1).toString()) );\r
+\r
+ searchResults.addElement( sres+"" );\r
+ searchResults.addElement( eres+"" );\r
\r
if(!findAll)\r
{\r
}\r
\r
\r
- ArrayList idMatch = new ArrayList();\r
+ Vector idMatch = new Vector();\r
for(int id = 0; id<av.alignment.getHeight(); id++)\r
{\r
if( regex.search( av.alignment.getSequenceAt(id).getName() ) )\r
int imgHeight=0;\r
boolean fastPaint = false;\r
\r
- java.util.ArrayList searchResults;\r
+ java.util.Vector searchResults;\r
\r
public IdCanvas(AlignViewport av)\r
{\r
\r
}\r
\r
- public void setHighlighted(java.util.ArrayList found)\r
+ public void setHighlighted(java.util.Vector found)\r
{\r
searchResults = found;\r
repaint();\r
PaintRefresher.Refresh(this);\r
}\r
\r
- public void highlightSearchResults( java.util.ArrayList found )\r
+ public void highlightSearchResults( java.util.Vector found )\r
{\r
idCanvas.setHighlighted( found );\r
\r
for(int r=0; r<searchResults.length; r+=3)\r
{\r
int searchSeq = searchResults[r];\r
- int searchStart = searchResults[r+1];\r
- int searchEnd = searchResults[r+2];\r
\r
if (searchSeq >= y1 && searchSeq < y2)\r
{\r
+ SequenceI seq = av.getAlignment().getSequenceAt(searchSeq);\r
+\r
+ int searchStart = seq.findIndex( searchResults[r+1] )-1;\r
+ int searchEnd = seq.findIndex( searchResults[r+2] )-1;\r
+\r
SequenceRenderer ssr = (SequenceRenderer) sr;\r
if(searchStart<x1)\r
searchStart = x1;\r
if(searchEnd > x2)\r
searchEnd = x2;\r
- ssr.drawHighlightedText(av.getAlignment().getSequenceAt(searchSeq),\r
+\r
+ ssr.drawHighlightedText(seq,\r
searchStart,\r
searchEnd,\r
(searchStart - startx) * av.charWidth,\r
{\r
\r
if ( jalview.util.Comparison.isGap( av.alignment.getSequenceAt(seq).getSequence().charAt(j)))\r
- av.alignment.getSequenceAt(seq).deleteCharAt(j);\r
+ av.alignment.getSequenceAt(seq).deleteCharAt(j);\r
\r
av.alignment.getWidth();\r
repaint();\r
seqEditOccurred=seq;\r
+\r
}\r
\r
\r