From 4fe95a3bc0c1aff8782a62c830215c1188aed7ae Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 11 Oct 2017 18:46:16 +0100 Subject: [PATCH] JAL-2609 tests updated for revised label width --- test/jalview/gui/SeqCanvasTest.java | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/jalview/gui/SeqCanvasTest.java b/test/jalview/gui/SeqCanvasTest.java index 3722e47..5c6fa5d 100644 --- a/test/jalview/gui/SeqCanvasTest.java +++ b/test/jalview/gui/SeqCanvasTest.java @@ -48,8 +48,8 @@ public class SeqCanvasTest av.setScaleLeftWrapped(true); av.setScaleRightWrapped(true); FontMetrics fm = SwingUtilities2.getFontMetrics(testee, av.getFont()); - int labelWidth = fm.stringWidth("00000"); // width of 3 digits and 2 spaces - assertEquals(labelWidth, 45); // note this is not 5 * charWidth + int labelWidth = fm.stringWidth("000") + charWidth; + assertEquals(labelWidth, 39); // 3 x 9 + charWidth /* * width 400 pixels leaves (400 - 2*labelWidth) for residue columns @@ -117,8 +117,8 @@ public class SeqCanvasTest assertEquals(wrappedWidth, 19); /* - * turn off West scale - adds labelWidth (45) to available for residues - * which with the 11 remainder makes 56 which is 4 more charWidths rem 8 + * turn off West scale - adds labelWidth (39) to available for residues + * which with the 11 remainder makes 50 which is 4 more charWidths rem 2 */ av.setScaleLeftWrapped(false); wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, @@ -126,9 +126,9 @@ public class SeqCanvasTest assertEquals(wrappedWidth, 23); /* - * add 4 pixels to width to fit in another whole residue column + * add 10 pixels to width to fit in another whole residue column */ - canvasWidth += 3; + canvasWidth += 9; wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, canvasHeight); assertEquals(wrappedWidth, 23); @@ -138,7 +138,7 @@ public class SeqCanvasTest assertEquals(wrappedWidth, 24); /* - * turn off East scale to gain 45 more pixels (3 columns remainder 9) + * turn off East scale to gain 39 more pixels (3 columns remainder 3) */ av.setScaleRightWrapped(false); wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, @@ -146,15 +146,19 @@ public class SeqCanvasTest assertEquals(wrappedWidth, 27); /* - * add 3 pixels to width to gain a residue column + * add 9 pixels to width to gain a residue column */ - canvasWidth += 3; + canvasWidth += 8; + wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, + canvasHeight); + assertEquals(wrappedWidth, 27); + canvasWidth += 1; wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, canvasHeight); assertEquals(wrappedWidth, 28); /* - * now West but not East scale - lose 45 pixels or 4 columns + * now West but not East scale - lose 39 pixels or 4 columns */ av.setScaleLeftWrapped(true); wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, @@ -162,9 +166,9 @@ public class SeqCanvasTest assertEquals(wrappedWidth, 24); /* - * adding 9 pixels to width regains one column + * adding 3 pixels to width regains one column */ - canvasWidth += 8; + canvasWidth += 2; wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, canvasHeight); assertEquals(wrappedWidth, 24); @@ -213,8 +217,8 @@ public class SeqCanvasTest av.setScaleLeftWrapped(true); av.setScaleRightWrapped(true); FontMetrics fm = SwingUtilities2.getFontMetrics(testee, av.getFont()); - int labelWidth = fm.stringWidth("00000"); // width of 3 digits and 2 spaces - assertEquals(labelWidth, 45); // note this is not 5 * charWidth + int labelWidth = fm.stringWidth("000") + charWidth; + assertEquals(labelWidth, 39); // 3 x 9 + charWidth int annotationHeight = testee.getAnnotationHeight(); /* -- 1.7.10.2