com.limegroup.gnutella.gui
Class GUIUtils

java.lang.Object
  extended bycom.limegroup.gnutella.gui.GUIUtils

public final class GUIUtils
extends java.lang.Object

This class serves as a holder for any static gui convenience methods.


Field Summary
static java.lang.String GENERAL_UNIT_GIGABYTES
           
static java.lang.String GENERAL_UNIT_KBPSEC
           
static java.lang.String GENERAL_UNIT_KILOBYTES
          Localizable constants
static java.lang.String GENERAL_UNIT_MEGABYTES
           
static java.lang.String GENERAL_UNIT_TERABYTES
           
 
Method Summary
static MultiLineLabel getSizedLabel(java.lang.String msg)
          Returns a label with multiple lines that is sized according to the string parameter.
static java.lang.String msec2DateTime(long milliseconds)
          Converts number of milliseconds since way back when to a local-formatted date String
static java.lang.String rate2speed(double rate)
          Converts an rate into a human readable and localized KB/s speed.
static java.lang.String seconds2time(int seconds)
          Converts a value in seconds to: "d:hh:mm:ss" where d=days, hh=hours, mm=minutes, ss=seconds, or "h:mm:ss" where h=hours<24, mm=minutes, ss=seconds, or "m:ss" where m=minutes<60, ss=seconds
static java.lang.String speed2name(int rate)
          Converts the following bandwidth value, in kbytes/second, to a human readable.
static java.lang.String toKilobytes(long bytes)
          This static method converts the passed in number of bytes into a kilobyte string grouping digits with locale-dependant thousand separator and with "KB" locale-dependant unit at the end.
static java.lang.String toLocalizedInteger(long value)
          This static method converts the passed in number into a localizable representation of an integer, with digit grouping using locale dependant separators.
static java.lang.String toUnitbytes(long bytes)
          Converts the passed in number of bytes into a byte-size string.
static java.lang.String toUnitnumber(double value, boolean allowFractional)
          Converts the passed in number into a short localized string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERAL_UNIT_KILOBYTES

public static final java.lang.String GENERAL_UNIT_KILOBYTES
Localizable constants


GENERAL_UNIT_MEGABYTES

public static final java.lang.String GENERAL_UNIT_MEGABYTES

GENERAL_UNIT_GIGABYTES

public static final java.lang.String GENERAL_UNIT_GIGABYTES

GENERAL_UNIT_TERABYTES

public static final java.lang.String GENERAL_UNIT_TERABYTES

GENERAL_UNIT_KBPSEC

public static final java.lang.String GENERAL_UNIT_KBPSEC
Method Detail

toLocalizedInteger

public static java.lang.String toLocalizedInteger(long value)
This static method converts the passed in number into a localizable representation of an integer, with digit grouping using locale dependant separators.

Parameters:
value - the number to convert to a numeric String.
Returns:
a localized String representing the integer value

toKilobytes

public static java.lang.String toKilobytes(long bytes)
This static method converts the passed in number of bytes into a kilobyte string grouping digits with locale-dependant thousand separator and with "KB" locale-dependant unit at the end.

Parameters:
bytes - the number of bytes to convert to a kilobyte String.
Returns:
a String representing the number of kilobytes that the bytes argument evaluates to, with "KB" appended at the end. If the input value is negative, the string returned will be "? KB".

toUnitbytes

public static java.lang.String toUnitbytes(long bytes)
Converts the passed in number of bytes into a byte-size string. Group digits with locale-dependant thousand separator if needed, but with "KB", or "MB" or "GB" or "TB" locale-dependant unit at the end, and a limited precision of 4 significant digits.

Parameters:
bytes - the number of bytes to convert to a size String.
Returns:
a String representing the number of kilobytes that the bytes argument evaluates to, with "KB"/"MB"/"GB"/TB" appended at the end. If the input value is negative, the string returned will be "? KB".

toUnitnumber

public static java.lang.String toUnitnumber(double value,
                                            boolean allowFractional)
Converts the passed in number into a short localized string. Group digits with locale-dependant thousand separator if needed, but first try to append a "k", "M", "G", or "T" locale-independant unit. Allows negative numbers in a locale-dependant representation.

Parameters:
value - the number of bytes to convert to a size String.
allowFractional - enables 1 fractional digit for values lower than 999.95; 1 fractional digit is always enabled for values greater than or equal to 99999.5, which have a unit appended.
Returns:
a String representing the number that the value argument evaluates to, with a possible "k"/"M"/"G"/T" unit appended at the end.

getSizedLabel

public static MultiLineLabel getSizedLabel(java.lang.String msg)
Returns a label with multiple lines that is sized according to the string parameter.

Parameters:
msg - the string that will be contained in the label.
Returns:
a MultiLineLabel sized according to the passed in string.

speed2name

public static java.lang.String speed2name(int rate)
Converts the following bandwidth value, in kbytes/second, to a human readable.


rate2speed

public static java.lang.String rate2speed(double rate)
Converts an rate into a human readable and localized KB/s speed.


seconds2time

public static java.lang.String seconds2time(int seconds)
Converts a value in seconds to: "d:hh:mm:ss" where d=days, hh=hours, mm=minutes, ss=seconds, or "h:mm:ss" where h=hours<24, mm=minutes, ss=seconds, or "m:ss" where m=minutes<60, ss=seconds


msec2DateTime

public static java.lang.String msec2DateTime(long milliseconds)
Converts number of milliseconds since way back when to a local-formatted date String