X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FFormat.java;h=826adf699bdca73cd0f342fdc05a5097436d46cd;hb=fba030f6eaadbcecd149589009b2bc669d46b009;hp=4acf29e6bf29e6d5b3a8a3bae47c1beacf10ce2f;hpb=1ecf6419aba86993b3c223bf5ec0fa79427baf85;p=jalview.git diff --git a/src/jalview/util/Format.java b/src/jalview/util/Format.java index 4acf29e..826adf6 100755 --- a/src/jalview/util/Format.java +++ b/src/jalview/util/Format.java @@ -4,18 +4,18 @@ * Copyright (C) 1997 Sun Microsystems Inc. * All Rights Reserved. * - * Permission to use, copy, modify, and distribute this + * Permission to use, copy, modify, and distribute this * software and its documentation for NON-COMMERCIAL purposes - * and without fee is hereby granted provided that this - * copyright notice appears in all copies. - * - * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR - * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * and without fee is hereby granted provided that this + * copyright notice appears in all copies. + * + * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR + * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS - * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED - * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING + * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED + * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. */ @@ -30,7 +30,8 @@ package jalview.util; import java.io.*; -public class Format { /** +public class Format { + /** * Formats the number following printf conventions. * Main limitation: Can only handle one format parameter at a time * Use multiple Format objects to format more than one number @@ -64,8 +65,26 @@ public class Format { /** * * * @exception IllegalArgumentException if bad format + * */ + public static String getHexString(java.awt.Color color) + { + String r, g, b; + r = Integer.toHexString(color.getRed()); + if (r.length() < 2) + r = "0" + r; + g = Integer.toHexString(color.getGreen()); + if (g.length() < 2) + g = "0" + g; + b = Integer.toHexString(color.getBlue()); + if (b.length() < 2) + b = "0" + b; + + return r+g+b; + } + + public Format(String s) { width = 0; precision = -1; @@ -178,7 +197,7 @@ public class Format { /** * prints a formatted number following printf conventions * @param s a PrintStream * @param fmt the format string - * @param x the character to + * @param x the character to */ public static void print(java.io.PrintStream s, String fmt, char x) { @@ -301,7 +320,7 @@ public class Format { /** /** * Formats a double into a string (like sprintf in C) * @param x the number to format - * @return the formatted string + * @return the formatted string * @exception IllegalArgumentException if bad argument */ @@ -327,7 +346,7 @@ public class Format { /** /** * Formats a long integer into a string (like sprintf in C) * @param x the number to format - * @return the formatted string + * @return the formatted string */ public String form(long x) { @@ -356,7 +375,7 @@ public class Format { /** /** * Formats a character into a string (like sprintf in C) * @param x the value to format - * @return the formatted string + * @return the formatted string */ public String form(char c) { @@ -370,7 +389,7 @@ public class Format { /** /** * Formats a string into a larger string (like sprintf in C) * @param x the value to format - * @return the formatted string + * @return the formatted string */ public String form(String s) {