f3b93a9c884d2d020d5aed92fbbcaec3f2e1932a
[jalview.git] / test / jalview / schemes / HydrophobicColourSchemeTest.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 HydrophobicColourSchemeTest
10 {
11   /**
12    * Turn colours are based on the scores in ResidueProperties.hyd A = 1.8, R =
13    * -4.5, N = -3.5, D = -3.5... min = -3.9 max = 4.5
14    * <p>
15    * scores are scaled to c 0-1 between min and max and colour is (c, 0, 1-c)
16    */
17   @Test(groups = "Functional")
18   public void testFindColour()
19   {
20     ScoreColourScheme scheme = new HydrophobicColourScheme();
21
22     float min = -3.9f;
23     float max = 4.5f;
24     float a = (1.8f - min) / (max - min);
25     assertEquals(scheme.findColour('A', 0, null),
26  new Color(a, 0, 1 - a));
27
28     float d = (-3.5f - min) / (max - min);
29     assertEquals(scheme.findColour('D', 0, null),
30  new Color(d, 0, 1 - d));
31
32     assertEquals(scheme.findColour('-', 0, null), Color.WHITE);
33   }
34
35 }