From: gmungoc Date: Tue, 26 Feb 2019 10:41:05 +0000 (+0000) Subject: JAL-3201 group colour schemes distinct instances X-Git-Tag: Release_2_11_0~17^2~99 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0356abc2cb7040672bc8fde68cafb77a2d623b5d;p=jalview.git JAL-3201 group colour schemes distinct instances --- diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index a4d4807..ec02bb1 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1872,8 +1872,11 @@ public class SeqPanel extends JPanel && afterDrag; if (stretchGroup.cs != null) { - stretchGroup.cs.alignmentChanged(stretchGroup, - av.getHiddenRepSequences()); + if (afterDrag) + { + stretchGroup.cs.alignmentChanged(stretchGroup, + av.getHiddenRepSequences()); + } ResidueShaderI groupColourScheme = stretchGroup .getGroupColourScheme(); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 1366ada..ca32ee7 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -662,7 +662,7 @@ public abstract class AlignmentViewport * retain any colour thresholds per group while * changing choice of colour scheme (JAL-2386) */ - sg.setColourScheme(cs); + sg.setColourScheme(cs.getInstance(sg, hiddenRepSequences)); if (cs != null) { sg.getGroupColourScheme().alignmentChanged(sg, diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 7801250..959abb0 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -23,6 +23,7 @@ package jalview.gui; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNotSame; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; @@ -33,8 +34,6 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SearchResults; import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; @@ -42,6 +41,7 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.DataSourceType; import jalview.io.FileLoader; +import jalview.schemes.ClustalxColourScheme; import jalview.schemes.ColourSchemeI; import jalview.schemes.PIDColourScheme; import jalview.structure.StructureSelectionManager; @@ -333,9 +333,34 @@ public class AlignViewportTest AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); ColourSchemeI cs = new PIDColourScheme(); - af.getViewport().setGlobalColourScheme(cs); - assertFalse(af.getViewport().getResidueShading() + AlignViewport viewport = af.getViewport(); + viewport.setGlobalColourScheme(cs); + assertFalse(viewport.getResidueShading() .conservationApplied()); + + /* + * JAL-3201 groups have their own ColourSchemeI instances + */ + AlignmentI aln = viewport.getAlignment(); + SequenceGroup sg1 = new SequenceGroup(); + sg1.addSequence(aln.getSequenceAt(0), false); + sg1.addSequence(aln.getSequenceAt(2), false); + SequenceGroup sg2 = new SequenceGroup(); + sg2.addSequence(aln.getSequenceAt(1), false); + sg2.addSequence(aln.getSequenceAt(3), false); + aln.addGroup(sg1); + aln.addGroup(sg2); + viewport.setColourAppliesToAllGroups(true); + viewport.setGlobalColourScheme(new ClustalxColourScheme()); + ColourSchemeI cs0 = viewport.getGlobalColourScheme(); + ColourSchemeI cs1 = sg1.getColourScheme(); + ColourSchemeI cs2 = sg2.getColourScheme(); + assertTrue(cs0 instanceof ClustalxColourScheme); + assertTrue(cs1 instanceof ClustalxColourScheme); + assertTrue(cs2 instanceof ClustalxColourScheme); + assertNotSame(cs0, cs1); + assertNotSame(cs0, cs2); + assertNotSame(cs1, cs2); } @Test(groups = { "Functional" })