public boolean editFlag;\r
protected AlignViewport av;\r
\r
+ // if character is inserted or deleted, we will need to recalculate the conservation\r
+ int seqEditOccurred = -1;\r
+\r
public SeqPanel(AlignViewport av, AlignmentPanel p) {\r
this.av = av;\r
\r
public void doMouseReleased(MouseEvent evt) {\r
\r
int x = evt.getX();\r
- int res = (int)(x/av.getCharWidth()) + av.getStartRes();\r
+ int res = (int)(x/av.getCharWidth()) + av.getStartRes();\r
\r
- endres = res;\r
+ endres = res;\r
\r
// This is to detect edits - we're at the end of an edit if mouse is up\r
- editFlag = false;\r
- startseq = -1;\r
- startres = -1;\r
- lastres = -1;\r
+ editFlag = false;\r
+ startseq = -1;\r
+ startres = -1;\r
+ lastres = -1;\r
+ if(seqEditOccurred>-1)\r
+ updateConservation(seqEditOccurred);\r
+\r
+ seqEditOccurred = -1;\r
\r
parent.RefreshPanels();\r
repaint();\r
{\r
if (!flag)\r
{\r
- if (!s.getSequence().substring(j,j+1).equals(av.getAlignment().getGapCharacter()) &&\r
- !s.getSequence().substring(j,j+1).equals(" "))\r
+ if (s.getSequence().charAt(j)!=av.getAlignment().getGapCharacter() &&\r
+ s.getSequence().charAt(j)==' ')\r
{\r
res = j+1;\r
flag = true;\r
\r
public void insertChar(int j, int seq)\r
{\r
- av.getAlignment().getSequenceAt(seq).insertCharAt(j, av.getGapCharacter().charAt(0));\r
- updateConservation(seq);\r
+ av.getAlignment().getSequenceAt(seq).insertCharAt(j, av.getGapCharacter());\r
+ seqEditOccurred=seq;\r
}\r
\r
- public void deleteChar(int j, int res, int sno)\r
+ public void deleteChar(int j, int res, int seq)\r
{\r
\r
- if (av.getAlignment().getSequenceAt(sno).getSequence().substring(j,j+1).equals(".") ||\r
- av.getAlignment().getSequenceAt(sno).getSequence().substring(j,j+1).equals("-") ||\r
- av.getAlignment().getSequenceAt(sno).getSequence().substring(j,j+1).equals(" ") )\r
+ if (av.getAlignment().getSequenceAt(seq).getSequence().charAt(j)=='.' ||\r
+ av.getAlignment().getSequenceAt(seq).getSequence().charAt(j)=='-' ||\r
+ av.getAlignment().getSequenceAt(seq).getSequence().charAt(j)==' ' )\r
{\r
- av.getAlignment().getSequenceAt(sno).deleteCharAt(j);\r
+ av.getAlignment().getSequenceAt(seq).deleteCharAt(j);\r
}\r
- updateConservation(sno);\r
+\r
av.getAlignment().getWidth();\r
repaint();\r
+ seqEditOccurred=seq;\r
}\r
\r
\r
void updateConservation(int i)\r
{\r
-\r
Alignment al = (Alignment) av.getAlignment();\r
SequenceGroup sg = av.alignment.findGroup( al.getSequenceAt(i));\r
if(sg==null || !(sg.cs instanceof ConservationColourScheme))\r
\r
public void setColourScheme(ColourSchemeI cs, boolean showConservation)\r
{\r
+ seqCanvas.paintFlag = true;\r
if (av.getSelection().size() == 0)\r
{\r
seqCanvas.cs = cs;\r
ConservationColourScheme ccs = (ConservationColourScheme)sg.cs;\r
sg.cs = ccs.cs;\r
}\r
-\r
-\r
-\r
}\r
- seqCanvas.paintFlag = true;\r
repaint();\r
}\r
\r