JAL-2055 prototype alternate feature colouring based on
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 6633156..9072ce6 100644 (file)
@@ -1587,17 +1587,22 @@ public class FeatureSettings extends JPanel implements
       tx += "Label";
       comp.setIcon(null);
     }
+    // else if (gcol.isColourAlternately())
+    // {
+    // tt = "Coloured alternately " + tt;
+    // if (thr)
+    // {
+    // tx += " ";
+    // }
+    // tx += "Alternately";
+    // comp.setIcon(null);
+    // }
     else
     {
       Color newColor = gcol.getMaxColor();
       comp.setBackground(newColor);
-      // System.err.println("Width is " + w / 2);
       Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr);
       comp.setIcon(ficon);
-      // tt+="RGB value: Max (" + newColor.getRed() + ", "
-      // + newColor.getGreen() + ", " + newColor.getBlue()
-      // + ")\nMin (" + minCol.getRed() + ", " + minCol.getGreen()
-      // + ", " + minCol.getBlue() + ")");
     }
     comp.setHorizontalAlignment(SwingConstants.CENTER);
     comp.setText(tx);
@@ -1636,7 +1641,7 @@ class FeatureIcon implements Icon
     width = w;
     height = h;
     midspace = mspace;
-    if (midspace)
+    if (midspace || gcol.isColourAlternately())
     {
       s1 = width / 3;
       e1 = s1 * 2;
@@ -1681,6 +1686,16 @@ class FeatureIcon implements Icon
       g.drawString(MessageManager.getString("label.label"), 0, 0);
 
     }
+    else if (gcol.isColourAlternately())
+    {
+      Color minCol = gcol.getMinColor();
+      g.setColor(minCol);
+      g.fillRect(0, 0, s1, height);
+      g.setColor(gcol.getMaxColor());
+      g.fillRect(s1, 0, e1 - s1, height);
+      g.setColor(minCol);
+      g.fillRect(e1, 0, width - e1, height);
+    }
     else
     {
       Color minCol = gcol.getMinColor();
@@ -1692,7 +1707,9 @@ class FeatureIcon implements Icon
         g.fillRect(s1, 0, e1 - s1, height);
       }
       g.setColor(gcol.getMaxColor());
-      g.fillRect(0, e1, width - e1, height);
+      g.fillRect(e1, 0, width - e1, height);
+      // this is wrong but works - why??
+      // g.fillRect(0, e1, width - e1, height);
     }
   }
 }