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