1 package jalview.renderer;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertFalse;
5 import static org.testng.Assert.assertNull;
6 import static org.testng.Assert.assertTrue;
8 import jalview.gui.AlignFrame;
9 import jalview.gui.AlignViewport;
10 import jalview.io.DataSourceType;
11 import jalview.io.FileLoader;
12 import jalview.renderer.ScaleRenderer.ScaleMark;
14 import java.util.List;
16 import org.testng.annotations.Test;
18 public class ScaleRendererTest
20 @Test(groups = "Functional")
21 public void testCalculateMarks()
23 String data = ">Seq/20-45\nABCDEFGHIJKLMNOPQRSTUVWXYS\n";
24 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(data,
25 DataSourceType.PASTE);
26 AlignViewport av = af.getViewport();
29 * scale has minor ticks at 5 and 15, major at 10 and 20
30 * (these are base 1, ScaleMark holds base 0 values)
32 List<ScaleMark> marks = new ScaleRenderer().calculateMarks(av, 0, 25);
33 assertEquals(marks.size(), 4);
35 assertFalse(marks.get(0).major);
36 assertEquals(marks.get(0).column, 4);
37 assertNull(marks.get(0).text);
39 assertTrue(marks.get(1).major);
40 assertEquals(marks.get(1).column, 9);
41 assertEquals(marks.get(1).text, "10");
43 assertFalse(marks.get(2).major);
44 assertEquals(marks.get(2).column, 14);
45 assertNull(marks.get(2).text);
47 assertTrue(marks.get(3).major);
48 assertEquals(marks.get(3).column, 19);
49 assertEquals(marks.get(3).text, "20");
52 * now hide columns 9-11 and 18-20 (base 1)
53 * scale marks are now in the same columns as before, but
54 * with column numbering adjusted for hidden columns
56 av.hideColumns(8, 10);
57 av.hideColumns(17, 19);
58 marks = new ScaleRenderer().calculateMarks(av, 0, 25);
59 assertEquals(marks.size(), 4);
60 assertFalse(marks.get(0).major);
61 assertEquals(marks.get(0).column, 4);
62 assertNull(marks.get(0).text);
63 assertTrue(marks.get(1).major);
64 assertEquals(marks.get(1).column, 9);
65 assertEquals(marks.get(1).text, "13"); // +3 hidden columns
66 assertFalse(marks.get(2).major);
67 assertEquals(marks.get(2).column, 14);
68 assertNull(marks.get(2).text);
69 assertTrue(marks.get(3).major);
70 assertEquals(marks.get(3).column, 19);
71 assertEquals(marks.get(3).text, "26"); // +6 hidden columns