ed46419827c8e39b90a3277a824386bc9289e1ac
[jalview.git] / test / jalview / schemes / HelixColourSchemeTest.java
1 package jalview.schemes;
2
3 import static org.testng.Assert.assertEquals;
4
5 import java.awt.Color;
6
7 import org.testng.annotations.Test;
8
9 public class HelixColourSchemeTest
10 {
11   /**
12    * Turn colours are based on the scores in ResidueProperties.helix A = 1.42, R
13    * = 0.98, N = 0.67, D = 1.01... min = 0.57 max = 1.51
14    * <p>
15    * scores are scaled to c 0-1 between min and max and colour is (c, 1-c, c)
16    */
17   @Test(groups = "Functional")
18   public void testFindColour()
19   {
20     ScoreColourScheme scheme = new HelixColourScheme();
21
22     float min = 0.57f;
23     float max = 1.51f;
24     float a = (1.42f - min) / (max - min);
25     assertEquals(scheme.findColour('A', 0, null), new Color(a, 1 - a, a));
26
27     float d = (1.01f - min) / (max - min);
28     assertEquals(scheme.findColour('D', 0, null), new Color(d, 1 - d, d));
29
30     assertEquals(scheme.findColour('-', 0, null), Color.WHITE);
31   }
32
33 }