Clover icon

Coverage Report

  1. Project Clover database Tue Mar 10 2026 14:58:44 GMT
  2. Package jalview.gui

File AlignFrameTest.java

 

Code metrics

4
282
9
1
636
396
12
0.04
31.33
9
1.33

Classes

Class Line # Actions
AlignFrameTest 62 282 12
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.gui;
22   
23    import static org.junit.Assert.assertNotEquals;
24    import static org.testng.Assert.assertEquals;
25    import static org.testng.Assert.assertFalse;
26    import static org.testng.Assert.assertNotSame;
27    import static org.testng.Assert.assertSame;
28    import static org.testng.Assert.assertTrue;
29   
30    import java.awt.Color;
31    import java.util.Iterator;
32   
33    import org.testng.annotations.AfterMethod;
34    import org.testng.annotations.BeforeClass;
35    import org.testng.annotations.BeforeMethod;
36    import org.testng.annotations.Test;
37   
38    import jalview.api.AlignViewportI;
39    import jalview.api.FeatureColourI;
40    import jalview.bin.Cache;
41    import jalview.bin.Jalview;
42    import jalview.datamodel.Alignment;
43    import jalview.datamodel.AlignmentI;
44    import jalview.datamodel.HiddenColumns;
45    import jalview.datamodel.Sequence;
46    import jalview.datamodel.SequenceFeature;
47    import jalview.datamodel.SequenceGroup;
48    import jalview.datamodel.SequenceI;
49    import jalview.io.DataSourceType;
50    import jalview.io.FileLoader;
51    import jalview.project.Jalview2xmlTests;
52    import jalview.renderer.ResidueShaderI;
53    import jalview.schemes.BuriedColourScheme;
54    import jalview.schemes.FeatureColour;
55    import jalview.schemes.HelixColourScheme;
56    import jalview.schemes.JalviewColourScheme;
57    import jalview.schemes.StrandColourScheme;
58    import jalview.schemes.TurnColourScheme;
59    import jalview.util.MessageManager;
60    import jalview.viewmodel.AlignmentViewport;
61   
 
62    public class AlignFrameTest
63    {
64    AlignFrame af;
65   
 
66  0 toggle @BeforeClass(alwaysRun = true)
67    public static void setUpBeforeClass() throws Exception
68    {
69  0 setUpJvOptionPane();
70    /*
71    * use read-only test properties file
72    */
73  0 Cache.loadProperties("test/jalview/io/testProps.jvprops");
74  0 Jalview.main(new String[] { "--nonews" });
75    }
76   
 
77  0 toggle @AfterMethod(alwaysRun = true)
78    public void tearDown()
79    {
80  0 if (Desktop.getInstance() != null)
81  0 Desktop.getInstance().closeAll_actionPerformed(null);
82    }
83   
84    /**
85    * configure (read-only) properties for test to ensure Consensus is computed
86    * for colour Above PID testing
87    */
 
88  0 toggle @BeforeMethod(alwaysRun = true)
89    public void setUp()
90    {
91  0 Cache.loadProperties("test/jalview/io/testProps.jvprops");
92  0 Cache.setPropertyNoSave("SHOW_IDENTITY",
93    Boolean.TRUE.toString());
94  0 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
95    DataSourceType.FILE);
96   
97    /*
98    * wait for Consensus thread to complete
99    */
100  0 do
101    {
102  0 try
103    {
104  0 Thread.sleep(50);
105    } catch (InterruptedException x)
106    {
107    }
108  0 } while (af.getViewport().getCalcManager().isWorking());
109    }
110   
 
111  0 toggle public static void setUpJvOptionPane()
112    {
113  0 JvOptionPane.setInteractiveMode(false);
114  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
115    }
116   
 
117  0 toggle @Test(groups = "Functional")
118    public void testHideFeatureColumns()
119    {
120  0 SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
121  0 SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
122  0 seq1.addSequenceFeature(
123    new SequenceFeature("Metal", "", 1, 5, 0f, null));
124  0 seq2.addSequenceFeature(
125    new SequenceFeature("Metal", "", 6, 10, 10f, null));
126  0 seq1.addSequenceFeature(
127    new SequenceFeature("Turn", "", 2, 4, Float.NaN, null));
128  0 seq2.addSequenceFeature(
129    new SequenceFeature("Turn", "", 7, 9, Float.NaN, null));
130  0 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
131  0 AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
132    al.getHeight());
133   
134    /*
135    * make all features visible (select feature columns checks visibility)
136    */
137  0 alignFrame.getFeatureRenderer().findAllFeatures(true);
138   
139    /*
140    * hiding a feature not present does nothing
141    */
142  0 assertFalse(alignFrame.hideFeatureColumns("exon", true));
143  0 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
144   
145  0 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
146    .getNumberOfRegions(), 0);
147   
148  0 assertFalse(alignFrame.hideFeatureColumns("exon", false));
149  0 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
150   
151  0 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
152    .getNumberOfRegions(), 0);
153   
154    /*
155    * hiding a feature in all columns does nothing
156    */
157  0 assertFalse(alignFrame.hideFeatureColumns("Metal", true));
158  0 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
159   
160  0 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
161    .getNumberOfRegions(), 0);
162   
163    /*
164    * threshold Metal to hide features where score < 5
165    * seq1 feature in columns 1-5 is hidden
166    * seq2 feature in columns 6-10 is shown
167    */
168  0 FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
169    0f, 10f);
170  0 fc.setAboveThreshold(true);
171  0 fc.setThreshold(5f);
172  0 alignFrame.getFeatureRenderer().setColour("Metal", fc);
173  0 assertTrue(alignFrame.hideFeatureColumns("Metal", true));
174  0 HiddenColumns hidden = alignFrame.getViewport().getAlignment()
175    .getHiddenColumns();
176  0 assertEquals(hidden.getNumberOfRegions(), 1);
177  0 Iterator<int[]> regions = hidden.iterator();
178  0 int[] next = regions.next();
179  0 assertEquals(next[0], 5);
180  0 assertEquals(next[1], 9);
181   
182    /*
183    * hide a feature present in some columns
184    * sequence positions [2-4], [7-9] are column positions
185    * [1-3], [6-8] base zero
186    */
187  0 alignFrame.getViewport().showAllHiddenColumns();
188  0 assertTrue(alignFrame.hideFeatureColumns("Turn", true));
189  0 regions = alignFrame.getViewport().getAlignment().getHiddenColumns()
190    .iterator();
191  0 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
192    .getNumberOfRegions(), 2);
193  0 next = regions.next();
194  0 assertEquals(next[0], 1);
195  0 assertEquals(next[1], 3);
196  0 next = regions.next();
197  0 assertEquals(next[0], 6);
198  0 assertEquals(next[1], 8);
199    }
200   
201    /**
202    * Test that changing background (alignment) colour scheme
203    * <ul>
204    * <li>with Apply Colour to All Groups not selected, does not change group
205    * colours</li>
206    * <li>with Apply Colour to All Groups selected, does change group
207    * colours</li>
208    * <li>in neither case, changes alignment or group colour thresholds (PID or
209    * Conservation)</li>
210    * </ul>
211    */
 
212  0 toggle @Test(groups = "Functional")
213    public void testChangeColour_background_groupsAndThresholds()
214    {
215  0 AlignViewportI av = af.getViewport();
216  0 AlignmentI al = av.getAlignment();
217   
218    /*
219    * Colour alignment by Buried Index
220    */
221  0 af.applyToAllGroups_actionPerformed(false);
222  0 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
223  0 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
224  0 assertFalse(av.getResidueShading().conservationApplied());
225  0 assertEquals(av.getResidueShading().getThreshold(), 0);
226   
227    /*
228    * Apply Conservation 20%
229    */
230  0 af.conservationMenuItem_actionPerformed(true);
231  0 SliderPanel sp = SliderPanel.getSliderPanel();
232  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
233    "label.conservation_colour_increment", new String[]
234    { "Background" }));
235  0 assertTrue(sp.isForConservation());
236  0 sp.valueChanged(20);
237  0 assertTrue(av.getResidueShading().conservationApplied());
238  0 assertEquals(av.getResidueShading().getConservationInc(), 20);
239   
240    /*
241    * Apply PID threshold 10% (conservation still applies as well)
242    */
243  0 af.abovePIDThreshold_actionPerformed(true);
244  0 sp = SliderPanel.getSliderPanel();
245  0 assertFalse(sp.isForConservation());
246  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
247    "label.percentage_identity_threshold", new String[]
248    { "Background" }));
249  0 sp.valueChanged(10);
250  0 assertEquals(av.getResidueShading().getThreshold(), 10);
251  0 assertTrue(av.getResidueShading().conservationApplied());
252  0 assertEquals(av.getResidueShading().getConservationInc(), 20);
253   
254    /*
255    * create a group with Strand colouring, 30% Conservation
256    * and 40% PID threshold
257    */
258  0 SequenceGroup sg = new SequenceGroup();
259  0 sg.addSequence(al.getSequenceAt(0), false);
260  0 sg.setStartRes(15);
261  0 sg.setEndRes(25);
262  0 av.setSelectionGroup(sg);
263   
264    /*
265    * apply 30% Conservation to group
266    * (notice menu action applies to selection group even if mouse click
267    * is at a sequence not in the group)
268    */
269  0 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
270    null);
271  0 popupMenu.changeColour_actionPerformed(
272    JalviewColourScheme.Strand.toString());
273  0 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
274  0 assertEquals(al.getGroups().size(), 1);
275  0 assertSame(al.getGroups().get(0), sg);
276  0 popupMenu.conservationMenuItem_actionPerformed(true);
277  0 sp = SliderPanel.getSliderPanel();
278  0 assertTrue(sp.isForConservation());
279  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
280    "label.conservation_colour_increment", new String[]
281    { sg.getName() }));
282  0 sp.valueChanged(30);
283  0 assertTrue(sg.getGroupColourScheme().conservationApplied());
284  0 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
285   
286    /*
287    * apply 40% PID threshold to group
288    */
289  0 popupMenu.abovePIDColour_actionPerformed(true);
290  0 sp = SliderPanel.getSliderPanel();
291  0 assertFalse(sp.isForConservation());
292  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
293    "label.percentage_identity_threshold", new String[]
294    { sg.getName() }));
295  0 sp.valueChanged(40);
296  0 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
297    // conservation threshold is unchanged:
298  0 assertTrue(sg.getGroupColourScheme().conservationApplied());
299  0 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
300   
301    /*
302    * change alignment colour - group colour, and all thresholds,
303    * should be unaffected
304    */
305  0 af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
306  0 assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
307  0 assertTrue(av.getResidueShading().conservationApplied());
308  0 assertEquals(av.getResidueShading().getConservationInc(), 20);
309  0 assertEquals(av.getResidueShading().getThreshold(), 10);
310  0 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
311  0 assertTrue(sg.getGroupColourScheme().conservationApplied());
312  0 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
313  0 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
314   
315    /*
316    * Now change alignment colour with Apply Colour To All Groups
317    * - group colour should change, but not colour thresholds
318    */
319  0 af.applyToAllGroups_actionPerformed(true);
320  0 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
321  0 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
322  0 assertTrue(av.getResidueShading().conservationApplied());
323  0 assertEquals(av.getResidueShading().getConservationInc(), 20);
324  0 assertEquals(av.getResidueShading().getThreshold(), 10);
325  0 assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
326  0 assertTrue(sg.getGroupColourScheme().conservationApplied());
327  0 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
328  0 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
329    }
330   
331    /**
332    * Test residue colouring with various options
333    * <ol>
334    * <li>no PID or Conservation threshold</li>
335    * <li>colour by Conservation applied</li>
336    * <li>colour by Conservation removed</li>
337    * <li>colour above PID - various values</li>
338    * <li>colour above PID removed</li>
339    * <li>Above PID plus By Conservation combined</li>
340    * <li>remove Above PID to leave just By Conservation</li>
341    * <li>re-add Above PID</li>
342    * <li>remove By Conservation to leave just Above PID</li>
343    * <li>remove Above PID to leave original colours</li>
344    * </ol>
345    */
 
346  0 toggle @Test(groups = "Functional")
347    public void testColourThresholdActions()
348    {
349  0 AlignViewportI av = af.getViewport();
350  0 AlignmentI al = av.getAlignment();
351   
352    /*
353    * Colour alignment by Helix Propensity, no thresholds
354    */
355  0 af.applyToAllGroups_actionPerformed(false);
356  0 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
357  0 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
358  0 assertFalse(av.getResidueShading().conservationApplied());
359  0 assertEquals(av.getResidueShading().getThreshold(), 0);
360   
361    /*
362    * inspect the colour of
363    * FER_CAPAN.9(I), column 15 (14 base 0)
364    * FER_CAPAN.10(SER), column 16 (15 base 0)
365    */
366  0 SequenceI ferCapan = al.findName("FER_CAPAN");
367  0 ResidueShaderI rs = av.getResidueShading();
368  0 Color c = rs.findColour('I', 14, ferCapan);
369  0 Color i_original = new Color(138, 117, 138);
370  0 assertEquals(c, i_original);
371  0 c = rs.findColour('S', 15, ferCapan);
372  0 Color s_original = new Color(54, 201, 54);
373  0 assertEquals(c, s_original);
374   
375    /*
376    * colour by conservation with increment 10
377    */
378  0 af.conservationMenuItem_actionPerformed(true);
379  0 SliderPanel sp = SliderPanel.getSliderPanel();
380  0 assertTrue(sp.isForConservation());
381  0 assertEquals(sp.getValue(), 30); // initial slider setting
382  0 c = rs.findColour('I', 14, ferCapan);
383  0 Color i_faded = new Color(255, 255, 255);
384  0 assertEquals(c, i_faded);
385  0 sp.valueChanged(10);
386  0 assertSame(rs, av.getResidueShading());
387  0 assertEquals(rs.getConservationInc(), 10);
388  0 c = rs.findColour('I', 14, ferCapan);
389  0 i_faded = new Color(196, 186, 196);
390  0 assertEquals(c, i_faded);
391  0 c = rs.findColour('S', 15, ferCapan);
392  0 Color s_faded = new Color(144, 225, 144);
393  0 assertEquals(c, s_faded);
394   
395    /*
396    * deselect By Conservation - colour should revert
397    */
398  0 af.conservationMenuItem_actionPerformed(false);
399  0 c = rs.findColour('S', 15, ferCapan);
400  0 assertEquals(c, s_original);
401   
402    /*
403    * now Above PID, threshold = 0%
404    * should be no change
405    */
406  0 af.abovePIDThreshold_actionPerformed(true);
407  0 sp = SliderPanel.getSliderPanel();
408  0 assertFalse(sp.isForConservation());
409  0 assertEquals(sp.getValue(), 0); // initial slider setting
410  0 c = rs.findColour('I', 14, ferCapan);
411  0 assertEquals(c, i_original);
412  0 c = rs.findColour('S', 15, ferCapan);
413  0 assertEquals(c, s_original);
414   
415    /*
416    * Above PID, threshold = 1%
417    * 15.I becomes White because no match to consensus (V)
418    * 16.S remains coloured as matches 66.66% consensus
419    */
420  0 sp.valueChanged(1);
421  0 c = rs.findColour('I', 14, ferCapan);
422  0 assertEquals(c, Color.white);
423  0 c = rs.findColour('S', 15, ferCapan);
424  0 assertEquals(c, s_original);
425   
426    /*
427    * threshold 66% - no further change yet...
428    */
429  0 sp.valueChanged(66);
430  0 c = rs.findColour('I', 14, ferCapan);
431  0 assertEquals(c, Color.white);
432  0 c = rs.findColour('S', 15, ferCapan);
433  0 assertEquals(c, s_original);
434   
435    /*
436    * threshold 67% - now both residues are white
437    */
438  0 sp.valueChanged(67);
439  0 c = rs.findColour('I', 14, ferCapan);
440  0 assertEquals(c, Color.white);
441  0 c = rs.findColour('S', 15, ferCapan);
442  0 assertEquals(c, Color.white);
443   
444    /*
445    * deselect Above PID - colours should revert
446    */
447  0 af.abovePIDThreshold_actionPerformed(false);
448  0 c = rs.findColour('I', 14, ferCapan);
449  0 assertEquals(c, i_original);
450  0 c = rs.findColour('S', 15, ferCapan);
451  0 assertEquals(c, s_original);
452   
453    /*
454    * Now combine Above 50% PID and By Conservation 10%
455    * 15.I is White because no match to consensus (V)
456    * 16.S is coloured but faded
457    */
458  0 af.abovePIDThreshold_actionPerformed(true);
459  0 sp = SliderPanel.getSliderPanel();
460  0 assertFalse(sp.isForConservation());
461  0 sp.valueChanged(50);
462  0 af.conservationMenuItem_actionPerformed(true);
463  0 sp = SliderPanel.getSliderPanel();
464  0 assertTrue(sp.isForConservation());
465  0 sp.valueChanged(10);
466  0 c = rs.findColour('I', 14, ferCapan);
467  0 assertEquals(c, Color.white);
468  0 c = rs.findColour('S', 15, ferCapan);
469  0 assertEquals(c, s_faded);
470   
471    /*
472    * turn off Above PID - should just leave Conservation fading as before
473    */
474  0 af.abovePIDThreshold_actionPerformed(false);
475  0 c = rs.findColour('I', 14, ferCapan);
476  0 assertEquals(c, i_faded);
477  0 c = rs.findColour('S', 15, ferCapan);
478  0 assertEquals(c, s_faded);
479   
480    /*
481    * Now add Above 50% PID to conservation colouring
482    * - should give the same as PID followed by conservation (above)
483    */
484  0 af.abovePIDThreshold_actionPerformed(true);
485  0 SliderPanel.getSliderPanel().valueChanged(50);
486  0 c = rs.findColour('I', 14, ferCapan);
487  0 assertEquals(c, Color.white);
488  0 c = rs.findColour('S', 15, ferCapan);
489  0 assertEquals(c, s_faded);
490   
491    /*
492    * turn off By Conservation
493    * should leave I white, S original (unfaded) colour
494    */
495  0 af.conservationMenuItem_actionPerformed(false);
496  0 c = rs.findColour('I', 14, ferCapan);
497  0 assertEquals(c, Color.white);
498  0 c = rs.findColour('S', 15, ferCapan);
499  0 assertEquals(c, s_original);
500   
501    /*
502    * finally turn off Above PID to leave original colours
503    */
504  0 af.abovePIDThreshold_actionPerformed(false);
505  0 c = rs.findColour('I', 14, ferCapan);
506  0 assertEquals(c, i_original);
507  0 c = rs.findColour('S', 15, ferCapan);
508  0 assertEquals(c, s_original);
509    }
510   
511    /**
512    * Verify that making a New View transfers alignment and group colour schemes,
513    * including any thresholds, to the new view. Because New View is performed by
514    * saving and reloading a 'project' file, this is similar to verifying a
515    * project save and reload.
516    *
517    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
518    */
 
519  0 toggle @Test(groups = "Functional")
520    public void testNewView_colourThresholds()
521    {
522  0 AlignViewportI av = af.getViewport();
523  0 AlignmentI al = av.getAlignment();
524   
525    /*
526    * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
527    */
528  0 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
529  0 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
530  0 af.abovePIDThreshold_actionPerformed(true);
531  0 SliderPanel sp = SliderPanel.getSliderPanel();
532  0 assertFalse(sp.isForConservation());
533  0 sp.valueChanged(10);
534  0 af.conservationMenuItem_actionPerformed(true);
535  0 sp = SliderPanel.getSliderPanel();
536  0 assertTrue(sp.isForConservation());
537  0 sp.valueChanged(20);
538  0 ResidueShaderI rs = av.getResidueShading();
539  0 assertEquals(rs.getThreshold(), 10);
540  0 assertTrue(rs.conservationApplied());
541  0 assertEquals(rs.getConservationInc(), 20);
542   
543    /*
544    * create a group with Strand colouring, 30% Conservation
545    * and 40% PID threshold
546    */
547  0 SequenceGroup sg = new SequenceGroup();
548  0 sg.addSequence(al.getSequenceAt(0), false);
549  0 sg.setStartRes(15);
550  0 sg.setEndRes(25);
551  0 av.setSelectionGroup(sg);
552  0 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
553    null);
554  0 popupMenu.changeColour_actionPerformed(
555    JalviewColourScheme.Strand.toString());
556  0 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
557  0 assertEquals(al.getGroups().size(), 1);
558  0 assertSame(al.getGroups().get(0), sg);
559  0 popupMenu.conservationMenuItem_actionPerformed(true);
560  0 sp = SliderPanel.getSliderPanel();
561  0 assertTrue(sp.isForConservation());
562  0 sp.valueChanged(30);
563  0 popupMenu.abovePIDColour_actionPerformed(true);
564  0 sp = SliderPanel.getSliderPanel();
565  0 assertFalse(sp.isForConservation());
566  0 sp.valueChanged(40);
567  0 rs = sg.getGroupColourScheme();
568  0 assertTrue(rs.conservationApplied());
569  0 assertEquals(rs.getConservationInc(), 30);
570  0 assertEquals(rs.getThreshold(), 40);
571   
572    /*
573    * set slider panel focus to the background alignment
574    */
575  0 af.conservationMenuItem_actionPerformed(true);
576  0 sp = SliderPanel.getSliderPanel();
577  0 assertTrue(sp.isForConservation());
578  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
579    "label.conservation_colour_increment", new String[]
580    { "Background" }));
581   
582    /*
583    * make a new View, verify alignment and group colour schemes
584    */
585  0 af.newView_actionPerformed(null);
586  0 assertEquals(af.alignPanel.getViewName(), "View 1");
587  0 AlignmentViewport av2 = af.getViewport();
588  0 assertNotSame(av, av2);
589  0 assertSame(av2, af.alignPanel.av);
590  0 rs = av2.getResidueShading();
591  0 assertNotSame(av.getResidueShading(), rs);
592  0 assertEquals(rs.getThreshold(), 10);
593  0 assertTrue(rs.conservationApplied(), rs.toString());
594  0 assertEquals(rs.getConservationInc(), 20);
595  0 assertEquals(av2.getAlignment().getGroups().size(), 1);
596  0 sg = av2.getAlignment().getGroups().get(0);
597  0 rs = sg.getGroupColourScheme();
598  0 assertTrue(rs.conservationApplied());
599  0 assertEquals(rs.getConservationInc(), 30);
600  0 assertEquals(rs.getThreshold(), 40);
601   
602    /*
603    * check the Conservation SliderPanel (still open) is linked to
604    * and updates the new view (JAL-2385)
605    */
606  0 sp = SliderPanel.getSliderPanel();
607  0 assertTrue(sp.isForConservation());
608  0 assertEquals(sp.getTitle(), MessageManager.formatMessage(
609    "label.conservation_colour_increment", new String[]
610    { "View 1" }));
611  0 sp.valueChanged(22);
612  0 assertEquals(av2.getResidueShading().getConservationInc(), 22);
613    }
614   
615    /**
616    * Verify that making a New View preserves the dataset reference for the
617    * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
618    * save alignments with multiple views, and codon mappings will not be shared
619    * across all panels in a split frame.
620    *
621    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
622    */
 
623  0 toggle @Test(groups = "Functional")
624    public void testNewView_dsRefPreserved()
625    {
626  0 AlignViewport av = af.getViewport();
627  0 AlignmentI al = av.getAlignment();
628  0 AlignmentI original_ds = al.getDataset();
629  0 af.newView_actionPerformed(null);
630  0 assertNotEquals("New view didn't select the a new panel", av,
631    af.getViewport());
632  0 org.testng.Assert.assertEquals(original_ds,
633    af.getViewport().getAlignment().getDataset(),
634    "Dataset was not preserved in new view");
635    }
636    }