JAL-2835 support filter/colour by nested attribute names
[jalview.git] / src / jalview / schemes / FeatureColour.java
index 168ab54..71a89b0 100644 (file)
@@ -78,10 +78,10 @@ public class FeatureColour implements FeatureColourI
   private boolean colourByLabel;
 
   /*
-   * if not null, the value of this named attribute is used for
-   * colourByLabel or graduatedColour
+   * if not null, the value of [attribute, [sub-attribute] ...]
+   *  is used for colourByLabel or graduatedColour
    */
-  private String byAttributeName;
+  private String[] attributeName;
 
   private float threshold;
 
@@ -371,7 +371,7 @@ public class FeatureColour implements FeatureColourI
     base = fc.base;
     range = fc.range;
     isHighToLow = fc.isHighToLow;
-    byAttributeName = fc.byAttributeName;
+    attributeName = fc.attributeName;
     setAboveThreshold(fc.isAboveThreshold());
     setBelowThreshold(fc.isBelowThreshold());
     setThreshold(fc.getThreshold());
@@ -593,8 +593,8 @@ public class FeatureColour implements FeatureColourI
   {
     if (isColourByLabel())
     {
-      String label = byAttributeName == null ? feature.getDescription()
-              : feature.getValueAsString(byAttributeName);
+      String label = attributeName == null ? feature.getDescription()
+              : feature.getValueAsString(attributeName);
       return label == null ? noColour : ColorUtils
               .createColourFromName(label);
     }
@@ -611,11 +611,11 @@ public class FeatureColour implements FeatureColourI
      * no such attribute is assigned the 'no value' colour
      */
     float scr = feature.getScore();
-    if (byAttributeName != null)
+    if (attributeName != null)
     {
       try
       {
-        String attVal = feature.getValueAsString(byAttributeName);
+        String attVal = feature.getValueAsString(attributeName);
         scr = Float.valueOf(attVal);
       } catch (Throwable e)
       {
@@ -746,19 +746,19 @@ public class FeatureColour implements FeatureColourI
   @Override
   public boolean isColourByAttribute()
   {
-    return byAttributeName != null;
+    return attributeName != null;
   }
 
   @Override
-  public String getAttributeName()
+  public String[] getAttributeName()
   {
-    return byAttributeName;
+    return attributeName;
   }
 
   @Override
-  public void setAttributeName(String name)
+  public void setAttributeName(String... name)
   {
-    byAttributeName = name;
+    attributeName = name;
   }
 
 }