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;
*/
wrappedRepeatHeightPx = wrappedSpaceAboveAlignment;
// add sequences
- wrappedRepeatHeightPx += av.getRanges().getViewportHeight()
+ wrappedRepeatHeightPx += av.getAlignment().getHeight()
* charHeight;
// add annotations panel height if shown
wrappedRepeatHeightPx += getAnnotationHeight();
import java.awt.Font;
import java.awt.FontMetrics;
-import junit.extensions.PA;
-
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
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
*/
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()));
+ }
}