From: amwaterhouse Date: Fri, 7 Apr 2006 11:27:19 +0000 (+0000) Subject: Scroll cursor wrapped alignment X-Git-Tag: Release_2_08~41 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=25e0e98d70d32d81c952a5927e847deeee76b810;p=jalview.git Scroll cursor wrapped alignment --- diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index b04946f..cc89098 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -219,19 +219,25 @@ public class AlignmentPanel extends Panel implements AdjustmentListener } else { - int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel. - seqCanvas.getSize().width); - if (start < av.getStartRes() || start > (av.getStartRes() + cwidth)) - { - vscroll.setValue(start / cwidth); - av.startRes = vscroll.getValue() * cwidth; - } + scrollToWrappedVisible(start); } } repaint(); } + void scrollToWrappedVisible(int res) + { + int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas. + getWidth()); + if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth)) + { + vscroll.setValue(res / cwidth); + av.startRes = vscroll.getValue() * cwidth; + } + } + + public OverviewPanel getOverviewPanel() { return overviewPanel; diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 55bc65a..987b0b8 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -140,26 +140,32 @@ public class SeqPanel endEditing(); - while (seqCanvas.cursorY < av.startSeq) + if (av.wrapAlignment) { - ap.scrollUp(true); + ap.scrollToWrappedVisible(seqCanvas.cursorX); } - while (seqCanvas.cursorY + 1 > av.endSeq) - { - ap.scrollUp(false); - } - while (seqCanvas.cursorX < av.startRes) + else { + while (seqCanvas.cursorY < av.startSeq) + { + ap.scrollUp(true); + } + while (seqCanvas.cursorY + 1 > av.endSeq) + { + ap.scrollUp(false); + } + while (seqCanvas.cursorX < av.startRes) + { - if(!ap.scrollRight(false)) - break; - } - while (seqCanvas.cursorX > av.endRes) - { - if(!ap.scrollRight(true)) - break; + if (!ap.scrollRight(false)) + break; + } + while (seqCanvas.cursorX > av.endRes) + { + if (!ap.scrollRight(true)) + break; + } } - setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY), seqCanvas.cursorX, seqCanvas.cursorY); diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 00f27aa..2800f85 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -371,16 +371,21 @@ public class AlignmentPanel extends GAlignmentPanel } else { - int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); - if( start(av.getStartRes()+cwidth) ) - { - vscroll.setValue(start / cwidth); - av.startRes = vscroll.getValue() * cwidth; - } + scrollToWrappedVisible(start); } } } + void scrollToWrappedVisible(int res) + { + int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); + if( res<=av.getStartRes() || res>=(av.getStartRes()+cwidth) ) + { + vscroll.setValue(res / cwidth); + av.startRes = vscroll.getValue() * cwidth; + } + } + /** * DOCUMENT ME! * diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 9b2f5f4..933ca04 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -235,25 +235,34 @@ public class SeqPanel extends JPanel implements MouseListener, endEditing(); - while (seqCanvas.cursorY < av.startSeq) + if(av.wrapAlignment) { - ap.scrollUp(true); + ap.scrollToWrappedVisible(seqCanvas.cursorX); } - while (seqCanvas.cursorY + 1 > av.endSeq) - { - ap.scrollUp(false); - } - while (seqCanvas.cursorX < av.startRes) - { - if(!ap.scrollRight(false)) - break; - } - while (seqCanvas.cursorX > av.endRes) + else { - if(!ap.scrollRight(true)) - break; + while (seqCanvas.cursorY < av.startSeq) + { + ap.scrollUp(true); + } + while (seqCanvas.cursorY + 1 > av.endSeq) + { + ap.scrollUp(false); + } + if (!av.wrapAlignment) + { + while (seqCanvas.cursorX < av.startRes) + { + if (!ap.scrollRight(false)) + break; + } + while (seqCanvas.cursorX > av.endRes) + { + if (!ap.scrollRight(true)) + break; + } + } } - setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY), seqCanvas.cursorX, seqCanvas.cursorY);