- SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4, seq5,
- seq6, seq7, seq8, seq9, seq10, seq11, seq12, seq13, seq14, seq15,
- seq16, seq17, seq18, seq19, seq20, seq21, seq22, seq23 };
- Alignment al = new Alignment(seqs);
- al.setDataset(null);
- AlignViewport av = new AlignViewport(al);
-
- AlignFrame alignFrame = new AlignFrame(al, 700, 500);
- AlignmentPanel ap = new AlignmentPanel(alignFrame, av);
-
- int oldres = av.getEndRes();
- ap.setScrollValues(-1, 5);
-
- // setting -ve x value does not change residue
- assertEquals(av.getEndRes(), oldres);
-
- ap.setScrollValues(0, 5);
-
- // setting 0 as x value does not change residue
- assertEquals(av.getEndRes(), oldres);
+ AlignViewportI av = af.alignPanel.getAlignViewport();
+ av.setShowJVSuffix(true);
+ av.setFont(new Font("Courier", Font.PLAIN, 15), true);
+ av.setShowAnnotation(false);
+ av.setIdWidth(18);
+
+ /*
+ * note 4 pixels 'padding' are added to the longest seq name/annotation label
+ */
+ Dimension d = af.alignPanel.calculateIdWidth(2000);
+ assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
+ assertEquals(d.height, 12); // fixed value (not used?)
+ assertEquals(av.getIdWidth(), 18); // not changed by this method
+
+ /*
+ * make the longest sequence name longer
+ */
+ SequenceI seq = af.viewport.getAlignment()
+ .findSequenceMatch("Q93Z60_ARATH")[0];
+ seq.setName(seq.getName() + "MMMMM");
+ d = af.alignPanel.calculateIdWidth(2000);
+ assertEquals(d.width, 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118"
+ assertEquals(d.height, 12);
+ assertEquals(av.getIdWidth(), 18); // unchanged
+
+ /*
+ * make the longest annotation name even longer
+ * note this is checked even if annotations are not shown
+ */
+ AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[0];
+ aa.label = "THIS IS A VERY LONG LABEL INDEED";
+ FontMetrics fmfor = af.alignPanel
+ .getFontMetrics(af.alignPanel.getAlabels().getFont());
+ // Assumption ID_WIDTH_PADDING == 4
+ int expwidth = 4 + fmfor.stringWidth(aa.label);
+ d = af.alignPanel.calculateIdWidth(2000);
+ assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of
+ // "THIS IS A VERY LONG LABEL INDEED"
+ assertEquals(d.height, 12);
+
+ /*
+ * override with maxwidth
+ * note the 4 pixels padding is added to this value
+ */
+ d = af.alignPanel.calculateIdWidth(213);
+ assertEquals(d.width, 217);
+ assertEquals(d.height, 12);
+ }