X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqPanel.java;h=1903294140283cfedd325160b1cd6cd3462a2a0c;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=fdcfacaf47b51f1b76b9587436a699a81c1aa330;hpb=caf13e6a9dc82023cd8648420201e5ad60ce0393;p=jalview.git diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java old mode 100755 new mode 100644 index fdcfaca..1903294 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * * This file is part of Jalview. * @@ -33,7 +33,7 @@ import jalview.structure.*; * DOCUMENT ME! * * @author $author$ - * @version $Revision$ + * @version $Revision: 1.130 $ */ public class SeqPanel extends JPanel implements MouseListener, MouseMotionListener, MouseWheelListener, SequenceListener, @@ -123,7 +123,7 @@ public class SeqPanel extends JPanel implements MouseListener, addMouseMotionListener(this); addMouseListener(this); addMouseWheelListener(this); - ssm = StructureSelectionManager.getStructureSelectionManager(); + ssm = StructureSelectionManager.getStructureSelectionManager(Desktop.instance); ssm.addStructureViewerListener(this); ssm.addSelectionListener(this); } @@ -168,6 +168,11 @@ public class SeqPanel extends JPanel implements MouseListener, } else { + if (x>seqCanvas.getWidth()+seqCanvas.getWidth()) + { + // make sure we calculate relative to visible alignment, rather than right-hand gutter + x = seqCanvas.getX()+seqCanvas.getWidth(); + } res = (x / av.getCharWidth()) + av.getStartRes(); } @@ -465,7 +470,7 @@ public class SeqPanel extends JPanel implements MouseListener, groupEditing = group; startseq = seqCanvas.cursorY; lastres = seqCanvas.cursorX; - editSequence(true, seqCanvas.cursorX + getKeyboardNo1()); + editSequence(true, false, seqCanvas.cursorX + getKeyboardNo1()); endEditing(); } @@ -474,9 +479,17 @@ public class SeqPanel extends JPanel implements MouseListener, groupEditing = group; startseq = seqCanvas.cursorY; lastres = seqCanvas.cursorX + getKeyboardNo1(); - editSequence(false, seqCanvas.cursorX); + editSequence(false, false, seqCanvas.cursorX); endEditing(); } + + void insertNucAtCursor(boolean group,String nuc){ + groupEditing = group; + startseq = seqCanvas.cursorY; + lastres = seqCanvas.cursorX; + editSequence(false, true, seqCanvas.cursorX + getKeyboardNo1()); + endEditing(); + } void numberPressed(char value) { @@ -610,8 +623,10 @@ public class SeqPanel extends JPanel implements MouseListener, { if (av.followHighlight) { - ap.scrollToPosition(results, false); + if (ap.scrollToPosition(results, false)) + { seqCanvas.revalidate(); + } } seqCanvas.highlightSearchResults(results); } @@ -804,17 +819,20 @@ public class SeqPanel extends JPanel implements MouseListener, .getType())) { tmpString = features[i].getDescription(); - int startTag = tmpString.toUpperCase().indexOf(""); + String tmp2up=tmpString.toUpperCase(); + int startTag = tmp2up.indexOf(""); if (startTag > -1) { tmpString = tmpString.substring(startTag + 6); + tmp2up = tmp2up.substring(startTag+6); } - int endTag = tmpString.toUpperCase().indexOf(""); + int endTag = tmp2up.indexOf(""); if (endTag > -1) { tmpString = tmpString.substring(0, endTag); + tmp2up = tmp2up.substring(0, endTag); } - endTag = tmpString.toUpperCase().indexOf(""); + endTag = tmp2up.indexOf(""); if (endTag > -1) { tmpString = tmpString.substring(0, endTag); @@ -1003,11 +1021,11 @@ public class SeqPanel extends JPanel implements MouseListener, if ((res < av.getAlignment().getWidth()) && (res < lastres)) { // dragLeft, delete gap - editSequence(false, res); + editSequence(false, false,res); } else { - editSequence(true, res); + editSequence(true, false,res); } mouseDragging = true; @@ -1017,7 +1035,8 @@ public class SeqPanel extends JPanel implements MouseListener, } } - synchronized void editSequence(boolean insertGap, int startres) + //TODO: Make it more clever than many booleans + synchronized void editSequence(boolean insertGap, boolean editSeq, int startres) { int fixedLeft = -1; int fixedRight = -1; @@ -1302,10 +1321,11 @@ public class SeqPanel extends JPanel implements MouseListener, { editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[] { seq }, lastres, startres - lastres, av.alignment, true); - } + } } else { + if(!editSeq){ // dragging to the left if (fixedColumns && fixedRight != -1) { @@ -1339,6 +1359,21 @@ public class SeqPanel extends JPanel implements MouseListener, { seq }, startres, max, av.alignment, true); } } + }else{//insertGap==false AND editSeq==TRUE; + if (fixedColumns && fixedRight != -1) + { + for (int j = lastres; j < startres; j++) + { + insertChar(j, new SequenceI[] + { seq }, fixedRight); + } + } + else + { + editCommand.appendEdit(EditCommand.INSERT_NUC, new SequenceI[] + { seq }, lastres, startres - lastres, av.alignment, true); + } + } } } @@ -1875,6 +1910,7 @@ public class SeqPanel extends JPanel implements MouseListener, // shared between viewports. if (av == source || !av.followSelection + || (av.isSelectionGroupChanged(false) || av.isColSelChanged(false)) || (source instanceof AlignViewport && ((AlignViewport) source) .getSequenceSetId().equals(av.getSequenceSetId()))) { @@ -1885,10 +1921,10 @@ public class SeqPanel extends JPanel implements MouseListener, // rules are: colsel is copied if there is a real intersection between // sequence selection boolean repaint = false, copycolsel = true; - if (av.selectionGroup == null || !av.isSelectionGroupChanged()) + // if (!av.isSelectionGroupChanged(false)) { SequenceGroup sgroup = null; - if (seqsel != null) + if (seqsel != null && seqsel.getSize()>0) { if (av.alignment == null) { @@ -1900,7 +1936,7 @@ public class SeqPanel extends JPanel implements MouseListener, sgroup = seqsel.intersect(av.alignment, (av.hasHiddenRows) ? av.hiddenRepSequences : null); if ((sgroup == null || sgroup.getSize() == 0) - && (colsel == null || colsel.size() == 0)) + || (colsel == null || colsel.size() == 0)) { // don't copy columns if the region didn't intersect. copycolsel = false; @@ -1914,9 +1950,10 @@ public class SeqPanel extends JPanel implements MouseListener, { av.setSelectionGroup(null); } - repaint = av.isSelectionGroupChanged(); + av.isSelectionGroupChanged(true); + repaint = true; } - if (copycolsel && (av.colSel == null || !av.isColSelChanged())) + if (copycolsel) { // the current selection is unset or from a previous message // so import the new colsel. @@ -1925,6 +1962,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (av.colSel != null) { av.colSel.clear(); + repaint=true; } } else @@ -1939,7 +1977,8 @@ public class SeqPanel extends JPanel implements MouseListener, av.colSel.setElementsFrom(colsel); } } - repaint |= av.isColSelChanged(); + av.isColSelChanged(true); + repaint = true; } if (copycolsel && av.hasHiddenColumns && (av.colSel == null || av.colSel.getHiddenColumns() == null))