From: gmungoc Date: Thu, 8 Jun 2017 14:19:04 +0000 (+0100) Subject: JAL-2386 JAL-2570 use ResidueShader copy constructor in SequenceGroup X-Git-Tag: Release_2_10_3b1~183^2~3^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fbug%2FJAL-2386groupConservationColouring;p=jalview.git JAL-2386 JAL-2570 use ResidueShader copy constructor in SequenceGroup copy constructor for 'like but yet unlike' colouring of new group --- diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index a8d0a36..46c802f 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -188,7 +188,7 @@ public class SequenceGroup implements AnnotatedCollectionI colourText = seqsel.colourText; startRes = seqsel.startRes; endRes = seqsel.endRes; - cs = seqsel.cs;// new ResidueShader(seqsel.getColourScheme()); + cs = new ResidueShader((ResidueShader) seqsel.cs); if (seqsel.description != null) { description = new String(seqsel.description); diff --git a/src/jalview/renderer/ResidueShader.java b/src/jalview/renderer/ResidueShader.java index b6f7fe6..8ecb2ad 100644 --- a/src/jalview/renderer/ResidueShader.java +++ b/src/jalview/renderer/ResidueShader.java @@ -96,6 +96,20 @@ public class ResidueShader implements ResidueShaderI } /** + * Copy constructor + */ + public ResidueShader(ResidueShader rs) + { + this.colourScheme = rs.colourScheme; + this.consensus = rs.consensus; + this.conservation = rs.conservation; + this.conservationColouring = rs.conservationColouring; + this.conservationIncrement = rs.conservationIncrement; + this.ignoreGaps = rs.ignoreGaps; + this.pidThreshold = rs.pidThreshold; + } + + /** * @see jalview.renderer.ResidueShaderI#setConsensus(jalview.datamodel.ProfilesI) */ @Override diff --git a/test/jalview/datamodel/SequenceGroupTest.java b/test/jalview/datamodel/SequenceGroupTest.java index 80790ed..b0af5c8 100644 --- a/test/jalview/datamodel/SequenceGroupTest.java +++ b/test/jalview/datamodel/SequenceGroupTest.java @@ -9,10 +9,12 @@ import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; +import jalview.analysis.Conservation; import jalview.schemes.NucleotideColourScheme; import jalview.schemes.PIDColourScheme; import java.awt.Color; +import java.util.Collections; import junit.extensions.PA; @@ -232,6 +234,11 @@ public class SequenceGroupTest sg.setName("g1"); sg.setDescription("desc"); sg.setColourScheme(new PIDColourScheme()); + Conservation cons = new Conservation("Cons", 2, + Collections. emptyList(), 3, 12); + PA.setValue(cons, "consSequence", new Sequence("s", "abc")); + sg.getGroupColourScheme().setConservation(cons); + sg.getGroupColourScheme().setConsensus(new Profiles(null)); sg.setDisplayBoxes(false); sg.setDisplayText(false); sg.setColourText(true); @@ -253,8 +260,12 @@ public class SequenceGroupTest SequenceGroup sg2 = new SequenceGroup(sg); assertEquals(sg2.getName(), sg.getName()); assertEquals(sg2.getDescription(), sg.getDescription()); - assertSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme()); + assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme()); assertSame(sg2.getColourScheme(), sg.getColourScheme()); + assertSame(PA.getValue(sg2.getGroupColourScheme(), "consensus"), + PA.getValue(sg.getGroupColourScheme(), "consensus")); + assertSame(PA.getValue(sg2.getGroupColourScheme(), "conservation"), + PA.getValue(sg.getGroupColourScheme(), "conservation")); assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes()); assertEquals(sg2.getDisplayText(), sg.getDisplayText()); assertEquals(sg2.getColourText(), sg.getColourText());