本文整理汇总了Java中com.trollworks.toolkit.utility.text.Numbers.format方法的典型用法代码示例。如果您正苦于以下问题:Java Numbers.format方法的具体用法?Java Numbers.format怎么用?Java Numbers.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.trollworks.toolkit.utility.text.Numbers
的用法示例。
在下文中一共展示了Numbers.format方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valueToString
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
@Override
public String valueToString(Object value) throws ParseException {
if (value instanceof Integer) {
int percentage = ((Integer) value).intValue();
if (percentage != 0) {
return Numbers.format(percentage) + "%"; //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
} else if (value instanceof WeightValue) {
WeightValue weight = (WeightValue) value;
if (weight.getValue() == 0) {
return ""; //$NON-NLS-1$
}
return weight.toString();
}
return ""; //$NON-NLS-1$
}
示例2: getSkillDisplayLevel
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
/**
* Creates a string suitable for displaying the level.
*
* @param level The skill level.
* @param relativeLevel The relative skill level.
* @param attribute The attribute the skill is based on.
* @param isContainer Whether this skill is a container or not.
* @return The formatted string.
*/
public static String getSkillDisplayLevel(int level, int relativeLevel, SkillAttribute attribute, boolean isContainer) {
if (isContainer) {
return EMPTY;
}
if (level < 0) {
return "-"; //$NON-NLS-1$
}
return Numbers.format(level) + SLASH + attribute + Numbers.formatWithForcedSign(relativeLevel);
}
示例3: getQualifierAsString
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
@Override
public String getQualifierAsString(boolean allowAdornments) {
return allowAdornments ? Numbers.format(mQualifier) : Integer.toString(mQualifier);
}
示例4: getDisplayLevel
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
private static String getDisplayLevel(SkillAttribute attribute, int level, int relativeLevel) {
if (level < 0) {
return "-"; //$NON-NLS-1$
}
return Numbers.format(level) + "/" + attribute + Numbers.formatWithForcedSign(relativeLevel); //$NON-NLS-1$
}
示例5: getResolvedValue
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
private String getResolvedValue(String input, SkillDefaultType baseDefaultType) {
DataFile df = getOwner().getDataFile();
if (df instanceof GURPSCharacter) {
GURPSCharacter character = (GURPSCharacter) df;
StringTokenizer tokenizer = new StringTokenizer(input, "\n\r", true); //$NON-NLS-1$
StringBuffer buffer = new StringBuffer();
int skillLevel = Integer.MAX_VALUE;
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (!token.equals("\n") && !token.equals("\r")) { //$NON-NLS-1$ //$NON-NLS-2$
int max = token.length();
int i = skipSpaces(token, 0);
if (i < max) {
char ch = token.charAt(i);
boolean neg = false;
int modifier = 0;
boolean found = false;
if (ch == '-' || ch == '+') {
neg = ch == '-';
if (++i < max) {
ch = token.charAt(i);
}
}
while (i < max && ch >= '0' && ch <= '9') {
found = true;
modifier *= 10;
modifier += ch - '0';
if (++i < max) {
ch = token.charAt(i);
}
}
if (found) {
String num;
if (skillLevel == Integer.MAX_VALUE) {
int best = Integer.MIN_VALUE;
for (SkillDefault skillDefault : getDefaults()) {
SkillDefaultType type = skillDefault.getType();
int level = type.getSkillLevelFast(character, skillDefault, new HashSet<String>());
if (level != Integer.MIN_VALUE && type != baseDefaultType) {
level = level / 2 + 3 + (baseDefaultType == SkillDefaultType.Parry ? character.getParryBonus() : character.getBlockBonus());
}
if (level > best) {
best = level;
}
}
skillLevel = best != Integer.MIN_VALUE ? best : 0;
}
num = Numbers.format(skillLevel + (neg ? -modifier : modifier) + (token.contains("F") ? character.getEncumbranceLevel().getEncumbrancePenalty() : 0)); //$NON-NLS-1$
if (i < max) {
buffer.append(num);
token = token.substring(i);
} else {
token = num;
}
}
}
}
buffer.append(token);
}
return buffer.toString();
}
return input;
}
示例6: getText
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
private String getText() {
return "\u00bb" + Numbers.format(mHidden.size()); //$NON-NLS-1$
}
示例7: formatMB
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
private static String formatMB(long amt) {
return Numbers.format((amt + MB / 2) / MB);
}
示例8: getTechniqueDisplayLevel
import com.trollworks.toolkit.utility.text.Numbers; //导入方法依赖的package包/类
/**
* Creates a string suitable for displaying the level.
*
* @param level The skill level.
* @param relativeLevel The relative skill level.
* @param modifier The modifer to the skill level.
* @return The formatted string.
*/
public static String getTechniqueDisplayLevel(int level, int relativeLevel, int modifier) {
if (level < 0) {
return "-"; //$NON-NLS-1$
}
return Numbers.format(level) + "/" + Numbers.formatWithForcedSign(relativeLevel + modifier); //$NON-NLS-1$
}