+ av.setIdWidth(99);
+ d = af.alignPanel.calculateIdWidth();
+ assertEquals(d.width, 99);
+ assertEquals(d.height, 0);
+
+ /*
+ * note 4 pixels padding are added to the longest sequence name width
+ */
+ av.setIdWidth(-1); // force recalculation
+ d = af.alignPanel.calculateIdWidth();
+ assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
+ assertEquals(d.height, 12);
+ assertEquals(d.width, av.getIdWidth());
+ }
+
+ /**
+ * Test the variant of calculateIdWidth that computes the longest of any
+ * sequence name or annotation label width
+ */
+ @Test(groups = "Functional")
+ public void testCalculateIdWidth_withMaxWidth()
+ {
+ 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);
+ }
+
+ @Test(groups = { "Functional", "Not-bamboo" })
+ public void testGetVisibleWidth()
+ {
+ /*
+ * width for onscreen rendering is IDPanel width
+ */
+ int w = af.alignPanel.getVisibleIdWidth(true);
+ assertEquals(w, af.alignPanel.getIdPanel().getWidth());
+ assertEquals(w, 115);
+
+ /*
+ * width for offscreen rendering is the same
+ * if no fixed id width is specified in preferences
+ */
+ Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.FALSE.toString());
+ Cache.removeProperty("FIGURE_FIXEDIDWIDTH");
+ assertEquals(w, af.alignPanel.getVisibleIdWidth(false));
+
+ /*
+ * preference for fixed id width - note 4 pixels padding is added
+ */
+ Cache.setProperty("FIGURE_FIXEDIDWIDTH", "120");
+ assertEquals(124, af.alignPanel.getVisibleIdWidth(false));
+
+ /*
+ * preference for auto id width overrides fixed width
+ */
+ Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
+ assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
+ }
+
+ @Test(groups = "Functional")
+ public void testSetOverviewTitle()
+ {
+ OverviewPanel ov1 = this.af.openOverviewPanel(true);
+ String alignFrameTitle = af.getTitle();
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle);
+
+ /*
+ * on New View, existing overview should get " Original" added to title
+ * and new view's overview should get " View 1" added
+ */
+ af.newView_actionPerformed(null);
+ assertEquals(ov1.getTitle(),
+ "Overview " + alignFrameTitle + " Original");
+ OverviewPanel ov2 = this.af.openOverviewPanel(true);
+ assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1");
+ }
+
+ @Test(groups = "Functional")
+ public void testSetOverviewTitle_automaticOverview()
+ {
+ Cache.setProperty("SHOW_OVERVIEW", "true");
+ AlignFrame alignFrame = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+ OverviewPanel ov1 = alignFrame.alignPanel.getOverviewPanel();
+ assertNotNull(ov1);
+ String alignFrameTitle = alignFrame.getTitle();
+ assertEquals(ov1.getTitle(), "Overview " + alignFrameTitle);
+
+ /*
+ * on New View, existing overview should get " Original" added to title
+ * and new view's automatic overview should have " View 1" added
+ */
+ alignFrame.newView_actionPerformed(null);
+ assertEquals(ov1.getTitle(),
+ "Overview " + alignFrameTitle + " Original");
+ OverviewPanel ov2 = alignFrame.alignPanel.getOverviewPanel();
+ assertNotNull(ov2);
+ assertEquals(ov2.getTitle(), "Overview " + alignFrameTitle + " View 1");