org.jmol.util
public class TextFormat extends Object
Modifier and Type | Field and Description |
---|---|
private static DecimalFormat[] |
formatters |
private static String[] |
formattingStrings |
private static Boolean[] |
useNumberLocalization |
Constructor and Description |
---|
TextFormat() |
Modifier and Type | Method and Description |
---|---|
private static String |
fdup(String f,
int pt,
int n)
fdup duplicates p or q formats for formatCheck
and the format() function.
|
static String |
format(double value,
int width,
int precision,
boolean alignLeft,
boolean zeroPad,
boolean allowOverflow) |
static String |
format(float value,
int width,
int precision,
boolean alignLeft,
boolean zeroPad) |
static String |
format(String value,
int width,
int precision,
boolean alignLeft,
boolean zeroPad) |
static String |
formatCheck(String strFormat)
formatCheck checks p and q formats and duplicates if necessary
"%10.5p xxxx" ==> "%10.5p%10.5p%10.5p xxxx"
|
static String |
formatDecimal(float value,
int decimalDigits) |
static String |
formatString(String strFormat,
String key,
float floatT) |
static String |
formatString(String strFormat,
String key,
int intT) |
static String |
formatString(String strFormat,
String key,
String strT) |
private static String |
formatString(String strFormat,
String key,
String strT,
float floatT,
double doubleT,
boolean doOne)
generic string formatter based on formatLabel in Atom
|
static boolean |
isMatch(String s,
String strWildcard,
boolean checkStar,
boolean allowInitialStar) |
static boolean |
isWild(String s) |
static String |
join(Object[] s,
char c,
int i0) |
static void |
lFill(StringBuffer s,
String s1,
String s2) |
static String |
replaceAllCharacters(String str,
String strFrom,
char chTo)
Does a clean replace of any of the characters in str with chrTo
If strTo contains strFrom, then only a single pass is done.
|
static String |
replaceAllCharacters(String str,
String strFrom,
String strTo)
Does a clean replace of any of the characters in str with strTo
If strTo contains strFrom, then only a single pass is done.
|
static String |
replaceQuotedStrings(String s,
List<String> list,
List<String> newList) |
static String |
replaceStrings(String s,
List<String> list,
List<String> newList) |
static void |
rFill(StringBuffer s,
String s1,
String s2) |
static String |
safeTruncate(float f,
int n) |
static void |
setUseNumberLocalization(boolean TF) |
static String |
simpleReplace(String str,
String strFrom,
String strTo)
Does a clean replace of strFrom in str with strTo
If strTo contains strFrom, then only a single pass is done.
|
static String[] |
split(String text,
char ch) |
static String[] |
split(String text,
String run)
proper splitting, even for Java 1.3 -- if the text ends in the run,
no new line is appended.
|
static String |
sprintf(String strFormat,
Object[] values)
sprintf emulation uses (almost) c++ standard string formats 's' string 'i'
or 'd' integer 'f' float/decimal 'p' point3f 'q' quaternion/plane/axisangle
' with added "i" in addion to the insipid "d" (digits?)
|
static String |
trim(String str,
String chars) |
private static final DecimalFormat[] formatters
private static final String[] formattingStrings
private static final Boolean[] useNumberLocalization
public static void setUseNumberLocalization(boolean TF)
public static String formatDecimal(float value, int decimalDigits)
public static String format(float value, int width, int precision, boolean alignLeft, boolean zeroPad)
public static String format(double value, int width, int precision, boolean alignLeft, boolean zeroPad, boolean allowOverflow)
value
- width
- precision
- alignLeft
- zeroPad
- allowOverflow
- IGNOREDpublic static String format(String value, int width, int precision, boolean alignLeft, boolean zeroPad)
value
- width
- number of columnsprecision
- precision > 0 ==> precision = number of characters max from left
precision < 0 ==> -1 - precision = number of char. max from rightalignLeft
- zeroPad
- generally for numbers turned stringspublic static String sprintf(String strFormat, Object[] values)
strFormat
- values
- private static String formatString(String strFormat, String key, String strT, float floatT, double doubleT, boolean doOne)
strFormat
- .... %width.precisionKEY....key
- any string to matchstrT
- replacement string or nullfloatT
- replacement float or Float.NaNdoubleT
- replacement double or Double.NaN -- for exponentialdoOne
- mimic sprintfpublic static String formatCheck(String strFormat)
strFormat
- private static String fdup(String f, int pt, int n)
f
- pt
- n
- public static String[] split(String text, String run)
text
- run
- public static String replaceAllCharacters(String str, String strFrom, String strTo)
str
- strFrom
- strTo
- public static String replaceAllCharacters(String str, String strFrom, char chTo)
str
- strFrom
- chTo
- public static String simpleReplace(String str, String strFrom, String strTo)
str
- strFrom
- strTo
- public static void lFill(StringBuffer s, String s1, String s2)
public static void rFill(StringBuffer s, String s1, String s2)
public static String safeTruncate(float f, int n)
public static boolean isWild(String s)
public static boolean isMatch(String s, String strWildcard, boolean checkStar, boolean allowInitialStar)
public static String replaceQuotedStrings(String s, List<String> list, List<String> newList)