Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 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.993220399.3%
 

Contributing tests

This file is covered by 5 tests. .

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  1 toggle @BeforeClass(alwaysRun = true)
67    public static void setUpBeforeClass() throws Exception
68    {
69  1 setUpJvOptionPane();
70    /*
71    * use read-only test properties file
72    */
73  1 Cache.loadProperties("test/jalview/io/testProps.jvprops");
74  1 Jalview.main(new String[] { "--nonews" });
75    }
76   
 
77  5 toggle @AfterMethod(alwaysRun = true)
78    public void tearDown()
79    {
80  5 if (Desktop.getInstance() != null)
81  5 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  5 toggle @BeforeMethod(alwaysRun = true)
89    public void setUp()
90    {
91  5 Cache.loadProperties("test/jalview/io/testProps.jvprops");
92  5 Cache.setPropertyNoSave("SHOW_IDENTITY",
93    Boolean.TRUE.toString());
94  5 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
95    DataSourceType.FILE);
96   
97    /*
98    * wait for Consensus thread to complete
99    */
100  5 do
101    {
102  5 try
103    {
104  5 Thread.sleep(50);
105    } catch (InterruptedException x)
106    {
107    }
108  5 } while (af.getViewport().getCalcManager().isWorking());
109    }
110   
 
111  1 toggle public static void setUpJvOptionPane()
112    {
113  1 JvOptionPane.setInteractiveMode(false);
114  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
115    }
116   
 
117  1 toggle @Test(groups = "Functional")
118    public void testHideFeatureColumns()
119    {
120  1 SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
121  1 SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
122  1 seq1.addSequenceFeature(
123    new SequenceFeature("Metal", "", 1, 5, 0f, null));
124  1 seq2.addSequenceFeature(
125    new SequenceFeature("Metal", "", 6, 10, 10f, null));
126  1 seq1.addSequenceFeature(
127    new SequenceFeature("Turn", "", 2, 4, Float.NaN, null));
128  1 seq2.addSequenceFeature(
129    new SequenceFeature("Turn", "", 7, 9, Float.NaN, null));
130  1 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
131  1 AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
132    al.getHeight());
133   
134    /*
135    * make all features visible (select feature columns checks visibility)
136    */
137  1 alignFrame.getFeatureRenderer().findAllFeatures(true);
138   
139    /*
140    * hiding a feature not present does nothing
141    */
142  1 assertFalse(alignFrame.hideFeatureColumns("exon", true));
143  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
144   
145  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
146    .getNumberOfRegions(), 0);
147   
148  1 assertFalse(alignFrame.hideFeatureColumns("exon", false));
149  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
150   
151  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
152    .getNumberOfRegions(), 0);
153   
154    /*
155    * hiding a feature in all columns does nothing
156    */
157  1 assertFalse(alignFrame.hideFeatureColumns("Metal", true));
158  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
159   
160  1 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  1 FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
169    0f, 10f);
170  1 fc.setAboveThreshold(true);
171  1 fc.setThreshold(5f);
172  1 alignFrame.getFeatureRenderer().setColour("Metal", fc);
173  1 assertTrue(alignFrame.hideFeatureColumns("Metal", true));
174  1 HiddenColumns hidden = alignFrame.getViewport().getAlignment()
175    .getHiddenColumns();
176  1 assertEquals(hidden.getNumberOfRegions(), 1);
177  1 Iterator<int[]> regions = hidden.iterator();
178  1 int[] next = regions.next();
179  1 assertEquals(next[0], 5);
180  1 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  1 alignFrame.getViewport().showAllHiddenColumns();
188  1 assertTrue(alignFrame.hideFeatureColumns("Turn", true));
189  1 regions = alignFrame.getViewport().getAlignment().getHiddenColumns()
190    .iterator();
191  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
192    .getNumberOfRegions(), 2);
193  1 next = regions.next();
194  1 assertEquals(next[0], 1);
195  1 assertEquals(next[1], 3);
196  1 next = regions.next();
197  1 assertEquals(next[0], 6);
198  1 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  1 toggle @Test(groups = "Functional")
213    public void testChangeColour_background_groupsAndThresholds()
214    {
215  1 AlignViewportI av = af.getViewport();
216  1 AlignmentI al = av.getAlignment();
217   
218    /*
219    * Colour alignment by Buried Index
220    */
221  1 af.applyToAllGroups_actionPerformed(false);
222  1 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
223  1 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
224  1 assertFalse(av.getResidueShading().conservationApplied());
225  1 assertEquals(av.getResidueShading().getThreshold(), 0);
226   
227    /*
228    * Apply Conservation 20%
229    */
230  1 af.conservationMenuItem_actionPerformed(true);
231  1 SliderPanel sp = SliderPanel.getSliderPanel();
232  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
233    "label.conservation_colour_increment", new String[]
234    { "Background" }));
235  1 assertTrue(sp.isForConservation());
236  1 sp.valueChanged(20);
237  1 assertTrue(av.getResidueShading().conservationApplied());
238  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
239   
240    /*
241    * Apply PID threshold 10% (conservation still applies as well)
242    */
243  1 af.abovePIDThreshold_actionPerformed(true);
244  1 sp = SliderPanel.getSliderPanel();
245  1 assertFalse(sp.isForConservation());
246  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
247    "label.percentage_identity_threshold", new String[]
248    { "Background" }));
249  1 sp.valueChanged(10);
250  1 assertEquals(av.getResidueShading().getThreshold(), 10);
251  1 assertTrue(av.getResidueShading().conservationApplied());
252  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
253   
254    /*
255    * create a group with Strand colouring, 30% Conservation
256    * and 40% PID threshold
257    */
258  1 SequenceGroup sg = new SequenceGroup();
259  1 sg.addSequence(al.getSequenceAt(0), false);
260  1 sg.setStartRes(15);
261  1 sg.setEndRes(25);
262  1 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  1 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
270    null);
271  1 popupMenu.changeColour_actionPerformed(
272    JalviewColourScheme.Strand.toString());
273  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
274  1 assertEquals(al.getGroups().size(), 1);
275  1 assertSame(al.getGroups().get(0), sg);
276  1 popupMenu.conservationMenuItem_actionPerformed(true);
277  1 sp = SliderPanel.getSliderPanel();
278  1 assertTrue(sp.isForConservation());
279  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
280    "label.conservation_colour_increment", new String[]
281    { sg.getName() }));
282  1 sp.valueChanged(30);
283  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
284  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
285   
286    /*
287    * apply 40% PID threshold to group
288    */
289  1 popupMenu.abovePIDColour_actionPerformed(true);
290  1 sp = SliderPanel.getSliderPanel();
291  1 assertFalse(sp.isForConservation());
292  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
293    "label.percentage_identity_threshold", new String[]
294    { sg.getName() }));
295  1 sp.valueChanged(40);
296  1 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
297    // conservation threshold is unchanged:
298  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
299  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
300   
301    /*
302    * change alignment colour - group colour, and all thresholds,
303    * should be unaffected
304    */
305  1 af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
306  1 assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
307  1 assertTrue(av.getResidueShading().conservationApplied());
308  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
309  1 assertEquals(av.getResidueShading().getThreshold(), 10);
310  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
311  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
312  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
313  1 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  1 af.applyToAllGroups_actionPerformed(true);
320  1 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
321  1 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
322  1 assertTrue(av.getResidueShading().conservationApplied());
323  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
324  1 assertEquals(av.getResidueShading().getThreshold(), 10);
325  1 assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
326  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
327  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
328  1 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  1 toggle @Test(groups = "Functional")
347    public void testColourThresholdActions()
348    {
349  1 AlignViewportI av = af.getViewport();
350  1 AlignmentI al = av.getAlignment();
351   
352    /*
353    * Colour alignment by Helix Propensity, no thresholds
354    */
355  1 af.applyToAllGroups_actionPerformed(false);
356  1 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
357  1 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
358  1 assertFalse(av.getResidueShading().conservationApplied());
359  1 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  1 SequenceI ferCapan = al.findName("FER_CAPAN");
367  1 ResidueShaderI rs = av.getResidueShading();
368  1 Color c = rs.findColour('I', 14, ferCapan);
369  1 Color i_original = new Color(138, 117, 138);
370  1 assertEquals(c, i_original);
371  1 c = rs.findColour('S', 15, ferCapan);
372  1 Color s_original = new Color(54, 201, 54);
373  1 assertEquals(c, s_original);
374   
375    /*
376    * colour by conservation with increment 10
377    */
378  1 af.conservationMenuItem_actionPerformed(true);
379  1 SliderPanel sp = SliderPanel.getSliderPanel();
380  1 assertTrue(sp.isForConservation());
381  1 assertEquals(sp.getValue(), 30); // initial slider setting
382  1 c = rs.findColour('I', 14, ferCapan);
383  1 Color i_faded = new Color(255, 255, 255);
384  1 assertEquals(c, i_faded);
385  1 sp.valueChanged(10);
386  1 assertSame(rs, av.getResidueShading());
387  1 assertEquals(rs.getConservationInc(), 10);
388  1 c = rs.findColour('I', 14, ferCapan);
389  1 i_faded = new Color(196, 186, 196);
390  1 assertEquals(c, i_faded);
391  1 c = rs.findColour('S', 15, ferCapan);
392  1 Color s_faded = new Color(144, 225, 144);
393  1 assertEquals(c, s_faded);
394   
395    /*
396    * deselect By Conservation - colour should revert
397    */
398  1 af.conservationMenuItem_actionPerformed(false);
399  1 c = rs.findColour('S', 15, ferCapan);
400  1 assertEquals(c, s_original);
401   
402    /*
403    * now Above PID, threshold = 0%
404    * should be no change
405    */
406  1 af.abovePIDThreshold_actionPerformed(true);
407  1 sp = SliderPanel.getSliderPanel();
408  1 assertFalse(sp.isForConservation());
409  1 assertEquals(sp.getValue(), 0); // initial slider setting
410  1 c = rs.findColour('I', 14, ferCapan);
411  1 assertEquals(c, i_original);
412  1 c = rs.findColour('S', 15, ferCapan);
413  1 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  1 sp.valueChanged(1);
421  1 c = rs.findColour('I', 14, ferCapan);
422  1 assertEquals(c, Color.white);
423  1 c = rs.findColour('S', 15, ferCapan);
424  1 assertEquals(c, s_original);
425   
426    /*
427    * threshold 66% - no further change yet...
428    */
429  1 sp.valueChanged(66);
430  1 c = rs.findColour('I', 14, ferCapan);
431  1 assertEquals(c, Color.white);
432  1 c = rs.findColour('S', 15, ferCapan);
433  1 assertEquals(c, s_original);
434   
435    /*
436    * threshold 67% - now both residues are white
437    */
438  1 sp.valueChanged(67);
439  1 c = rs.findColour('I', 14, ferCapan);
440  1 assertEquals(c, Color.white);
441  1 c = rs.findColour('S', 15, ferCapan);
442  1 assertEquals(c, Color.white);
443   
444    /*
445    * deselect Above PID - colours should revert
446    */
447  1 af.abovePIDThreshold_actionPerformed(false);
448  1 c = rs.findColour('I', 14, ferCapan);
449  1 assertEquals(c, i_original);
450  1 c = rs.findColour('S', 15, ferCapan);
451  1 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  1 af.abovePIDThreshold_actionPerformed(true);
459  1 sp = SliderPanel.getSliderPanel();
460  1 assertFalse(sp.isForConservation());
461  1 sp.valueChanged(50);
462  1 af.conservationMenuItem_actionPerformed(true);
463  1 sp = SliderPanel.getSliderPanel();
464  1 assertTrue(sp.isForConservation());
465  1 sp.valueChanged(10);
466  1 c = rs.findColour('I', 14, ferCapan);
467  1 assertEquals(c, Color.white);
468  1 c = rs.findColour('S', 15, ferCapan);
469  1 assertEquals(c, s_faded);
470   
471    /*
472    * turn off Above PID - should just leave Conservation fading as before
473    */
474  1 af.abovePIDThreshold_actionPerformed(false);
475  1 c = rs.findColour('I', 14, ferCapan);
476  1 assertEquals(c, i_faded);
477  1 c = rs.findColour('S', 15, ferCapan);
478  1 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  1 af.abovePIDThreshold_actionPerformed(true);
485  1 SliderPanel.getSliderPanel().valueChanged(50);
486  1 c = rs.findColour('I', 14, ferCapan);
487  1 assertEquals(c, Color.white);
488  1 c = rs.findColour('S', 15, ferCapan);
489  1 assertEquals(c, s_faded);
490   
491    /*
492    * turn off By Conservation
493    * should leave I white, S original (unfaded) colour
494    */
495  1 af.conservationMenuItem_actionPerformed(false);
496  1 c = rs.findColour('I', 14, ferCapan);
497  1 assertEquals(c, Color.white);
498  1 c = rs.findColour('S', 15, ferCapan);
499  1 assertEquals(c, s_original);
500   
501    /*
502    * finally turn off Above PID to leave original colours
503    */
504  1 af.abovePIDThreshold_actionPerformed(false);
505  1 c = rs.findColour('I', 14, ferCapan);
506  1 assertEquals(c, i_original);
507  1 c = rs.findColour('S', 15, ferCapan);
508  1 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  1 toggle @Test(groups = "Functional")
520    public void testNewView_colourThresholds()
521    {
522  1 AlignViewportI av = af.getViewport();
523  1 AlignmentI al = av.getAlignment();
524   
525    /*
526    * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
527    */
528  1 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
529  1 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
530  1 af.abovePIDThreshold_actionPerformed(true);
531  1 SliderPanel sp = SliderPanel.getSliderPanel();
532  1 assertFalse(sp.isForConservation());
533  1 sp.valueChanged(10);
534  1 af.conservationMenuItem_actionPerformed(true);
535  1 sp = SliderPanel.getSliderPanel();
536  1 assertTrue(sp.isForConservation());
537  1 sp.valueChanged(20);
538  1 ResidueShaderI rs = av.getResidueShading();
539  1 assertEquals(rs.getThreshold(), 10);
540  1 assertTrue(rs.conservationApplied());
541  1 assertEquals(rs.getConservationInc(), 20);
542   
543    /*
544    * create a group with Strand colouring, 30% Conservation
545    * and 40% PID threshold
546    */
547  1 SequenceGroup sg = new SequenceGroup();
548  1 sg.addSequence(al.getSequenceAt(0), false);
549  1 sg.setStartRes(15);
550  1 sg.setEndRes(25);
551  1 av.setSelectionGroup(sg);
552  1 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
553    null);
554  1 popupMenu.changeColour_actionPerformed(
555    JalviewColourScheme.Strand.toString());
556  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
557  1 assertEquals(al.getGroups().size(), 1);
558  1 assertSame(al.getGroups().get(0), sg);
559  1 popupMenu.conservationMenuItem_actionPerformed(true);
560  1 sp = SliderPanel.getSliderPanel();
561  1 assertTrue(sp.isForConservation());
562  1 sp.valueChanged(30);
563  1 popupMenu.abovePIDColour_actionPerformed(true);
564  1 sp = SliderPanel.getSliderPanel();
565  1 assertFalse(sp.isForConservation());
566  1 sp.valueChanged(40);
567  1 rs = sg.getGroupColourScheme();
568  1 assertTrue(rs.conservationApplied());
569  1 assertEquals(rs.getConservationInc(), 30);
570  1 assertEquals(rs.getThreshold(), 40);
571   
572    /*
573    * set slider panel focus to the background alignment
574    */
575  1 af.conservationMenuItem_actionPerformed(true);
576  1 sp = SliderPanel.getSliderPanel();
577  1 assertTrue(sp.isForConservation());
578  1 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  1 af.newView_actionPerformed(null);
586  1 assertEquals(af.alignPanel.getViewName(), "View 1");
587  1 AlignmentViewport av2 = af.getViewport();
588  1 assertNotSame(av, av2);
589  1 assertSame(av2, af.alignPanel.av);
590  1 rs = av2.getResidueShading();
591  1 assertNotSame(av.getResidueShading(), rs);
592  1 assertEquals(rs.getThreshold(), 10);
593  1 assertTrue(rs.conservationApplied(), rs.toString());
594  1 assertEquals(rs.getConservationInc(), 20);
595  1 assertEquals(av2.getAlignment().getGroups().size(), 1);
596  1 sg = av2.getAlignment().getGroups().get(0);
597  1 rs = sg.getGroupColourScheme();
598  1 assertTrue(rs.conservationApplied());
599  1 assertEquals(rs.getConservationInc(), 30);
600  1 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  1 sp = SliderPanel.getSliderPanel();
607  1 assertTrue(sp.isForConservation());
608  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
609    "label.conservation_colour_increment", new String[]
610    { "View 1" }));
611  1 sp.valueChanged(22);
612  1 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  1 toggle @Test(groups = "Functional")
624    public void testNewView_dsRefPreserved()
625    {
626  1 AlignViewport av = af.getViewport();
627  1 AlignmentI al = av.getAlignment();
628  1 AlignmentI original_ds = al.getDataset();
629  1 af.newView_actionPerformed(null);
630  1 assertNotEquals("New view didn't select the a new panel", av,
631    af.getViewport());
632  1 org.testng.Assert.assertEquals(original_ds,
633    af.getViewport().getAlignment().getDataset(),
634    "Dataset was not preserved in new view");
635    }
636    }