From: kiramt Date: Fri, 22 Sep 2017 11:56:56 +0000 (+0100) Subject: JAL-2739 Change to updateLayout width calculation X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e760e4772fc65a111dbb91358281dd182b53b3d0;p=jalview.git JAL-2739 Change to updateLayout width calculation --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index ba9fc11..baac692 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -640,9 +640,9 @@ public class AlignmentPanel extends GAlignmentPanel implements } else { - int widthInRes = (canvasWidth / av.getCharWidth()) - 1; + int widthInRes = (canvasWidth / av.getCharWidth()); int heightInSeq = (getSeqPanel().seqCanvas.getHeight() - / av.getCharHeight()) - 1; + / av.getCharHeight()); vpRanges.setViewportWidth(widthInRes); vpRanges.setViewportHeight(heightInSeq); diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index b228ba1..2819dbf 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -21,6 +21,7 @@ package jalview.gui; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotEquals; import jalview.bin.Cache; import jalview.bin.Jalview; @@ -218,4 +219,31 @@ public class AlignmentPanelTest .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden // columns } + + /** + * Test that update layout reverts to original (unwrapped) values for endRes + * and endSeq when switching from wrapped to unwrapped mode (JAL-2739) + */ + @Test(groups = "Functional") + public void TestUpdateLayout_endRes() + { + // get details of original alignment dimensions + ViewportRanges ranges = af.getViewport().getRanges(); + int endres = ranges.getEndRes(); + + // wrap + af.alignPanel.getAlignViewport().setWrapAlignment(true); + af.alignPanel.updateLayout(); + + // endRes changes + assertNotEquals(ranges.getEndRes(), endres); + + // unwrap + af.alignPanel.getAlignViewport().setWrapAlignment(false); + af.alignPanel.updateLayout(); + + // endRes and endSeq back to original values + assertEquals(ranges.getEndRes(), endres); + + } }