*/\r
public class SeqCanvas extends JComponent\r
{\r
- FeatureRenderer fr;\r
- SequenceRenderer sr;\r
+ final FeatureRenderer fr;\r
+ final SequenceRenderer sr;\r
BufferedImage img;\r
Graphics2D gg;\r
int imgWidth;\r
int LABEL_WEST;\r
int LABEL_EAST;\r
\r
+\r
+ int cursorX = 0;\r
+ int cursorY = 0;\r
+\r
+\r
/**\r
* Creates a new SeqCanvas object.\r
*\r
\r
if (pdbCanvas != null)\r
{\r
- pdbCanvas.updateSeqColours();\r
+ pdbCanvas.updateSeqColours();\r
}\r
\r
}\r
av.endRes = av.startRes + cWidth;\r
\r
\r
- int endx = (startRes + cWidth) - 1;\r
+ int endx;\r
int ypos = hgap;\r
\r
while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
{\r
+ endx = startRes + cWidth;\r
+\r
+ if (endx > al.getWidth())\r
+ {\r
+ endx = al.getWidth();\r
+ }\r
+\r
g.setFont(av.getFont());\r
g.setColor(Color.black);\r
\r
cWidth * av.charWidth, (int) clip.getBounds().getHeight());\r
}\r
\r
- if (av.vconsensus!=null && av.alignment.getWidth() >= av.vconsensus.size())\r
- {\r
- endx = av.vconsensus.size() - 2;\r
- }\r
-\r
-\r
drawPanel(g, startRes, endx, 0, al.getHeight(), ypos);\r
\r
if(av.showAnnotation)\r
if(annotations==null)\r
annotations = new AnnotationPanel(av);\r
\r
- annotations.drawComponent( (Graphics2D) g, startRes, endx + 1);\r
+ annotations.drawComponent( (Graphics2D) g, startRes, endx);\r
g.translate(0, -cHeight - ypos);\r
}\r
g.setClip(clip);\r
ypos -= 3;\r
\r
startRes += cWidth;\r
- endx = (startRes + cWidth) - 1;\r
-\r
- if (endx > al.getWidth())\r
- {\r
- endx = al.getWidth();\r
- }\r
}\r
}\r
\r
* DOCUMENT ME!\r
*\r
* @param g1 DOCUMENT ME!\r
- * @param x1 DOCUMENT ME!\r
- * @param x2 DOCUMENT ME!\r
- * @param y1 DOCUMENT ME!\r
- * @param y2 DOCUMENT ME!\r
- * @param startx DOCUMENT ME!\r
- * @param starty DOCUMENT ME!\r
+ * @param startRes DOCUMENT ME!\r
+ * @param endRes DOCUMENT ME!\r
+ * @param startSeq DOCUMENT ME!\r
+ * @param endSeq DOCUMENT ME!\r
* @param offset DOCUMENT ME!\r
*/\r
-\r
- float aaRatio = 2f/3f;\r
- public void increaseAARatio()\r
- {\r
- aaRatio += .025;\r
- if(aaRatio>1)\r
- aaRatio = 1;\r
-\r
- repaint();\r
- }\r
-\r
- public void decreaseAARation()\r
- {\r
- aaRatio -= .025;\r
- if(aaRatio<0)\r
- aaRatio = 0;\r
-\r
- repaint();\r
- }\r
-\r
-\r
void drawPanel(Graphics g1, int startRes, int endRes,\r
int startSeq, int endSeq, int offset)\r
{\r
int offset)\r
{\r
\r
- sr.renderGaps(av.renderGaps);\r
+\r
Graphics2D g = (Graphics2D) g1;\r
g.setFont(av.getFont());\r
+ sr.prepare(g, av.renderGaps);\r
\r
SequenceI nextSeq;\r
\r
{\r
nextSeq = av.alignment.getSequenceAt(i);\r
\r
- sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq),\r
+ sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq),\r
startRes, endRes,\r
offset + ( (i - startSeq) * av.charHeight));\r
\r
if (av.showSequenceFeatures)\r
{\r
fr.drawSequence(g1, nextSeq, startRes, endRes,\r
- offset + ((i - startSeq) * av.charHeight), av.charWidth,\r
- av.charHeight);\r
+ offset + ((i - startSeq) * av.charHeight));\r
}\r
\r
/// Highlight search Results once all sequences have been drawn\r
sr.drawHighlightedText(nextSeq, visibleResults[r],\r
visibleResults[r + 1],\r
(visibleResults[r] - startRes) * av.charWidth,\r
- offset + ( (i - startSeq) * av.charHeight),\r
- av.charWidth, av.charHeight);\r
+ offset + ( (i - startSeq) * av.charHeight));\r
}\r
}\r
+\r
+ if(av.cursorMode && cursorY==i\r
+ && cursorX>=startRes && cursorX<=endRes)\r
+ {\r
+ sr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * av.charWidth,\r
+ offset + ( (i - startSeq) * av.charHeight));\r
+ }\r
}\r
\r
//\r
public AlignmentPanel ap;\r
protected int lastres;\r
protected int startseq;\r
- int startEdit = -1;\r
- int endEdit = -1;\r
protected AlignViewport av;\r
\r
// if character is inserted or deleted, we will need to recalculate the conservation\r
seqEditOccurred = false;\r
editingSeqs = false;\r
groupEditing = false;\r
+ keyboardGaps = null;\r
}\r
\r
+\r
+ void moveCursor(int dx, int dy)\r
+ {\r
+ seqCanvas.cursorX += dx;\r
+ seqCanvas.cursorY += dy;\r
+\r
+ if(seqCanvas.cursorX<0)\r
+ seqCanvas.cursorX = 0;\r
+ else if(seqCanvas.cursorX>av.alignment.getWidth()-1)\r
+ seqCanvas.cursorX = av.alignment.getWidth()-1;\r
+ if(seqCanvas.cursorX<av.startRes)\r
+ ap.scrollRight(false);\r
+ else if(seqCanvas.cursorX>av.endRes)\r
+ ap.scrollRight(true);\r
+\r
+ if(seqCanvas.cursorY<0)\r
+ seqCanvas.cursorY=0;\r
+ else if(seqCanvas.cursorY>av.alignment.getHeight()-1)\r
+ seqCanvas.cursorY = av.alignment.getHeight()-1;\r
+ if(seqCanvas.cursorY<av.startSeq)\r
+ ap.scrollUp(true);\r
+ else if(seqCanvas.cursorY+1>av.endSeq)\r
+ ap.scrollUp(false);\r
+\r
+ setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY),\r
+ seqCanvas.cursorX, seqCanvas.cursorY);\r
+ seqCanvas.repaint();\r
+ }\r
+\r
+ void setSelectionAreaAtCursor(boolean topLeft)\r
+ {\r
+ SequenceI sequence =\r
+ (Sequence) av.getAlignment().getSequenceAt(seqCanvas.cursorY);\r
+\r
+ if(av.getSelectionGroup()!=null)\r
+ {\r
+ SequenceGroup sg = av.selectionGroup;\r
+ //Find the top and bottom of this group\r
+ int min = av.alignment.getHeight(), max = 0;\r
+ for(int i=0; i<sg.getSize(); i++)\r
+ {\r
+ int index = av.alignment.findIndex( sg.getSequenceAt(i) );\r
+ if(index > max)\r
+ max = index;\r
+ if(index < min)\r
+ min = index;\r
+ }\r
+\r
+ max ++;\r
+\r
+ if(topLeft)\r
+ {\r
+ sg.setStartRes(seqCanvas.cursorX);\r
+ if(sg.getEndRes()<seqCanvas.cursorX)\r
+ sg.setEndRes(seqCanvas.cursorX);\r
+\r
+ min = seqCanvas.cursorY;\r
+ }\r
+ else\r
+ {\r
+ sg.setEndRes(seqCanvas.cursorX);\r
+ if(sg.getStartRes()>seqCanvas.cursorX)\r
+ sg.setStartRes(seqCanvas.cursorX);\r
+\r
+ max = seqCanvas.cursorY+1;\r
+ }\r
+\r
+ if(min>max)\r
+ {\r
+ // Only the user can do this\r
+ av.setSelectionGroup(null);\r
+ }\r
+ else\r
+ {\r
+ // Now add any sequences between min and max\r
+ sg.sequences.clear();\r
+ for (int i = min; i < max; i++)\r
+ {\r
+ sg.addSequence(av.alignment.getSequenceAt(i), false);\r
+ }\r
+ }\r
+ }\r
+\r
+ if (av.getSelectionGroup() == null)\r
+ {\r
+ SequenceGroup sg = new SequenceGroup();\r
+ sg.setStartRes(seqCanvas.cursorX);\r
+ sg.setEndRes(seqCanvas.cursorX);\r
+ sg.addSequence(sequence, false);\r
+ av.setSelectionGroup(sg);\r
+ }\r
+\r
+\r
+ ap.repaint();\r
+ }\r
+\r
+ void insertGapAtCursor(boolean group)\r
+ {\r
+ ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence",\r
+ av.alignment, HistoryItem.EDIT));\r
+ groupEditing = group;\r
+ startseq = seqCanvas.cursorY;\r
+ lastres = seqCanvas.cursorX;\r
+ editSequence(true, seqCanvas.cursorX+getKeyboardGaps());\r
+ editOccurred();\r
+ }\r
+\r
+ void deleteGapAtCursor(boolean group)\r
+ {\r
+ ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence",\r
+ av.alignment, HistoryItem.EDIT));\r
+ groupEditing = group;\r
+ startseq = seqCanvas.cursorY;\r
+ lastres = seqCanvas.cursorX+getKeyboardGaps();\r
+ editSequence(false, seqCanvas.cursorX);\r
+ editOccurred();\r
+ }\r
+\r
+ void numberPressed(char value)\r
+ {\r
+ if(keyboardGaps==null)\r
+ keyboardGaps = new StringBuffer();\r
+\r
+ keyboardGaps.append(value);\r
+ }\r
+\r
+ StringBuffer keyboardGaps;\r
+ int getKeyboardGaps()\r
+ {\r
+ if(keyboardGaps==null)\r
+ return 1;\r
+ else\r
+ return Integer.parseInt(keyboardGaps.toString());\r
+ }\r
+\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
public void mouseReleased(MouseEvent evt)\r
{\r
mouseDragging = false;\r
+ mouseWheelPressed = false;\r
\r
if (!editingSeqs)\r
{\r
return;\r
}\r
\r
- if (seqEditOccurred)\r
- {\r
- editOccurred();\r
- }\r
+ editOccurred();\r
\r
- endEditing();\r
- ap.repaint();\r
+ endEditing();\r
+ ap.repaint();\r
}\r
\r
\r
}\r
\r
\r
- ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence",\r
- av.alignment, HistoryItem.EDIT));\r
\r
int seq = findSeq(evt);\r
int res = findRes(evt);\r
if(seq<0 || res<0)\r
return;\r
\r
+ ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence",\r
+ av.alignment, HistoryItem.EDIT));\r
+\r
if ((seq < av.getAlignment().getHeight()) &&\r
(res < av.getAlignment().getSequenceAt(seq).getLength()))\r
{\r
lastres = -1;\r
}\r
\r
- startEdit = lastres;\r
- endEdit = lastres;\r
-\r
return;\r
}\r
\r
int res = findRes(evt);\r
int seq = findSeq(evt);\r
\r
+\r
if(res<0 || seq<0 || seq >= av.getAlignment().getHeight())\r
return;\r
\r
seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res));\r
}\r
\r
-\r
- StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " +\r
- sequence.getName());\r
-\r
- Object obj = null;\r
- if (av.alignment.isNucleotide())\r
- {\r
- obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) +\r
- "");\r
- if(obj!=null)\r
- text.append(" Nucleotide: ");\r
- }\r
- else\r
- {\r
- obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + "");\r
- if(obj!=null)\r
- text.append(" Residue: ");\r
- }\r
-\r
- if (obj != null)\r
- {\r
-\r
- if (obj != "")\r
- {\r
- text.append( obj + " (" +\r
- av.getAlignment().getSequenceAt(seq).findPosition(res) + ")");\r
- }\r
- }\r
-\r
- ap.alignFrame.statusBar.setText(text.toString());\r
+ setStatusMessage(sequence, res, seq);\r
\r
// use aa to see if the mouse pointer is on a\r
if (av.showSequenceFeatures)\r
if ( (features[i].getBegin() <= sequence.findPosition(res)) &&\r
(features[i].getEnd() >= sequence.findPosition(res)))\r
{\r
- if(!av.featuresDisplayed.containsKey(features[i].getType()))\r
+ if(av.featuresDisplayed==null\r
+ || !av.featuresDisplayed.containsKey(features[i].getType()))\r
continue;\r
\r
\r
}\r
}\r
\r
+ void setStatusMessage(SequenceI sequence, int res, int seq)\r
+ {\r
+ StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " +\r
+ sequence.getName());\r
+\r
+ Object obj = null;\r
+ if (av.alignment.isNucleotide())\r
+ {\r
+ obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) +\r
+ "");\r
+ if (obj != null)\r
+ text.append(" Nucleotide: ");\r
+ }\r
+ else\r
+ {\r
+ obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + "");\r
+ if (obj != null)\r
+ text.append(" Residue: ");\r
+ }\r
+\r
+ if (obj != null)\r
+ {\r
+\r
+ if (obj != "")\r
+ {\r
+ text.append(obj + " (" + sequence.findPosition(res) +\r
+ ")");\r
+ }\r
+ }\r
+ ap.alignFrame.statusBar.setText(text.toString());\r
+\r
+ }\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
return;\r
}\r
\r
- boolean dragRight = true;\r
-\r
- if ((res < av.getAlignment().getWidth()) && (res < lastres))\r
+ if ( (res < av.getAlignment().getWidth()) && (res < lastres))\r
{\r
- dragRight = false;\r
+ // dragLeft, delete gap\r
+ editSequence(false, res);\r
}\r
- else if(av.hasHiddenColumns)\r
+ else\r
+ editSequence(true, res);\r
+\r
+ mouseDragging = true;\r
+ if(scrollThread!=null)\r
+ scrollThread.setEvent(evt);\r
+\r
+ }\r
+\r
+ void editSequence(boolean insertGap, int startres)\r
+ {\r
+ int fixedLeft = -1;\r
+ int fixedRight = -1;\r
+ boolean fixedColumns = false;\r
+\r
+ if(insertGap && av.hasHiddenColumns)\r
{\r
//Stop editing if the user has dragged beyond hiddenBoundary\r
- int lastCol = av.getColumnSelection().getHiddenRegionBoundary(lastres);\r
- if( lastCol < res)\r
+ fixedRight = av.getColumnSelection().getHiddenRegionBoundary(lastres);\r
+ if( fixedRight < lastres)\r
{\r
- if(lastres!=lastCol)\r
+ if(lastres!=fixedRight)\r
{\r
endEditing();\r
return;\r
}\r
}\r
\r
- if(!groupEditing && av.hasHiddenRows)\r
+ if (!groupEditing && av.hasHiddenRows)\r
{\r
- if(av.alignment.getSequenceAt(startseq).getHiddenSequences()!=null)\r
+ if (av.alignment.getSequenceAt(startseq).getHiddenSequences() != null)\r
{\r
groupEditing = true;\r
}\r
}\r
\r
\r
- if (res != lastres)\r
- {\r
- SequenceI seq;\r
- // Group editing\r
- if (groupEditing)\r
- {\r
- SequenceGroup sg = av.getSelectionGroup();\r
+ SequenceI seq = av.alignment.getSequenceAt(startseq);\r
+ StringBuffer message = new StringBuffer();\r
+ if (groupEditing)\r
+ message.append("Edit group:");\r
+ else\r
+ message.append("Edit sequence: "+seq.getName());\r
\r
- if (av.hasHiddenRows)\r
- {\r
- //sg might be null as the user may only see 1 sequence\r
- if(sg==null)\r
- {\r
- sg = new SequenceGroup();\r
- sg.addSequence(av.alignment.getSequenceAt(startseq), false);\r
- }\r
+ if(insertGap)\r
+ message.append(" insert ");\r
+ else\r
+ message.append(" delete ");\r
\r
- SequenceGroup tmp = new SequenceGroup();\r
+ message.append(Math.abs(startres-lastres)+" gaps.");\r
+ ap.alignFrame.statusBar.setText(message.toString());\r
\r
- //Do any of the sequences have hidden associates?\r
- for (int s = 0; s < sg.getSize(); s++)\r
- {\r
- seq = sg.getSequenceAt(s);\r
- tmp.addSequence(seq, false);\r
- if (seq.getHiddenSequences()!=null)\r
- {\r
- for(int h=0; h<seq.getHiddenSequences().getSize(); h++)\r
- tmp.addSequence(seq.getHiddenSequences().getSequenceAt(h),\r
- false);\r
- }\r
- }\r
\r
- sg = tmp;\r
- }\r
+ //Are we editing within a selection group?\r
+ if (groupEditing\r
+ || (av.getSelectionGroup() != null &&\r
+ av.getSelectionGroup().sequences.contains(seq)))\r
+ {\r
+ fixedColumns = true;\r
\r
+ fixedLeft = av.getSelectionGroup().getStartRes();\r
+ fixedRight = av.getSelectionGroup().getEndRes();\r
\r
- if (sg == null)\r
- {\r
- endEditing();\r
- return;\r
- }\r
+ if ( (startres < fixedLeft && lastres >= fixedLeft)\r
+ || (startres >= fixedLeft && lastres < fixedLeft)\r
+ || (startres > fixedRight && lastres <=fixedRight)\r
+ || (startres <= fixedRight && lastres > fixedRight))\r
+ {\r
+ endEditing();\r
+ return;\r
+ }\r
+\r
+ if (fixedLeft > startres)\r
+ {\r
+ fixedRight = fixedLeft - 1;\r
+ fixedLeft = 0;\r
+ }\r
+ else if (fixedRight < startres)\r
+ {\r
+ fixedLeft = fixedRight;\r
+ fixedRight = -1;\r
+ }\r
+ }\r
\r
- int blankColumn = -1;\r
+ if (groupEditing)\r
+ {\r
+ SequenceGroup sg = av.getSelectionGroup();\r
+ if(fixedLeft>sg.getEndRes()\r
+ ||fixedRight<sg.getStartRes())\r
+ {\r
+ endEditing();\r
+ return;\r
+ }\r
\r
- // drag to right\r
- if (dragRight)\r
- {\r
+ if (av.hasHiddenRows)\r
+ {\r
+ //sg might be null as the user may only see 1 sequence\r
+ if (sg == null)\r
+ {\r
+ sg = new SequenceGroup();\r
+ sg.addSequence(av.alignment.getSequenceAt(startseq), false);\r
+ }\r
\r
- // Is it valid??\r
- // Find the next gap before the end\r
- // of the visible region boundary\r
- if (av.hasHiddenColumns)\r
- {\r
- if(res-lastres > 1)\r
- {\r
- res = lastres+1;\r
- }\r
+ SequenceGroup tmp = new SequenceGroup();\r
\r
+ //Do any of the sequences have hidden associates?\r
+ for (int s = 0; s < sg.getSize(); s++)\r
+ {\r
+ seq = sg.getSequenceAt(s);\r
+ tmp.addSequence(seq, false);\r
+ if (seq.getHiddenSequences() != null)\r
+ {\r
+ for (int h = 0; h < seq.getHiddenSequences().getSize(); h++)\r
+ tmp.addSequence(seq.getHiddenSequences().getSequenceAt(h),\r
+ false);\r
+ }\r
+ }\r
\r
- int lastCol = av.getColumnSelection().\r
- getHiddenRegionBoundary(res);\r
+ sg = tmp;\r
+ }\r
\r
- if(lastCol!=res)\r
- {\r
- for (blankColumn = lastCol;\r
- blankColumn > lastres;\r
- blankColumn--)\r
- {\r
- boolean blank = true;\r
- for (int s = 0; s < sg.getSize(); s++)\r
- {\r
- seq = sg.getSequenceAt(s);\r
-\r
- if (seq.getSequence().length() <= blankColumn)\r
- {\r
- continue;\r
- }\r
-\r
- if (!jalview.util.Comparison.isGap(\r
- seq.getSequence().charAt(blankColumn)))\r
- {\r
- blank = false;\r
- continue;\r
- }\r
- }\r
- if (blank)\r
- break;\r
- }\r
-\r
-\r
- if (blankColumn <= lastres)\r
- {\r
- endEditing();\r
- return;\r
- }\r
- }\r
- else\r
- blankColumn = -1;\r
+ if (sg == null)\r
+ {\r
+ endEditing();\r
+ return;\r
+ }\r
\r
- }\r
+ // int blankColumn = -1;\r
\r
- sg.setEndRes(sg.getEndRes() + (res - lastres));\r
- }\r
+ // drag to right\r
+ if (insertGap)\r
+ {\r
+ // Is it valid??\r
+ // Find the next gap before the end\r
+ // of the visible region boundary\r
+ if (av.hasHiddenColumns)\r
+ {\r
+ // int lastCol = av.getColumnSelection().\r
+ // getHiddenRegionBoundary(res);\r
\r
- // drag to left\r
- else\r
+ }\r
+\r
+ if (fixedRight != startres && fixedRight<av.alignment.getWidth()-1)\r
+ {\r
+ for (fixedRight = fixedRight;\r
+ fixedRight > lastres;\r
+ fixedRight --)\r
{\r
- /// Are we able to delete?\r
- // ie are all columns blank?\r
+ boolean blank = true;\r
+ for (int s = 0; s < sg.getSize(); s++)\r
+ {\r
+ seq = sg.getSequenceAt(s);\r
\r
- for (int s = 0; s < sg.getSize(); s++)\r
+ if (seq.getSequence().length() <= fixedRight)\r
{\r
- seq = sg.getSequenceAt(s);\r
-\r
- for (int j = res; j < lastres; j++)\r
- {\r
- if (seq.getSequence().length() <= j)\r
- {\r
- continue;\r
- }\r
-\r
- if (!jalview.util.Comparison.isGap(\r
- seq.getSequence().charAt(j)))\r
- {\r
- // Not a gap, block edit not valid\r
- endEditing();\r
- return;\r
- }\r
- }\r
+ continue;\r
}\r
\r
- if(res<sg.getStartRes())\r
+ if (!jalview.util.Comparison.isGap(\r
+ seq.getCharAt(fixedRight)))\r
{\r
- sg.setStartRes(sg.getStartRes() - 1);\r
+ blank = false;\r
+ continue;\r
}\r
- sg.setEndRes(sg.getEndRes() - (lastres - res));\r
+ }\r
+ if (blank)\r
+ break;\r
}\r
+ }\r
+\r
+ if (fixedRight <= startres)\r
+ {\r
+ endEditing();\r
+ return;\r
+ }\r
+ }\r
\r
- for (int i = 0; i < sg.getSize(); i++)\r
+\r
+ // drag to left\r
+ else\r
+ {\r
+ /// Are we able to delete?\r
+ // ie are all columns blank?\r
+\r
+ for (int s = 0; s < sg.getSize(); s++)\r
+ {\r
+ seq = sg.getSequenceAt(s);\r
+\r
+ for (int j = startres; j < lastres; j++)\r
+ {\r
+ if (seq.getSequence().length() <= j)\r
{\r
- seq = sg.getSequenceAt(i);\r
+ continue;\r
+ }\r
\r
- // drag to right\r
- if (dragRight)\r
- {\r
- for (int j = lastres; j < res; j++)\r
- {\r
- insertChar(j, seq, blankColumn);\r
- }\r
- }\r
+ if (!jalview.util.Comparison.isGap(\r
+ seq.getSequence().charAt(j)))\r
+ {\r
+ // Not a gap, block edit not valid\r
+ endEditing();\r
+ return;\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- // drag to left\r
- else\r
- {\r
- for (int j = res; j < lastres; j++)\r
- {\r
- if (seq.getLength()-1 > res)\r
- {\r
- deleteChar(res, seq);\r
- }\r
- }\r
- }\r
+\r
+ for (int i = 0; i < sg.getSize(); i++)\r
+ {\r
+ seq = sg.getSequenceAt(i);\r
+\r
+ if (insertGap)\r
+ {\r
+ // dragging to the right\r
+ for (int j = lastres; j < startres; j++)\r
+ {\r
+ if (fixedColumns && fixedRight != -1)\r
+ {\r
+ insertChar(j, seq, fixedRight);\r
}\r
+ else\r
+ insertChar(j, seq);\r
+ }\r
}\r
- else /////Editing a single sequence///////////\r
+ else\r
{\r
- seq = av.alignment.getSequenceAt(startseq);\r
- if ((res < av.getAlignment().getWidth()) && (res > lastres))\r
+ // dragging to the left\r
+ for (int j = lastres; j > startres; j--)\r
+ {\r
+ if (fixedColumns && fixedRight != -1)\r
{\r
- // dragging to the right\r
- for (int j = lastres; j < res; j++)\r
- {\r
- insertChar(j, seq, j);\r
- }\r
+ deleteChar(startres, seq, fixedRight);\r
}\r
- else if ((res < av.getAlignment().getWidth()) &&\r
- (res < lastres))\r
+ else\r
{\r
- // dragging to the left\r
- for (int j = lastres; j > res; j--)\r
- {\r
- if (jalview.util.Comparison.isGap(\r
- av.alignment.getSequenceAt(startseq)\r
- .getSequence().charAt(res)))\r
- {\r
- deleteChar(res, seq);\r
- }\r
- else\r
- {\r
- break;\r
- }\r
- }\r
+ deleteChar(startres, seq);\r
}\r
+ }\r
}\r
+ }\r
}\r
+ else /////Editing a single sequence///////////\r
+ {\r
\r
- mouseDragging = true;\r
- if(scrollThread!=null)\r
- scrollThread.setEvent(evt);\r
+ if (insertGap)\r
+ {\r
+ // dragging to the right\r
+ for (int j = lastres; j < startres; j++)\r
+ {\r
+ if (fixedColumns && fixedRight != -1)\r
+ insertChar(j, seq, fixedRight);\r
+ else\r
+ insertChar(j, seq);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ // dragging to the left\r
+ for (int j = lastres; j > startres; j--)\r
+ {\r
+ if (fixedColumns && fixedRight != -1)\r
+ {\r
+ deleteChar(startres, seq, fixedRight);\r
+ }\r
+ else\r
+ {\r
+ deleteChar(startres, seq);\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- endEdit = res;\r
- lastres = res;\r
+ lastres = startres;\r
seqCanvas.repaint();\r
}\r
\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param j DOCUMENT ME!\r
+ * @param seq DOCUMENT ME!\r
+ */\r
+ void insertChar(int j, SequenceI seq)\r
+ {\r
+ seq.insertCharAt(j, av.getGapCharacter());\r
+ seqEditOccurred = true;\r
+ }\r
+\r
+ void insertChar(int j, SequenceI seq, int fixedColumn)\r
+ {\r
+ //Find the next gap before the end of the visible region boundary\r
+ //If lastCol > j, theres a boundary after the gap insertion\r
+ int blankColumn = fixedColumn;\r
+ for (blankColumn = fixedColumn; blankColumn > j; blankColumn--)\r
+ {\r
+ if (jalview.util.Comparison.isGap(seq.getCharAt(blankColumn)))\r
+ {\r
+ //Theres a space, so break and insert the gap\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (blankColumn <= j)\r
+ {\r
+ endEditing();\r
+ return;\r
+ }\r
+\r
+ if (!jalview.util.Comparison.isGap(seq.getCharAt(blankColumn)))\r
+ {\r
+ //Just Checking\r
+ System.out.println("Tried removing residue (INSERT)"+seq.getCharAt(fixedColumn));\r
+ return;\r
+ }\r
+\r
+ seq.deleteCharAt(blankColumn);\r
+ seq.insertCharAt(j, av.getGapCharacter());\r
+ seqEditOccurred = true;\r
+ }\r
+\r
+ void deleteChar(int j, SequenceI seq, int fixedColumn)\r
+ {\r
+ if (!jalview.util.Comparison.isGap(seq.getCharAt(j)))\r
+ {\r
+ ap.alignFrame.statusBar.setText(\r
+ "End editing: Tried removing residue " + seq.getCharAt(j));\r
+ return;\r
+ }\r
+\r
+ seq.deleteCharAt(j);\r
+ seq.insertCharAt(fixedColumn, av.getGapCharacter());\r
+ seqEditOccurred = true;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param j DOCUMENT ME!\r
+ * @param seq DOCUMENT ME!\r
+ */\r
+ void deleteChar(int j, SequenceI seq)\r
+ {\r
+ if (!jalview.util.Comparison.isGap(seq.getCharAt(j)))\r
+ {\r
+ ap.alignFrame.statusBar.setText(\r
+ "End editing: Tried removing residue " + seq.getCharAt(j));\r
+ return;\r
+ }\r
+\r
+ seq.deleteCharAt(j);\r
+ seqEditOccurred = true;\r
+ seqCanvas.repaint();\r
+ }\r
/**\r
* DOCUMENT ME!\r
*\r
\r
public void mouseWheelMoved(MouseWheelEvent e)\r
{\r
+ e.consume();\r
if (mouseWheelPressed)\r
{\r
Font font = av.getFont();\r
}\r
\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param j DOCUMENT ME!\r
- * @param seq DOCUMENT ME!\r
- */\r
- void insertChar(int j, SequenceI seq, int blankColumn)\r
- {\r
- if(av.hasHiddenColumns)\r
- {\r
- //Find the next gap before the end of the visible region boundary\r
- int lastCol = av.getColumnSelection().getHiddenRegionBoundary(j);\r
- if(lastCol != j)\r
- {\r
- if (!groupEditing || lastCol <= j)\r
- {\r
- blankColumn = lastCol;\r
- //If lastCol > j, theres a boundary after the gap insertion\r
- if (lastCol > j)\r
- {\r
- for (blankColumn = lastCol; blankColumn > j; blankColumn--)\r
- {\r
- if (jalview.util.Comparison.isGap(seq.getCharAt(blankColumn)))\r
- {\r
- //Theres a space, so break and insert the gap\r
- break;\r
- }\r
- }\r
-\r
- if (blankColumn <= j)\r
- {\r
- endEditing();\r
- return;\r
- }\r
- }\r
-\r
- }\r
-\r
- // Editing with hidden regions only!!\r
- seq.deleteCharAt(blankColumn);\r
- }\r
- }\r
-\r
- seq.insertCharAt(j, av.getGapCharacter());\r
- seqEditOccurred = true;\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param j DOCUMENT ME!\r
- * @param seq DOCUMENT ME!\r
- */\r
- public void deleteChar(int j, SequenceI seq)\r
- {\r
- if (av.hasHiddenColumns)\r
- {\r
- //Find the next gap before the end of the visible region boundary\r
- int lastCol = av.getColumnSelection().getHiddenRegionBoundary(j);\r
-\r
- //If lastCol > j, theres a boundary after the gap insertion\r
- if (lastCol > j)\r
- {\r
- seq.insertCharAt(lastCol, av.getGapCharacter());\r
- }\r
- }\r
-\r
- seq.deleteCharAt(j);\r
- seqEditOccurred = true;\r
-\r
- seqCanvas.repaint();\r
- }\r
\r
/**\r
* DOCUMENT ME!\r
*/\r
void editOccurred()\r
{\r
- if (endEdit == startEdit)\r
+ if (!seqEditOccurred)\r
{\r
ap.alignFrame.historyList.pop();\r
ap.alignFrame.updateEditMenuBar();\r
}\r
\r
+ endEditing();\r
+\r
av.firePropertyChange("alignment", null,av.getAlignment().getSequences());\r
\r
}\r
if(seq<0 || res<0)\r
return;\r
\r
-\r
SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq);\r
\r
if ((sequence == null) || (res > sequence.getLength()))\r
}\r
}\r
\r
+ if (av.cursorMode)\r
+ {\r
+ seqCanvas.cursorX = findRes(evt);\r
+ seqCanvas.cursorY = findSeq(evt);\r
+ seqCanvas.repaint();\r
+ return;\r
+ }\r
+\r
+\r
if (stretchGroup == null)\r
{\r
// define a new group here\r
\r
if (mouseDragging && (evt.getX() < 0))\r
{\r
- running = ap.scrollRight(true);\r
+ running = ap.scrollRight(false);\r
}\r
else if (mouseDragging && (evt.getX() >= getWidth()))\r
{\r
- running = ap.scrollRight(false);\r
+ running = ap.scrollRight(true);\r
}\r
}\r
\r