From 9a23ee1cee6a2ef0f797fd8e1a6a950e66ef6e72 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:15:18 +0000 Subject: [PATCH] Scroll implemented for applet editing --- src/jalview/appletgui/SeqPanel.java | 229 +++++++++++++++++++++-------------- 1 file changed, 135 insertions(+), 94 deletions(-) diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index daff328..e29f4e1 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -255,7 +255,9 @@ public class SeqPanel // use aa to see if the mouse pointer is on a - if (av.showSequenceFeatures && sequence.getSequenceFeatures()!=null) + if (av.showSequenceFeatures + && sequence.getSequenceFeatures()!=null + && av.featuresDisplayed!=null) { int index = 0; sequence.getSequenceFeatures(); @@ -429,7 +431,11 @@ public class SeqPanel } else { - + if(scrollThread!=null) + { + scrollThread.running = false; + scrollThread = null; + } break; } } @@ -438,17 +444,21 @@ public class SeqPanel } } + mouseDragging = true; + if (res > av.endRes || res < av.startRes) + { + mouseExited(evt); + } + + if (scrollThread != null) + scrollThread.setEvent(evt); + + endEdit = res; lastres = res; seqCanvas.repaint(); } - public void drawChars(int seqstart, int seqend, int start) - { - seqCanvas.drawPanel(seqCanvas.gg, start, av.getEndRes(), seqstart, seqend, 0); - seqCanvas.repaint(); - } - public void insertChar(int j, int seq) { av.alignment.getSequenceAt(seq).insertCharAt(j, av.getGapCharacter()); @@ -481,6 +491,12 @@ public class SeqPanel int oldSeq = -1; public void doMousePressedDefineMode(MouseEvent evt) { + if (scrollThread != null) + { + scrollThread.running = false; + scrollThread = null; + } + int res = findRes(evt); int seq = findSeq(evt); oldSeq = seq; @@ -589,23 +605,25 @@ public class SeqPanel public void doMouseReleasedDefineMode(MouseEvent evt) { - if(mouseDragging) - { - stretchGroup.recalcConservation(); - mouseDragging = false; - } - if (stretchGroup == null) { - return; + return; } if(stretchGroup.cs!=null) { + if (stretchGroup.cs instanceof ClustalxColourScheme) + { + ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup. + sequences, + stretchGroup.getWidth()); + } + if (stretchGroup.cs.conservationApplied()) { SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()); + stretchGroup.recalcConservation(); } else { @@ -616,121 +634,143 @@ public class SeqPanel changeEndRes = false; changeStartRes = false; stretchGroup = null; - seqCanvas.repaint(); + PaintRefresher.Refresh(av.alignment); ap.repaint(); } - boolean remove = false; public void doMouseDraggedDefineMode(MouseEvent evt) { int res = findRes(evt); int y = findSeq(evt); if(wrappedBlock!=startWrapBlock) - return; + return; - if(y>=av.alignment.getHeight()) - y = av.alignment.getHeight()-1; + if (stretchGroup == null) + { + return; + } - if (stretchGroup == null) - { - return; - } + mouseDragging = true; - if (res > av.alignment.getWidth()) - { - res = av.alignment.getWidth() - 1; - } - if (stretchGroup.getEndRes() == res) - { - // Edit end res position of selected group - changeEndRes = true; - } + if(y > av.alignment.getHeight()) + { + y = av.alignment.getHeight() -1; + } - else if (stretchGroup.getStartRes() == res) - { - // Edit start res position of selected group - changeStartRes = true; - } + if(res>av.alignment.getWidth()) + res = av.alignment.getWidth()-1; - if (res < av.getStartRes()) - { - res = av.getStartRes(); - } - else if (res > av.getEndRes() && !av.getWrapAlignment()) - { - res = av.getEndRes(); - } + if (stretchGroup.getEndRes() == res) + { + // Edit end res position of selected group + changeEndRes = true; + } + else if (stretchGroup.getStartRes() == res) + { + // Edit start res position of selected group + changeStartRes = true; + } - if (changeEndRes) - { - if (res > stretchGroup.getStartRes() - 1) + if (res < 0) { - stretchGroup.setEndRes(res); + res = 0; } - } - else if (changeStartRes) - { - if (res < stretchGroup.getEndRes() + 1) + + if (changeEndRes) { - stretchGroup.setStartRes(res); + if (res > (stretchGroup.getStartRes() - 1)) + { + stretchGroup.setEndRes(res); + } + } + else if (changeStartRes) + { + if (res < (stretchGroup.getEndRes() + 1)) + { + stretchGroup.setStartRes(res); + } } - } - int dragDirection = 0; - if (y > oldSeq) - { - dragDirection = 1; - } - else if (y < oldSeq) - { - dragDirection = -1; - } + int dragDirection = 0; - while (y != oldSeq && oldSeq > 0 && y < av.alignment.getHeight()) - { - // This routine ensures we don't skip any sequences, as the - // selection is quite slow. - Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + if (y > oldSeq) + { + dragDirection = 1; + } + else if (y < oldSeq) + { + dragDirection = -1; + } + + + while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight())) + { + // This routine ensures we don't skip any sequences, as the + // selection is quite slow. + Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + + oldSeq += dragDirection; + + if(oldSeq<0) + break; + + Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + + if (stretchGroup.sequences.contains(nextSeq)) + { + stretchGroup.deleteSequence(seq, false); + } + else + { + if (seq != null) + { + stretchGroup.addSequence(seq, false); + } + + stretchGroup.addSequence(nextSeq, false); + } + } - oldSeq += dragDirection; - Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + if(oldSeq < 0) + oldSeq = -1; - if (stretchGroup.sequences.contains(nextSeq)) + + if(res>av.endRes || resav.endSeq) { - stretchGroup.deleteSequence(seq, false); + mouseExited(evt); } - else + + if (scrollThread != null) { - if (seq != null) - { - stretchGroup.addSequence(seq, false); - } - stretchGroup.addSequence(nextSeq, false); + scrollThread.setEvent(evt); } + + seqCanvas.repaint(); } - oldSeq = y; - mouseDragging = true; - if (scrollThread != null) + + public void mouseEntered(MouseEvent e) { - scrollThread.setEvent(evt); - } + if (oldSeq < 0) + oldSeq = 0; - seqCanvas.repaint(); - } + if (scrollThread != null) + { + scrollThread.running = false; + scrollThread = null; + } + } - public void mouseEntered(MouseEvent e) + public void mouseExited(MouseEvent e) { - if (editingSeqs && scrollThread != null) + if (av.getWrapAlignment()) { - scrollThread.running = false; + return; } - } - public void mouseExited(MouseEvent e) - { - if (mouseDragging) + if (mouseDragging && scrollThread==null) { scrollThread = new ScrollThread(); } @@ -762,6 +802,7 @@ public class SeqPanel running = true; while (running) { + if (evt != null) { -- 1.7.10.2