import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
+import jalview.util.Platform;
import jalview.viewmodel.ViewportRanges;
public class AlignmentPanelTest
@BeforeMethod(alwaysRun = true)
public void setUp() throws InvocationTargetException, InterruptedException
{
- Jalview.main(
- new String[]
- { "-nonews", "-props", "test/jalview/testProps.jvprops" });
+ Jalview.main(new String[] { "-nonews",
+ "-props", "test/jalview/testProps.jvprops",
+ "-jabaws", "none"});
- Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+ Cache.setPropertyNoSave("SHOW_IDENTITY",
Boolean.TRUE.toString());
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
DataSourceType.FILE);
-
+
/*
* ensure the panel has been repainted and so ViewportRanges set
*/
af.alignPanel.setScrollValues(-1, 5);
// setting -ve x value does not change residue
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(0, 5);
+ // no update necessary now
// setting 0 as x value does not change residue
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres);
af.alignPanel.setScrollValues(5, 5);
// setting x value to 5 extends endRes by 5 residues
+ System.out.println(ranges);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + 5);
// scroll to position after hidden columns sets endres to oldres (width) +
// position
- int scrollpos = 60;
+ int scrollpos = 53; // was 60, but this is too high to allow full scrolling
+ // in Windows
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within hidden columns, still sets endres to oldres +
af.getViewport().showAllHiddenColumns();
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(), oldres + scrollpos);
// scroll to position within <width> distance of the end of the alignment
scrollpos = 130;
af.getViewport().showAllHiddenColumns();
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(),
af.getViewport().getAlignment().getWidth() - 1);
// columns
af.getViewport().hideColumns(30, 50);
af.alignPanel.setScrollValues(scrollpos, 5);
+ // no update necessary now
assertEquals(ranges.getEndRes(),
af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the
// number of
}
/**
- * Test the variant of calculateIdWidth that only recomputes the width if it
- * is not already saved in the viewport (initial value is -1)
+ * Test the variant of calculateIdWidth that only recomputes the width if it is
+ * not already saved in the viewport (initial value is -1)
*/
@Test(groups = "Functional")
public void testCalculateIdWidth_noArgs()
* 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.width, Platform.isWin() ? 172 : 166); // 4 + pixel width of "Q93Z60_ARATH/1-118"
assertEquals(d.height, 12);
assertEquals(d.width, av.getIdWidth());
}
* 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.width, Platform.isWin() ? 172 : 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
*/
SequenceI seq = af.viewport.getAlignment()
.findSequenceMatch("Q93Z60_ARATH")[0];
- seq.setName(seq.getName() + "MMMMM");
+ String orig = seq.getName();
+ seq.setName(orig + "MMMMM");
d = af.alignPanel.calculateIdWidth(2000);
- assertEquals(d.width, 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118"
+ assertEquals(d.width, Platform.isWin() ? 219 : 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118"
assertEquals(d.height, 12);
assertEquals(av.getIdWidth(), 18); // unchanged
+ // for next test:
+ seq.setName(orig);
/*
* make the longest annotation name even longer
FontMetrics fmfor = af.alignPanel
.getFontMetrics(af.alignPanel.getAlabels().getFont());
// Assumption ID_WIDTH_PADDING == 4
+ // AH! But with those added MMMM above, this was NOT the longest label!
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.width, expwidth); // 191 == 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);
+ // BH but we have to be under the max width
+ d = af.alignPanel.calculateIdWidth(180);
+ assertEquals(d.width, 184);
assertEquals(d.height, 12);
}
*/
int w = af.alignPanel.getVisibleIdWidth(true);
assertEquals(w, af.alignPanel.getIdPanel().getWidth());
- assertEquals(w, 115);
+ assertEquals(w, Platform.isWin() ? 112 : 115);
/*
* width for offscreen rendering is the same
* preference for auto id width overrides fixed width
*/
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString());
- assertEquals(115, af.alignPanel.getVisibleIdWidth(false));
+ assertEquals(Platform.isWin() ? 106 : 115, af.alignPanel.getVisibleIdWidth(false));
}
}