JAL-2189 apply license
[jalview.git] / src / jalview / schemes / FeatureColour.java
index bd58273..23087a8 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.schemes;
 
 import jalview.api.FeatureColourI;
@@ -111,10 +131,10 @@ public class FeatureColour implements FeatureColourI
     }
 
     /*
-     * autoScaled == true: colours range over actual score range; autoScaled ==
-     * false ('abso'): colours range over min/max range
+     * autoScaled == true: colours range over actual score range
+     * autoScaled == false ('abso'): colours range over min/max range
      */
-    boolean autoScaled = false;
+    boolean autoScaled = true;
     String tok = null, minval, maxval;
     if (mincol != null)
     {
@@ -138,15 +158,15 @@ public class FeatureColour implements FeatureColourI
       }
       tok = gcol.nextToken();
       gcol.nextToken(); // skip next '|'
-      if (tok.toLowerCase().indexOf("abso") != 0)
+      if (tok.toLowerCase().startsWith("abso"))
       {
-        minval = tok;
-        autoScaled = true;
+        minval = gcol.nextToken();
+        gcol.nextToken(); // skip next '|'
+        autoScaled = false;
       }
       else
       {
-        minval = gcol.nextToken();
-        gcol.nextToken(); // skip next '|'
+        minval = tok;
       }
       maxval = gcol.nextToken();
       if (gcol.hasMoreTokens())
@@ -317,6 +337,7 @@ public class FeatureColour implements FeatureColourI
    */
   public FeatureColour(FeatureColour fc)
   {
+    graduatedColour = fc.graduatedColour;
     colour = fc.colour;
     minColour = fc.minColour;
     maxColour = fc.maxColour;
@@ -335,9 +356,10 @@ public class FeatureColour implements FeatureColourI
     setAutoScaled(fc.isAutoScaled());
     setColourByLabel(fc.isColourByLabel());
   }
-  
+
   /**
    * Copy constructor with new min/max ranges
+   * 
    * @param fc
    * @param min
    * @param max
@@ -359,8 +381,7 @@ public class FeatureColour implements FeatureColourI
    * Sets the 'graduated colour' flag. If true, also sets 'colour by label' to
    * false.
    */
-  @Override
-  public void setGraduatedColour(boolean b)
+  void setGraduatedColour(boolean b)
   {
     graduatedColour = b;
     if (b)
@@ -406,6 +427,7 @@ public class FeatureColour implements FeatureColourI
       setGraduatedColour(false);
     }
   }
+
   @Override
   public boolean isBelowThreshold()
   {
@@ -543,7 +565,8 @@ public class FeatureColour implements FeatureColourI
     {
       scl = 1f;
     }
-    return new Color(minRed + scl * deltaRed, minGreen + scl * deltaGreen, minBlue + scl * deltaBlue);
+    return new Color(minRed + scl * deltaRed, minGreen + scl * deltaGreen,
+            minBlue + scl * deltaBlue);
   }
 
   /**
@@ -643,7 +666,7 @@ public class FeatureColour implements FeatureColourI
       {
         sb.append(Format.getHexString(getMinColour())).append(BAR);
         sb.append(Format.getHexString(getMaxColour())).append(BAR);
-        if (isAutoScaled())
+        if (!isAutoScaled())
         {
           sb.append("abso").append(BAR);
         }