+
+ /**
+ * Configure an alignment and a sub-group each with distinct colour schemes,
+ * Conservation and PID thresholds, and confirm these are restored from the
+ * saved project.
+ *
+ * @throws IOException
+ */
+ @Test(groups = { "Functional" })
+ public void testStoreAndRecoverColourThresholds() throws IOException
+ {
+ Desktop.instance.closeAll_actionPerformed(null);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+
+ AlignViewport av = af.getViewport();
+ AlignmentI al = av.getAlignment();
+
+ /*
+ * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
+ */
+ af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
+ assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
+ af.abovePIDThreshold_actionPerformed(true);
+ SliderPanel sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(10);
+ af.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(20);
+ ResidueShaderI rs = av.getResidueShading();
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+
+ /*
+ * create a group with Strand colouring, 30% Conservation
+ * and 40% PID threshold
+ */
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(al.getSequenceAt(0), false);
+ sg.setStartRes(15);
+ sg.setEndRes(25);
+ av.setSelectionGroup(sg);
+ PopupMenu popupMenu = new PopupMenu(af.alignPanel, null, null);
+ popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
+ .toString());
+ assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
+ assertEquals(al.getGroups().size(), 1);
+ assertSame(al.getGroups().get(0), sg);
+ popupMenu.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(30);
+ popupMenu.abovePIDColour_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(40);
+ assertTrue(sg.getGroupColourScheme().conservationApplied());
+ assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
+ assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
+
+ /*
+ * save project, close windows, reload project, verify
+ */
+ File tfile = File.createTempFile("testStoreAndRecoverColourThresholds",
+ ".jvp");
+ tfile.deleteOnExit();
+ new Jalview2XML(false).saveState(tfile);
+ Desktop.instance.closeAll_actionPerformed(null);
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
+ Assert.assertNotNull(af, "Failed to reload project");
+
+ /*
+ * verify alignment (background) colouring
+ */
+ rs = af.getViewport().getResidueShading();
+ assertTrue(rs.getColourScheme() instanceof BuriedColourScheme);
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+
+ /*
+ * verify group colouring
+ */
+ assertEquals(1, af.getViewport().getAlignment().getGroups().size(), 1);
+ rs = af.getViewport().getAlignment().getGroups().get(0)
+ .getGroupColourScheme();
+ assertTrue(rs.getColourScheme() instanceof StrandColourScheme);
+ assertEquals(rs.getThreshold(), 40);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 30);
+ }