X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Futil%2FFormat.java;h=0f12eb833a6973565eae6804d73d3c9fcc9115d0;hb=e7921fdc9d6ab87ef91bb7781dd7d9316e671e3f;hp=bf520272c05cd20416444adb946bb1ad280e578f;hpb=66170487efac01381b97cda847c4a381a8c731ab;p=jalview.git diff --git a/src/jalview/util/Format.java b/src/jalview/util/Format.java index bf52027..0f12eb8 100755 --- a/src/jalview/util/Format.java +++ b/src/jalview/util/Format.java @@ -29,10 +29,13 @@ package jalview.util; import java.util.Arrays; /** - * DOCUMENT ME! + * A utility class that provides a variety of formatting methods. * - * @author $author$ - * @version $Revision$ + * Principle method {@code 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 + * + * @author unknown */ public class Format { @@ -59,12 +62,59 @@ public class Format private final String formatString; /** - * Creates a new Format object. + * Creates a new Format object given a format descriptor, which follows printf + * conventions The string has a prefix, a format code and a suffix. The prefix + * and suffix become part of the formatted output. The format code directs the + * formatting of the (single) parameter to be formatted. The code has the + * following structure + * * * @param s - * DOCUMENT ME! + * the format descriptor */ - public Format(String s) + public Format(final String s) { formatString = s; width = 0; @@ -214,63 +264,11 @@ 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 - * - * @param s - * the format string following printf conventions The string has a - * prefix, a format code and a suffix. The prefix and suffix become - * part of the formatted output. The format code directs the - * formatting of the (single) parameter to be formatted. The code has - * the following structure - * - * @exception IllegalArgumentException - * if bad format + * Returns a 6 character string consisting of the hex values of the colour's + * rgb values (left padded with zeroes if necessary) * + * @param color + * @return */ public static String getHexString(java.awt.Color color) { @@ -790,8 +788,8 @@ public class Format { w = width; } - else if (((fmt == 'd') || (fmt == 'i') || (fmt == 'x') || (fmt == 'X') || (fmt == 'o')) - && (precision > 0)) + else if (((fmt == 'd') || (fmt == 'i') || (fmt == 'x') || (fmt == 'X') + || (fmt == 'o')) && (precision > 0)) { w = precision; } @@ -833,7 +831,8 @@ public class Format double factor = 1; String leading_zeroes = ""; - for (int i = 1; (i <= precision) && (factor <= 0x7FFFFFFFFFFFFFFFL); i++) + for (int i = 1; (i <= precision) + && (factor <= 0x7FFFFFFFFFFFFFFFL); i++) { factor *= 10; leading_zeroes = leading_zeroes + "0";