From: gmungoc Date: Fri, 24 Aug 2018 14:32:44 +0000 (+0100) Subject: JAL-3087 include full alignment height in repeating wrapped height X-Git-Tag: Release_2_10_5~47 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=72ac4a5ecabebe8c96feb08c32e5ce1adccc7d46;p=jalview.git JAL-3087 include full alignment height in repeating wrapped height --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 8f315bd..1753a64 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -658,7 +658,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI calculateWrappedGeometry(canvasWidth, canvasHeight); /* - * draw one width at a time (including any scales or annotation shown), + * draw one width at a time (excluding any scales or annotation shown), * until we have run out of either alignment or vertical space available */ int ypos = wrappedSpaceAboveAlignment; @@ -709,7 +709,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI */ wrappedRepeatHeightPx = wrappedSpaceAboveAlignment; // add sequences - wrappedRepeatHeightPx += av.getRanges().getViewportHeight() + wrappedRepeatHeightPx += av.getAlignment().getHeight() * charHeight; // add annotations panel height if shown wrappedRepeatHeightPx += getAnnotationHeight(); diff --git a/test/jalview/gui/SeqCanvasTest.java b/test/jalview/gui/SeqCanvasTest.java index ee1270e..bcb1cfd 100644 --- a/test/jalview/gui/SeqCanvasTest.java +++ b/test/jalview/gui/SeqCanvasTest.java @@ -48,17 +48,17 @@ public class SeqCanvasTest AlignmentI al = av.getAlignment(); assertEquals(al.getWidth(), 157); assertEquals(al.getHeight(), 15); + av.getRanges().setStartEndSeq(0, 14); + + SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; av.setWrapAlignment(true); - av.getRanges().setStartEndSeq(0, 14); av.setFont(new Font("SansSerif", Font.PLAIN, 14), true); int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); assertEquals(charHeight, 17); assertEquals(charWidth, 12); - SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; - /* * first with scales above, left, right */ @@ -298,4 +298,42 @@ public class SeqCanvasTest testee.calculateWrappedGeometry(canvasWidth, canvasHeight); assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); } + + /** + * Test simulates loading an unwrapped alignment, shrinking it vertically so + * not all sequences are visible, then changing to wrapped mode. The ranges + * endSeq should be unchanged, but the vertical repeat height should include + * all sequences. + */ + @Test(groups = "Functional") + public void testCalculateWrappedGeometry_fromScrolled() + { + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + "examples/uniref50.fa", DataSourceType.FILE); + AlignViewport av = af.getViewport(); + AlignmentI al = av.getAlignment(); + assertEquals(al.getWidth(), 157); + assertEquals(al.getHeight(), 15); + av.getRanges().setStartEndSeq(0, 3); + av.setShowAnnotation(false); + av.setScaleAboveWrapped(true); + + SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; + + av.setWrapAlignment(true); + av.setFont(new Font("SansSerif", Font.PLAIN, 14), true); + int charHeight = av.getCharHeight(); + int charWidth = av.getCharWidth(); + assertEquals(charHeight, 17); + assertEquals(charWidth, 12); + + int canvasWidth = 400; + int canvasHeight = 300; + testee.calculateWrappedGeometry(canvasWidth, canvasHeight); + + assertEquals(av.getRanges().getEndSeq(), 3); // unchanged + int repeatingHeight = (int) PA.getValue(testee, + "wrappedRepeatHeightPx"); + assertEquals(repeatingHeight, charHeight * (2 + al.getHeight())); + } }