X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=89e2086a1ebbd81a81e2f2286dc7071a3fc7455c;hb=7724430e3293cbb862d0c50c5308a3b3b0417cac;hp=5ff10cea149919531272e388a1bb81b51217b8b8;hpb=94e3d91558ad96de545821aeb548934f8c8353a3;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 5ff10ce..89e2086 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,6 +24,7 @@ import java.awt.event.*; import jalview.datamodel.*; import jalview.schemes.*; +import jalview.commands.*; import java.util.Vector; @@ -60,6 +61,8 @@ public class SeqPanel boolean mouseWheelPressed = false; Point lastMousePress; + EditCommand editCommand; + public SeqPanel(AlignViewport avp, AlignmentPanel p) { this.av = avp; @@ -78,13 +81,20 @@ public class SeqPanel void endEditing() { + if (editCommand!=null && editCommand.getSize() > 0) + { + ap.alignFrame.addHistoryItem(editCommand); + av.firePropertyChange("alignment", null, + av.getAlignment().getSequences()); + } + startseq = -1; lastres = -1; - seqEditOccurred = false; editingSeqs = false; groupEditing = false; keyboardNo1 = null; keyboardNo2 = null; + editCommand = null; } void setCursorRow() @@ -128,6 +138,24 @@ public class SeqPanel { seqCanvas.cursorX += dx; seqCanvas.cursorY += dy; + if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX)) + { + int original = seqCanvas.cursorX - dx; + int maxWidth = av.alignment.getWidth(); + + while(!av.colSel.isVisible(seqCanvas.cursorX) + && seqCanvas.cursorX0) + { + seqCanvas.cursorX += dx; + } + + if(seqCanvas.cursorX>=maxWidth + || !av.colSel.isVisible(seqCanvas.cursorX) ) + { + seqCanvas.cursorX = original; + } + } scrollToVisible(); } @@ -159,13 +187,13 @@ public class SeqPanel { ap.scrollUp(false); } - while (seqCanvas.cursorX < av.startRes) + while (seqCanvas.cursorX < av.colSel.adjustForHiddenColumns(av.startRes)) { if (!ap.scrollRight(false)) break; } - while (seqCanvas.cursorX > av.endRes) + while (seqCanvas.cursorX > av.colSel.adjustForHiddenColumns(av.endRes)) { if (!ap.scrollRight(true)) break; @@ -223,7 +251,7 @@ public class SeqPanel else { // Now add any sequences between min and max - sg.sequences.removeAllElements(); + sg.getSequences(null).removeAllElements(); for (int i = min; i < max; i++) { sg.addSequence(av.alignment.getSequenceAt(i), false); @@ -246,24 +274,20 @@ public class SeqPanel void insertGapAtCursor(boolean group) { - ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", - av.alignment, HistoryItem.EDIT)); groupEditing = group; startseq = seqCanvas.cursorY; lastres = seqCanvas.cursorX; editSequence(true, seqCanvas.cursorX+getKeyboardNo(keyboardNo1)); - editOccurred(); + endEditing(); } void deleteGapAtCursor(boolean group) { - ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", - av.alignment, HistoryItem.EDIT)); groupEditing = group; startseq = seqCanvas.cursorY; lastres = seqCanvas.cursorX+getKeyboardNo(keyboardNo1); editSequence(false, seqCanvas.cursorX); - editOccurred(); + endEditing(); } void numberPressed(char value) @@ -322,17 +346,20 @@ public class SeqPanel { lastMousePress = evt.getPoint(); + //For now, ignore the mouseWheel font resizing on Macs + //As the Button2_mask always seems to be true if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) == - InputEvent.BUTTON2_MASK) + InputEvent.BUTTON2_MASK && !av.MAC) { mouseWheelPressed = true; return; } - if (evt.isShiftDown() || evt.isAltDown() || - evt.isControlDown()) + if (evt.isShiftDown() + || evt.isControlDown() + || evt.isAltDown()) { - if (evt.isAltDown() || evt.isControlDown()) + if (evt.isControlDown() || evt.isAltDown()) { groupEditing = true; } @@ -351,8 +378,6 @@ public class SeqPanel if(seq<0 || res<0) return; - ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", - av.alignment, HistoryItem.EDIT)); if ((seq < av.getAlignment().getHeight()) && (res < av.getAlignment().getSequenceAt(seq).getLength())) @@ -383,8 +408,6 @@ public class SeqPanel return; } - editOccurred(); - endEditing(); ap.repaint(); } @@ -412,6 +435,8 @@ public class SeqPanel int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width); + if(cwidth<1) + return 0; wrappedBlock = y / cHeight; wrappedBlock += av.getStartRes() / cwidth; @@ -424,6 +449,9 @@ public class SeqPanel res = (x / av.getCharWidth()) + av.getStartRes(); } + if(av.hasHiddenColumns) + res = av.getColumnSelection().adjustForHiddenColumns(res); + return res; } @@ -445,11 +473,17 @@ public class SeqPanel y -= hgap; - seq = ( (y % cHeight) / av.getCharHeight()); + seq = Math.min( (y % cHeight) / av.getCharHeight(), + av.alignment.getHeight() -1); + if(seq<0) + seq = 0; } else { - seq = (y / av.getCharHeight()) + av.getStartSeq(); + seq = Math.min( (y / av.getCharHeight()) + av.getStartSeq(), + av.alignment.getHeight() -1); + if(seq<0) + seq = 0; } return seq; @@ -458,8 +492,6 @@ public class SeqPanel public void doMousePressed(MouseEvent evt) { - ap.alignFrame.addHistoryItem(new HistoryItem( - "Edit Sequence", av.alignment, HistoryItem.EDIT)); int seq = findSeq(evt); int res = findRes(evt); @@ -519,11 +551,9 @@ public class SeqPanel if (obj != null) { - if (obj != "") { - text.append(obj + " (" + - av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + text.append(obj + " (" + sequence.findPosition(res) + ")"); } } @@ -532,6 +562,8 @@ public class SeqPanel seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res)); } + ap.alignFrame.statusBar.setText(text.toString()); + // use aa to see if the mouse pointer is on a if (av.showSequenceFeatures @@ -553,7 +585,9 @@ public class SeqPanel if (sf.getValue("status") != null ) { - featureText.append(" (" + sf.getValue("status") + ")"); + String status = sf.getValue("status").toString(); + if(status.length()>0) + featureText.append(" (" + sf.getValue("status") + ")"); } featureText.append("\n"); @@ -568,14 +602,11 @@ public class SeqPanel tooltip.repaint(); - // text.append(" Sequence Feature:"); - // text.append(featureText); - } - - - ap.alignFrame.statusBar.setText(text.toString()); - + else if (tooltip != null) + { + tooltip.setTip(""); + } } Vector getAllFeaturesAtRes(SequenceI seq, int res) @@ -693,250 +724,339 @@ public class SeqPanel } synchronized void editSequence(boolean insertGap, int startres) - { - int fixedLeft = -1; - int fixedRight = -1; - boolean fixedColumns = false; - SequenceGroup sg = av.getSelectionGroup(); + { + int fixedLeft = -1; + int fixedRight = -1; + boolean fixedColumns = false; + SequenceGroup sg = av.getSelectionGroup(); - if(groupEditing && sg==null) - return; + SequenceI seq = av.alignment.getSequenceAt(startseq); - SequenceI seq = av.alignment.getSequenceAt(startseq); - StringBuffer message = new StringBuffer(); - if (groupEditing) - message.append("Edit group:"); - else - message.append("Edit sequence: "+seq.getName()); + if (!groupEditing && av.hasHiddenRows) + { + if (av.hiddenRepSequences!=null + && av.hiddenRepSequences.containsKey(seq)) + { + sg = (SequenceGroup)av.hiddenRepSequences.get(seq); + groupEditing = true; + } + } + + StringBuffer message = new StringBuffer(); + if (groupEditing) + { + message.append("Edit group:"); + if (editCommand == null) + editCommand = new EditCommand("Edit Group"); + } + else + { + message.append("Edit sequence: " + seq.getName()); + String label = seq.getName(); + if(label.length()>10) + label = label.substring(0,10); + if(editCommand==null) + editCommand = new EditCommand("Edit "+label); + } + + if(insertGap) + message.append(" insert "); + else + message.append(" delete "); + + message.append(Math.abs(startres-lastres)+" gaps."); + ap.alignFrame.statusBar.setText(message.toString()); - if(insertGap) - message.append(" insert "); - else - message.append(" delete "); - message.append(Math.abs(startres-lastres)+" gaps."); - ap.alignFrame.statusBar.setText(message.toString()); + //Are we editing within a selection group? + if (groupEditing + || (sg != null && sg.getSequences(av.hiddenRepSequences).contains(seq))) + { + fixedColumns = true; + + //sg might be null as the user may only see 1 sequence, + //but the sequence represents a group + if (sg == null) + { + sg = (SequenceGroup) av.hiddenRepSequences.get(seq); + } + fixedLeft = sg.getStartRes(); + fixedRight = sg.getEndRes(); - //Are we editing within a selection group? - if (groupEditing - || (sg != null && sg.sequences.contains(seq))) + if ( (startres < fixedLeft && lastres >= fixedLeft) + || (startres >= fixedLeft && lastres < fixedLeft) + || (startres > fixedRight && lastres <=fixedRight) + || (startres <= fixedRight && lastres > fixedRight)) { - fixedColumns = true; + endEditing(); + return; + } + + if (fixedLeft > startres) + { + fixedRight = fixedLeft - 1; + fixedLeft = 0; + } + else if (fixedRight < startres) + { + fixedLeft = fixedRight; + fixedRight = -1; + } + } + - fixedLeft = sg.getStartRes(); - fixedRight = sg.getEndRes(); + if(av.hasHiddenColumns ) + { + fixedColumns = true; + int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres); + int y2 = av.getColumnSelection().getHiddenBoundaryRight(startres); - if ( (startres < fixedLeft && lastres >= fixedLeft) - || (startres >= fixedLeft && lastres < fixedLeft) - || (startres > fixedRight && lastres <=fixedRight) - || (startres <= fixedRight && lastres > fixedRight)) + if ( (insertGap && startres > y1 && lastres < y1) + || (!insertGap && startres < y2 && lastres > y2)) { endEditing(); return; } - if (fixedLeft > startres) - { - fixedRight = fixedLeft - 1; - fixedLeft = 0; - } - else if (fixedRight < startres) + //System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~"); + //Selection spans a hidden region + if(fixedLefty2 || fixedRight==-1)) { - fixedLeft = fixedRight; - fixedRight = -1; + if(startres>=y2) + { + fixedLeft = y2; + } + else + { + fixedRight = y2 - 1; + } } - } + } - if (groupEditing) + if (groupEditing) + { + Vector vseqs = sg.getSequences(av.hiddenRepSequences); + int g, groupSize = vseqs.size(); + SequenceI[] groupSeqs = new SequenceI[groupSize]; + for (g = 0; g < groupSeqs.length; g++) + groupSeqs[g] = (SequenceI) vseqs.elementAt(g); + + // drag to right + if (insertGap) { - // drag to right - if (insertGap) + //If the user has selected the whole sequence, and is dragging to + // the right, we can still extend the alignment and selectionGroup + if( sg.getStartRes() == 0 + && sg.getEndRes() == fixedRight + && sg.getEndRes() == av.alignment.getWidth()-1 + ) + { + sg.setEndRes(av.alignment.getWidth() + startres - lastres); + fixedRight = sg.getEndRes(); + } + + // Is it valid with fixed columns?? + // Find the next gap before the end + // of the visible region boundary + boolean blank = false; + for (fixedRight = fixedRight; + fixedRight > lastres; + fixedRight--) { - //If the user has selected the whole sequence, and is dragging to - // the right, we can still extend the alignment and selectionGroup - if(sg.getStartRes() == 0 && sg.getEndRes() + 1 == av.alignment.getWidth()) - { - sg.setEndRes(av.alignment.getWidth() + startres - lastres); - fixedRight = sg.getEndRes(); - } + blank = true; - // Is it valid with fixed columns?? - // Find the next gap before the end - // of the visible region boundary - boolean blank = false; - for (fixedRight = fixedRight; - fixedRight > lastres; - fixedRight--) + for (g = 0; g < groupSize; g++) { - blank = true; - for (int s = 0; s < sg.getSize(); s++) + for (int j = 0; j < startres - lastres; j++) { - seq = sg.getSequenceAt(s); - for (int j = 0; j < startres - lastres; j++) + if (!jalview.util.Comparison.isGap( + groupSeqs[g].getCharAt(fixedRight - j))) { - if (!jalview.util.Comparison.isGap( - seq.getCharAt(fixedRight - j))) - { - blank = false; - break; - } + blank = false; + break; } } - if (blank) - break; } + if (blank) + break; + } - if (!blank) + if (!blank) + { + if(sg.getSize() == av.alignment.getHeight() ) { - if(sg.getSize() == av.alignment.getHeight()) - { - //We can still insert gaps if the selectionGroup - //contains all the sequences - sg.setEndRes(sg.getEndRes()+startres-lastres); - fixedRight = av.alignment.getWidth()+startres-lastres; - } - else + if((av.hasHiddenColumns + && startresalWidth) + alWidth = hwidth; + } + //We can still insert gaps if the selectionGroup + //contains all the sequences + sg.setEndRes(sg.getEndRes()+startres-lastres); + fixedRight = alWidth+startres-lastres; + } + else + { + endEditing(); + return; } } + } - // drag to left - else if(!insertGap) - { - /// Are we able to delete? - // ie are all columns blank? + // drag to left + else if(!insertGap) + { + /// Are we able to delete? + // ie are all columns blank? - for (int s = 0; s < sg.getSize(); s++) + for (g = 0; g < groupSize; g++) + { + for (int j = startres; j < lastres; j++) { - seq = sg.getSequenceAt(s); - - for (int j = startres; j < lastres; j++) + if (groupSeqs[g].getLength() <= j) { - if (seq.getSequence().length() <= j) - { - continue; - } + continue; + } - if (!jalview.util.Comparison.isGap( - seq.getSequence().charAt(j))) - { - // Not a gap, block edit not valid - endEditing(); - return; - } + if (!jalview.util.Comparison.isGap( + groupSeqs[g].getCharAt(j))) + { + // Not a gap, block edit not valid + endEditing(); + return; } } } + } - - for (int i = 0; i < sg.getSize(); i++) + if (insertGap) { - seq = sg.getSequenceAt(i); - - if (insertGap) + // dragging to the right + if (fixedColumns && fixedRight != -1) { - // dragging to the right for (int j = lastres; j < startres; j++) { - if (fixedColumns && fixedRight != -1) - { - insertChar(j, seq, fixedRight); - } - else - insertChar(j, seq); + insertChar(j, groupSeqs, fixedRight); } } else { - // dragging to the left + editCommand.appendEdit(EditCommand.INSERT_GAP, + groupSeqs, + startres, startres-lastres, + av.getGapCharacter(), + true); + } + } + else + { + // dragging to the left + if (fixedColumns && fixedRight != -1) + { for (int j = lastres; j > startres; j--) { - if (fixedColumns && fixedRight != -1) - { - deleteChar(startres, seq, fixedRight); - } - else - { - deleteChar(startres, seq); - } + deleteChar(startres, groupSeqs, fixedRight); } } + else + editCommand.appendEdit(EditCommand.DELETE_GAP, + groupSeqs, + startres, lastres - startres, + av.getGapCharacter(), + true); + } - } - else /////Editing a single sequence/////////// + } + else /////Editing a single sequence/////////// + { + if (insertGap) { - if (insertGap) + // dragging to the right + if (fixedColumns && fixedRight != -1) { - // dragging to the right for (int j = lastres; j < startres; j++) { - if (fixedColumns && fixedRight != -1) - { - if (sg.getStartRes() == 0 - && sg.getEndRes() + 1 == av.alignment.getWidth() - && !jalview.util.Comparison.isGap(seq.getCharAt(fixedRight))) - { - //Single sequence edit, whole sequence selected, - //extend the selection group - sg.setEndRes(av.alignment.getWidth() -1 + startres - lastres); - fixedColumns = false; - insertChar(j, seq); - } - else - insertChar(j, seq, fixedRight); - } - else - insertChar(j, seq); + insertChar(j, new SequenceI[]{seq}, fixedRight); } } else { - // dragging to the left + editCommand.appendEdit(EditCommand.INSERT_GAP, + new SequenceI[] + {seq}, + lastres, startres-lastres, + av.getGapCharacter(), + true); + } + } + else + { + // dragging to the left + if (fixedColumns && fixedRight != -1) + { for (int j = lastres; j > startres; j--) { - if (fixedColumns && fixedRight != -1) - { - deleteChar(startres, seq, fixedRight); - } - else + if (!jalview.util.Comparison.isGap(seq.getCharAt(startres))) { - deleteChar(startres, seq); + endEditing(); + break; } + deleteChar(startres, new SequenceI[]{seq}, fixedRight); + } + } + else + { + //could be a keyboard edit trying to delete none gaps + int max=0; + for(int m = startres; m0) + { + editCommand.appendEdit(EditCommand.DELETE_GAP, + new SequenceI[] + {seq}, + startres, max, + av.getGapCharacter(), + true); } } } + } - lastres = startres; - seqCanvas.repaint(); - } + lastres = startres; + seqCanvas.repaint(); + } - /** - * DOCUMENT ME! - * - * @param j DOCUMENT ME! - * @param seq DOCUMENT ME! - */ - void insertChar(int j, SequenceI seq) - { - seq.insertCharAt(j, av.getGapCharacter()); - seqEditOccurred = true; - } - void insertChar(int j, SequenceI seq, int fixedColumn) + void insertChar(int j, SequenceI [] seq, int fixedColumn) + { + int blankColumn = fixedColumn; + for(int s=0; s j, theres a boundary after the gap insertion - int blankColumn = fixedColumn; + for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { - if (jalview.util.Comparison.isGap(seq.getCharAt(blankColumn))) + if (jalview.util.Comparison.isGap(seq[s].getCharAt(blankColumn))) { //Theres a space, so break and insert the gap break; @@ -945,82 +1065,41 @@ public class SeqPanel if (blankColumn <= j) { + blankColumn = fixedColumn; endEditing(); return; } - - if (!jalview.util.Comparison.isGap(seq.getCharAt(blankColumn))) - { - //Just Checking - System.out.println("Tried removing residue (INSERT)"+seq.getCharAt(fixedColumn)); - return; - } - - seq.deleteCharAt(blankColumn); - seq.insertCharAt(j, av.getGapCharacter()); - seqEditOccurred = true; } - void deleteChar(int j, SequenceI seq, int fixedColumn) - { - if (!jalview.util.Comparison.isGap(seq.getCharAt(j))) - { - ap.alignFrame.statusBar.setText( - "End editing: Tried removing residue " + seq.getCharAt(j)); - return; - } - - seq.deleteCharAt(j); - seq.insertCharAt(fixedColumn, av.getGapCharacter()); - seqEditOccurred = true; - } + editCommand.appendEdit(EditCommand.DELETE_GAP, + seq, + blankColumn, 1, av.getGapCharacter(), true); - /** - * DOCUMENT ME! - * - * @param j DOCUMENT ME! - * @param seq DOCUMENT ME! - */ - void deleteChar(int j, SequenceI seq) - { - if (!jalview.util.Comparison.isGap(seq.getCharAt(j))) - { - ap.alignFrame.statusBar.setText( - "End editing: Tried removing residue " + seq.getCharAt(j)); - return; - } + editCommand.appendEdit(EditCommand.INSERT_GAP, + seq, + j, 1, av.getGapCharacter(), + true); - seq.deleteCharAt(j); - seqEditOccurred = true; - seqCanvas.repaint(); - } + } - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - */ - void editOccurred() - { - if (!seqEditOccurred) - { - ap.alignFrame.historyList.pop(); - ap.alignFrame.updateEditMenuBar(); - } + void deleteChar(int j, SequenceI [] seq, int fixedColumn) + { - endEditing(); + editCommand.appendEdit(EditCommand.DELETE_GAP, + seq, + j, 1, av.getGapCharacter(), true); - av.firePropertyChange("alignment", null,av.getAlignment().getSequences()); + editCommand.appendEdit(EditCommand.INSERT_GAP, + seq, + fixedColumn, 1, av.getGapCharacter(), true); + } - } ////////////////////////////////////////// /////Everything below this is for defining the boundary of the rubberband ////////////////////////////////////////// public void doMousePressedDefineMode(MouseEvent evt) { - - if (scrollThread != null) { scrollThread.running = false; @@ -1058,7 +1137,7 @@ public class SeqPanel } } - else if (!stretchGroup.sequences.contains(sequence) + else if (!stretchGroup.getSequences(null).contains(sequence) || stretchGroup.getStartRes() > res || stretchGroup.getEndRes() < res) { @@ -1081,15 +1160,6 @@ public class SeqPanel av.setSelectionGroup(stretchGroup); } - if (av.cursorMode) - { - seqCanvas.cursorX = findRes(evt); - seqCanvas.cursorY = findSeq(evt); - seqCanvas.repaint(); - return; - } - - // DETECT RIGHT MOUSE BUTTON IN AWT if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == @@ -1118,9 +1188,17 @@ public class SeqPanel this.add(popup); popup.show(this, evt.getX(), evt.getY()); ap.repaint(); + return; } - else + + if (av.cursorMode) { + seqCanvas.cursorX = findRes(evt); + seqCanvas.cursorY = findSeq(evt); + seqCanvas.repaint(); + return; + } + //Only if left mouse button do we want to change group sizes if (stretchGroup == null) @@ -1145,19 +1223,6 @@ public class SeqPanel } } - - if (stretchGroup != null && stretchGroup.getEndRes() == res) - { - // Edit end res position of selected group - changeEndRes = true; - } - - else if (stretchGroup != null && stretchGroup.getStartRes() == res) - { - // Edit end res position of selected group - changeStartRes = true; - } - } } public void doMouseReleasedDefineMode(MouseEvent evt) @@ -1171,11 +1236,18 @@ public class SeqPanel { if (stretchGroup.cs instanceof ClustalxColourScheme) { - ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup. - sequences, + ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX( + stretchGroup.getSequences(av.hiddenRepSequences), stretchGroup.getWidth()); } + if (stretchGroup.cs instanceof Blosum62ColourScheme + || stretchGroup.cs instanceof PIDColourScheme + || stretchGroup.cs.conservationApplied() + || stretchGroup.cs.getThreshold() > 0) + stretchGroup.recalcConservation(); + + if (stretchGroup.cs.conservationApplied()) { SliderPanel.setConservationSlider(ap, stretchGroup.cs, @@ -1191,7 +1263,7 @@ public class SeqPanel changeEndRes = false; changeStartRes = false; stretchGroup = null; - PaintRefresher.Refresh(av.alignment); + PaintRefresher.Refresh(ap, av.getSequenceSetId()); ap.repaint(); } @@ -1216,7 +1288,7 @@ public class SeqPanel y = av.alignment.getHeight() -1; } - if(res>av.alignment.getWidth()) + if(res>=av.alignment.getWidth()) res = av.alignment.getWidth()-1; if (stretchGroup.getEndRes() == res) @@ -1275,7 +1347,7 @@ public class SeqPanel Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); - if (stretchGroup.sequences.contains(nextSeq)) + if (stretchGroup.getSequences(null).contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); } @@ -1333,6 +1405,28 @@ public class SeqPanel } } + void scrollCanvas(MouseEvent evt) + { + if(evt==null) + { + if(scrollThread!=null) + { + scrollThread.running = false; + scrollThread = null; + } + mouseDragging = false; + } + else + { + if (scrollThread == null) + scrollThread = new ScrollThread(); + + mouseDragging = true; + scrollThread.setEvent(evt); + } + + } + // this class allows scrolling off the bottom of the visible alignment class ScrollThread extends Thread @@ -1376,12 +1470,12 @@ public class SeqPanel if (mouseDragging && evt.getX() < 0) { - running = ap.scrollRight(true); + running = ap.scrollRight(false); } else if (mouseDragging && evt.getX() >= getSize().width) { - running = ap.scrollRight(false); + running = ap.scrollRight(true); } }