X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;h=e13f5421c2749ed44d5ff3f21b6447a1d6f2649c;hb=b4ae8736c4d0d6bcba332dc875dd5eabd8d4c851;hp=483ea5df85ee73ab04e5d038d21e46431d8317ec;hpb=3e943322f9d66e8718316ba8bd03669adce65149;p=jalview.git diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 483ea5d..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); @@ -166,7 +204,7 @@ public class FeatureColourTest */ fc = new FeatureColour(Color.GREEN, Color.RED, 12f, 25f); String greenHex = Format.getHexString(Color.GREEN); - String expected = String.format("domain\t%s|%s|12.0|25.0|none", + String expected = String.format("domain\t%s|%s|abso|12.0|25.0|none", greenHex, redHex); assertEquals(expected, fc.toJalviewFormat("domain")); @@ -174,7 +212,7 @@ public class FeatureColourTest * colour ranges over the actual score ranges (not min/max) */ fc.setAutoScaled(true); - expected = String.format("domain\t%s|%s|abso|12.0|25.0|none", greenHex, + expected = String.format("domain\t%s|%s|12.0|25.0|none", greenHex, redHex); assertEquals(expected, fc.toJalviewFormat("domain")); @@ -183,7 +221,7 @@ public class FeatureColourTest */ fc.setThreshold(12.5f); fc.setBelowThreshold(true); - expected = String.format("domain\t%s|%s|abso|12.0|25.0|below|12.5", + expected = String.format("domain\t%s|%s|12.0|25.0|below|12.5", greenHex, redHex); assertEquals(expected, fc.toJalviewFormat("domain")); @@ -192,6 +230,7 @@ public class FeatureColourTest */ fc.setThreshold(12.5f); fc.setAboveThreshold(true); + fc.setAutoScaled(false); expected = String.format("domain\t%s|%s|abso|12.0|25.0|above|12.5", greenHex, redHex); assertEquals(expected, fc.toJalviewFormat("domain")); @@ -296,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()); } }