X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;h=52ca3601fd3c21caf47b2d5bee8f1bd65ba2c917;hp=8f7ac7cd5804819636e0eada5527ffb3c08eb100;hb=ee7d621eea4811c90ce8bc470cc1e217cd2d806c;hpb=7e00183505bd4c58d1ce62ee121ed372c3b058f2 diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 8f7ac7c..52ca360 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -700,4 +700,101 @@ public class FeatureColourTest sf.setValue("AC", "junk"); assertFalse(fc.isOutwithThreshold(sf)); // bad value is ignored } + + /** + * Test description of feature colour suitable for a tooltip + */ + @Test(groups = { "Functional" }) + public void testGetDescription() + { + /* + * plain colour + */ + FeatureColour fc = new FeatureColour(Color.RED); + assertEquals( + String.format("r=%d,g=%d,b=%d", Color.RED.getRed(), + Color.red.getGreen(), Color.red.getBlue()), + fc.getDescription()); + + /* + * colour by label (no threshold) + */ + fc = new FeatureColour(); + fc.setColourByLabel(true); + assertEquals("By Label", fc.getDescription()); + + /* + * colour by attribute text (no threshold) + */ + fc = new FeatureColour(); + fc.setColourByLabel(true); + fc.setAttributeName("CLIN_SIG"); + assertEquals("By CLIN_SIG", fc.getDescription()); + + /* + * colour by label (above score threshold) + */ + fc = new FeatureColour(); + fc.setColourByLabel(true); + fc.setAutoScaled(false); + fc.setThreshold(12.5f); + fc.setAboveThreshold(true); + assertEquals("By Label (Score > 12.5)", + fc.getDescription()); + + /* + * colour by label (below score threshold) + */ + fc.setBelowThreshold(true); + assertEquals("By Label (Score < 12.5)", + fc.getDescription()); + + /* + * colour by attributes text (below score threshold) + */ + fc.setBelowThreshold(true); + fc.setAttributeName("CSQ", "Consequence"); + assertEquals( + "By CSQ:Consequence (Score < 12.5)", + fc.getDescription()); + + /* + * graduated colour by score, no threshold + */ + fc = new FeatureColour(null, Color.GREEN, Color.RED, null, 12f, 25f); + assertEquals("By Score", fc.getDescription()); + + /* + * graduated colour by score, below threshold + */ + fc.setThreshold(12.5f); + fc.setBelowThreshold(true); + assertEquals("By Score (< 12.5)", + fc.getDescription()); + + /* + * graduated colour by score, above threshold + */ + fc.setThreshold(12.5f); + fc.setAboveThreshold(true); + fc.setAutoScaled(false); + assertEquals("By Score (> 12.5)", + fc.getDescription()); + + /* + * graduated colour by attribute, no threshold + */ + fc.setAttributeName("CSQ", "AF"); + fc.setAboveThreshold(false); + fc.setAutoScaled(false); + assertEquals("By CSQ:AF", fc.getDescription()); + + /* + * graduated colour by attribute, above threshold + */ + fc.setAboveThreshold(true); + fc.setAutoScaled(false); + assertEquals("By CSQ:AF (> 12.5)", + fc.getDescription()); + } }