JAL-1609 refactored colour by sequence command, now performs ok
[jalview.git] / src / jalview / util / ColorUtils.java
index fd76086..44ce010 100644 (file)
@@ -60,6 +60,26 @@ public class ColorUtils
   }
 
   /**
+   * Convert to Tk colour code format
+   * 
+   * @param colour
+   * @return
+   * @see http
+   *      ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/colortool.html#
+   *      tkcode
+   */
+  public static final String toTkCode(Color colour)
+  {
+    String colstring = "#" + ((colour.getRed() < 16) ? "0" : "")
+            + Integer.toHexString(colour.getRed())
+            + ((colour.getGreen() < 16) ? "0" : "")
+            + Integer.toHexString(colour.getGreen())
+            + ((colour.getBlue() < 16) ? "0" : "")
+            + Integer.toHexString(colour.getBlue());
+    return colstring;
+  }
+
+  /**
    * Returns a colour three shades darker. Note you can't guarantee that
    * brighterThan reverses this, as darkerThan may result in black.
    *