Class UnitFormatUtil
- java.lang.Object
-
- ch.supertomcat.supertomcatutils.gui.formatter.UnitFormatUtil
-
public final class UnitFormatUtil extends Object
Utility class for formatting units
-
-
Field Summary
Fields Modifier and Type Field Description static intAUTO_CHANGE_SIZETakes automatically a suitable unit for displaying filesizestatic intNOPROGRESSBAR_PERCENTDisplay no progressbar and only percentstatic intNOPROGRESSBAR_SIZEDisplay no progressbar and only filesizestatic intONLY_BDisplay filesize only as bytesstatic intONLY_GIBDisplay filesize only as gibibytesstatic intONLY_KIBDisplay filesize only as kibibytesstatic intONLY_MIBDisplay filesize only as mebibytesstatic intONLY_TIBDisplay filesize only as tebibytesstatic intPROGRESSBAR_PERCENTDisplay progressbar and only percentstatic intPROGRESSBAR_SIZEDisplay progressbar and only filesize
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublegetBitrate(long size, long max, long timeStarted, long timeNow)Calculates and returns the bitrate.static StringgetBitrateString(double rate)Returns a String with the download ratestatic StringgetPercentString(long size, long max)Returns the progress as percentstatic StringgetSizeString(long size, int mode)Returns the bytes read in a suitable unit, or a specific unit, if the user defined that in the options
-
-
-
Field Detail
-
PROGRESSBAR_PERCENT
public static final int PROGRESSBAR_PERCENT
Display progressbar and only percent- See Also:
- Constant Field Values
-
PROGRESSBAR_SIZE
public static final int PROGRESSBAR_SIZE
Display progressbar and only filesize- See Also:
- Constant Field Values
-
NOPROGRESSBAR_PERCENT
public static final int NOPROGRESSBAR_PERCENT
Display no progressbar and only percent- See Also:
- Constant Field Values
-
NOPROGRESSBAR_SIZE
public static final int NOPROGRESSBAR_SIZE
Display no progressbar and only filesize- See Also:
- Constant Field Values
-
AUTO_CHANGE_SIZE
public static final int AUTO_CHANGE_SIZE
Takes automatically a suitable unit for displaying filesize- See Also:
- Constant Field Values
-
ONLY_B
public static final int ONLY_B
Display filesize only as bytes- See Also:
- Constant Field Values
-
ONLY_KIB
public static final int ONLY_KIB
Display filesize only as kibibytes- See Also:
- Constant Field Values
-
ONLY_MIB
public static final int ONLY_MIB
Display filesize only as mebibytes- See Also:
- Constant Field Values
-
ONLY_GIB
public static final int ONLY_GIB
Display filesize only as gibibytes- See Also:
- Constant Field Values
-
ONLY_TIB
public static final int ONLY_TIB
Display filesize only as tebibytes- See Also:
- Constant Field Values
-
-
Method Detail
-
getSizeString
public static String getSizeString(long size, int mode)
Returns the bytes read in a suitable unit, or a specific unit, if the user defined that in the options- Parameters:
size- Number of bytes readmode-- Returns:
- Progress-String
-
getPercentString
public static String getPercentString(long size, long max)
Returns the progress as percent- Parameters:
size- Number of bytes readmax- Filesize- Returns:
- Percent-String
-
getBitrate
public static double getBitrate(long size, long max, long timeStarted, long timeNow)Calculates and returns the bitrate. If not possible -1 is returned- Parameters:
size- Number of bytes readmax- FilesizetimeStarted- Start-TimetimeNow- Now- Returns:
- Bitrate
-
getBitrateString
public static String getBitrateString(double rate)
Returns a String with the download rate- Parameters:
rate- Bitrate- Returns:
- String with the download rate
-
-