From: gmungoc Date: Wed, 22 Jun 2016 15:09:00 +0000 (+0100) Subject: JAL-2015 fixed bug in copy constructor and added tests X-Git-Tag: Release_2_10_0~159^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=579d3d1bccf00ce126ab3574758c6558b1bc3367;p=jalview.git JAL-2015 fixed bug in copy constructor and added tests --- diff --git a/src/jalview/schemes/FeatureColour.java b/src/jalview/schemes/FeatureColour.java index 213868b..bdc70c9 100644 --- a/src/jalview/schemes/FeatureColour.java +++ b/src/jalview/schemes/FeatureColour.java @@ -317,6 +317,7 @@ public class FeatureColour implements FeatureColourI */ public FeatureColour(FeatureColour fc) { + graduatedColour = fc.graduatedColour; colour = fc.colour; minColour = fc.minColour; maxColour = fc.maxColour; diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 9b1bd73..e13f542 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -15,6 +15,44 @@ import org.testng.annotations.Test; public class FeatureColourTest { @Test(groups = { "Functional" }) + public void testCopyConstructor() + { + /* + * plain colour + */ + FeatureColour fc = new FeatureColour(Color.RED); + FeatureColour fc1 = new FeatureColour(fc); + assertTrue(fc1.getColour().equals(Color.RED)); + assertFalse(fc1.isGraduatedColour()); + assertFalse(fc1.isColourByLabel()); + + /* + * min-max colour + */ + fc = new FeatureColour(Color.gray, Color.black, 10f, 20f); + fc.setAboveThreshold(true); + fc.setThreshold(12f); + fc1 = new FeatureColour(fc); + assertTrue(fc1.isGraduatedColour()); + assertFalse(fc1.isColourByLabel()); + assertTrue(fc1.isAboveThreshold()); + assertEquals(12f, fc1.getThreshold()); + assertEquals(Color.gray, fc1.getMinColour()); + assertEquals(Color.black, fc1.getMaxColour()); + assertEquals(10f, fc1.getMin()); + assertEquals(20f, fc1.getMax()); + + /* + * colour by label + */ + fc = new FeatureColour(); + fc.setColourByLabel(true); + fc1 = new FeatureColour(fc); + assertTrue(fc1.isColourByLabel()); + assertFalse(fc1.isGraduatedColour()); + } + + @Test(groups = { "Functional" }) public void testIsColored_simpleColour() { FeatureColour fc = new FeatureColour(Color.RED); @@ -297,5 +335,10 @@ public class FeatureColourTest assertEquals(Color.GREEN, fc.getMaxColour()); assertEquals(10f, fc.getMin()); assertEquals(20f, fc.getMax()); + + descriptor = String + .format("blue|255,0,255|absolute|20.0|95.0|below|66.0"); + fc = FeatureColour.parseJalviewFeatureColour(descriptor); + assertTrue(fc.isGraduatedColour()); } }