From fa1b18fd88ff97d45a561afef3df4f2c023f0145 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 14 Dec 2004 11:22:30 +0000 Subject: [PATCH] Selection of sequences is continuous --- src/jalview/gui/SeqPanel.java | 85 +++++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 3680503..ad75942 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -39,7 +39,8 @@ public class SeqPanel extends JPanel addMouseMotionListener( new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) - { doMouseMoved(evt); } + { doMouseMoved(evt); } + public void mouseDragged(MouseEvent evt) { if(av.groupDefiningMode) @@ -143,7 +144,6 @@ public class SeqPanel extends JPanel res = (int)((y/chunkHeight)*(getWidth()/av.charWidth)) + x/av.getCharWidth() + av.getStartRes(); - System.out.println( ((y/chunkHeight)*(getWidth()/av.charWidth)) +" "+((x / av.getCharWidth()) + av.getStartRes()) ); y %= chunkHeight; seq = y / av.getCharHeight() + av.getStartSeq(); @@ -310,7 +310,7 @@ public class SeqPanel extends JPanel void updateConservation(int i) { - Alignment al = (Alignment) av.getAlignment(); + /* Alignment al = (Alignment) av.getAlignment(); SequenceGroup sg = av.alignment.findGroup( al.getSequenceAt(i)); if(sg==null || !(sg.cs instanceof ConservationColourScheme)) return; @@ -324,28 +324,29 @@ public class SeqPanel extends JPanel c.verdict(false, 100); sg.setConservation(c); ConservationColourScheme ccs = (ConservationColourScheme)sg.cs; - ccs.conserve = c; + ccs.conserve = c;*/ } + int oldSeq = -1; public void doMousePressedDefineMode(MouseEvent evt) { int res = evt.getX()/av.getCharWidth() + av.getStartRes(); int seq = evt.getY()/av.getCharHeight() + av.getStartSeq(); + oldSeq = seq; stretchGroup = av.getRubberbandGroup(); + if(stretchGroup == null) stretchGroup = av.alignment.findGroup((Sequence)av.getAlignment().getSequenceAt(seq)); - else if(!stretchGroup.sequences.contains((Sequence)av.getAlignment().getSequenceAt(seq)) - || stretchGroup.getStartRes()res) + + else if(!stretchGroup.sequences.contains((Sequence)av.getAlignment().getSequenceAt(seq)) + || stretchGroup.getStartRes()>res + || stretchGroup.getEndRes() oldSeq) + dragDirection = 1; + else if (y < oldSeq) + dragDirection = -1; + + while (y != oldSeq) { - if(newSeqGroup !=null) - av.getAlignment().removeFromGroup(newSeqGroup, seq ); + // This routine ensures we don't skip any sequences, as the + // selection is quite slow. + Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); - if(stretchGroup!=null) - stretchGroup.addSequence( seq ); - }*/ + oldSeq += dragDirection; + Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + + if (stretchGroup.sequences.contains(nextSeq)) + { + stretchGroup.deleteSequence(seq); + stretchGroup.deleteSequence(nextSeq); + } + else + { + stretchGroup.addSequence(seq); + stretchGroup.addSequence(nextSeq); + } + } + oldSeq = y; seqCanvas.paintFlag = true; repaint(); - } + } -- 1.7.10.2