JAL-2069 corrected overloaded constructor behaviour
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 7 Nov 2017 13:13:46 +0000 (13:13 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 7 Nov 2017 13:13:46 +0000 (13:13 +0000)
src/jalview/schemes/FeatureColour.java
test/jalview/schemes/FeatureColourTest.java

index df4ea39..168ab54 100644 (file)
@@ -389,7 +389,6 @@ public class FeatureColour implements FeatureColourI
   public FeatureColour(FeatureColour fc, float min, float max)
   {
     this(fc);
-    setGraduatedColour(true);
     updateBounds(min, max);
   }
 
index 3f60152..db4fe40 100644 (file)
@@ -183,6 +183,19 @@ public class FeatureColourTest
     assertTrue((boolean) PA.getValue(fc1, "isHighToLow"));
 
     /*
+     * graduated colour by attribute
+     */
+    fc1.setAttributeName("AF");
+    fc1 = new FeatureColour(fc1, 13f, 36f);
+    assertTrue(fc1.isGraduatedColour());
+    assertFalse(fc1.isColourByLabel());
+    assertTrue(fc1.isColourByAttribute());
+    assertEquals("AF", fc1.getAttributeName());
+    assertEquals(13f, fc1.getMin());
+    assertEquals(36f, fc1.getMax());
+    assertFalse((boolean) PA.getValue(fc1, "isHighToLow"));
+
+    /*
      * colour by label
      */
     fc = new FeatureColour(Color.BLUE, Color.RED, 1f, 5f);
@@ -195,15 +208,27 @@ public class FeatureColourTest
     assertEquals(5f, fc.getMax());
 
     /*
-     * update min-max bounds - converts to graduated colour
+     * update min-max bounds
      */
     fc1 = new FeatureColour(fc, 2f, 6f);
-    assertTrue(fc1.isGraduatedColour());
-    assertFalse(fc1.isColourByLabel());
+    assertFalse(fc1.isGraduatedColour());
+    assertTrue(fc1.isColourByLabel());
     assertFalse(fc1.isColourByAttribute());
     assertNull(fc1.getAttributeName());
     assertEquals(2f, fc1.getMin());
     assertEquals(6f, fc1.getMax());
+
+    /*
+     * colour by attribute text
+     */
+    fc1.setAttributeName("AC");
+    fc1 = new FeatureColour(fc1, 13f, 36f);
+    assertFalse(fc1.isGraduatedColour());
+    assertTrue(fc1.isColourByLabel());
+    assertTrue(fc1.isColourByAttribute());
+    assertEquals("AC", fc1.getAttributeName());
+    assertEquals(13f, fc1.getMin());
+    assertEquals(36f, fc1.getMax());
   }
 
   @Test(groups = { "Functional" })