本文整理汇总了Java中com.google.gwt.i18n.client.NumberFormat.format方法的典型用法代码示例。如果您正苦于以下问题:Java NumberFormat.format方法的具体用法?Java NumberFormat.format怎么用?Java NumberFormat.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.i18n.client.NumberFormat
的用法示例。
在下文中一共展示了NumberFormat.format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHighScore
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public void setHighScore(int scoreIndex, String playerName, int highScore) {
int maxLength = SCORE_PAGE.texttspan5634().length();
NumberFormat decimalFormat = NumberFormat.getDecimalFormat();
String formattedScore = decimalFormat.format(highScore);
playerName += " ";
String labelText = playerName.substring(0, maxLength - 1 - formattedScore.length()).concat(" ").concat(formattedScore);
// labelText = labelText.replace(" ", " ");
// String.format("%1$" + n + "s", playerName);
switch (scoreIndex) {
case 0:
scorePageBuilder.setLabel(SvgTextElements.tspan4348, labelText);
break;
case 1:
scorePageBuilder.setLabel(SvgTextElements.tspan5630, labelText);
break;
case 2:
scorePageBuilder.setLabel(SvgTextElements.tspan4379, labelText);
break;
case 3:
scorePageBuilder.setLabel(SvgTextElements.tspan5632, labelText);
break;
case 4:
scorePageBuilder.setLabel(SvgTextElements.tspan5634, labelText);
break;
}
}
示例2: printMessage
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public void printMessage(String eventName, int code, boolean modifier, boolean control) {
final NumberFormat formatter = NumberFormat.getDecimalFormat();
String message = eventName + " - Char Code: " + formatter.format(code) + ". ";
if(code == KeyCodes.KEY_ENTER) {
message += "Key is ENTER. ";
}
if(modifier)
message += "Modifier is down. ";
if(control)
message += "CTRL is down. ";
logger.info("message"+message);
}
示例3: compassLon
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public static String compassLon(double lon) {
NumberFormat lonFormat = NumberFormat.getFormat("####.##");
String compass_lon;
if ( lon < 0.0 ) {
compass_lon = lonFormat.format(Math.abs(lon))+" W";
} else {
compass_lon = lonFormat.format(lon)+" E";
}
return compass_lon;
}
示例4: compassLat
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public static String compassLat(double lat) {
NumberFormat latFormat = NumberFormat.getFormat("###.##");
String compass_lat;
if ( lat <= 0.0 ) {
compass_lat = latFormat.format(Math.abs(lat))+" S";
} else {
compass_lat = latFormat.format(lat)+" N";
}
return compass_lat;
}
示例5: createText
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
protected String createText() {
NumberFormat formatter = NumberFormat.getFormat( "#,###" );
HasRows display = getDisplay();
Range range = display.getVisibleRange();
int pageStart = range.getStart() + 1;
int pageSize = range.getLength();
int dataSize = display.getRowCount();
int endIndex = Math.min( dataSize,
pageStart
+ pageSize
- 1 );
endIndex = Math.max( pageStart,
endIndex );
boolean exact = display.isRowCountExact();
if ( dataSize == 0 ) {
return "0 of 0";
} else if ( pageStart == endIndex ) {
return formatter.format( pageStart )
+ " of "
+ formatter.format( dataSize );
}
return formatter.format( pageStart )
+ "-"
+ formatter.format( endIndex )
+ ( exact ? " of " : " of over " )
+ formatter.format( dataSize );
}
示例6: myGetUnitText
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
static String myGetUnitText(double v, String u, boolean sf) {
NumberFormat s;
String sp = "";
if (sf)
s=shortFormat;
else {
s=showFormat;
sp = " ";
}
double va = Math.abs(v);
if (va < 1e-14)
// this used to return null, but then wires would display "null" with 0V
return "0" + sp + u;
if (va < 1e-9)
return s.format(v*1e12) + sp + "p" + u;
if (va < 1e-6)
return s.format(v*1e9) + sp + "n" + u;
if (va < 1e-3)
return s.format(v*1e6) + sp + CirSim.muString + u;
if (va < 1)
return s.format(v*1e3) + sp + "m" + u;
if (va < 1e3)
return s.format(v) + sp + u;
if (va < 1e6)
return s.format(v*1e-3) + sp + "k" + u;
if (va < 1e9)
return s.format(v*1e-6) + sp + "M" + u;
return s.format(v*1e-9) + sp + "G" + u;
}
示例7: updateTable
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
/**
* Update a single row in the stock table.
*
* @param price Stock data for a single row.
*/
private void updateTable(StockPrice price) {
// Make sure the stock is still in the stock table.
if (!stocks.contains(price.getSymbol())) {
return;
}
int row = stocks.indexOf(price.getSymbol()) + 1;
// Format the data in the Price and Change fields.
String priceText = NumberFormat.getFormat("#,##0.00").format(
price.getPrice());
NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
String changeText = changeFormat.format(price.getChange());
String changePercentText = changeFormat.format(price.getChangePercent());
// Populate the Price and Change fields with new data.
stocksFlexTable.setText(row, 1, priceText);
Label changeWidget = (Label)stocksFlexTable.getWidget(row, 2);
changeWidget.setText(changeText + " (" + changePercentText + "%)");
// Change the color of text in the Change field based on its value.
String changeStyleName = "noChange";
if (price.getChangePercent() < -0.1f) {
changeStyleName = "negativeChange";
}
else if (price.getChangePercent() > 0.1f) {
changeStyleName = "positiveChange";
}
changeWidget.setStyleName(changeStyleName);
}
示例8: updateToActive
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
private void updateToActive() {
ActiveTarget at = ActiveTarget.getInstance();
_targetPanel.setTarget(at.getActive());
if (_currSearchMethod == null) return;
NumberFormat formatter = NumberFormat.getFormat("#.000000");
String ra, dec;
SearchMethods method = _methods.get(_currSearchMethod);
if (_searchMethod.getValue().equals(POLYGON) && at.getImageCorners() != null) {
WorldPt[] wpts = at.getImageCorners();
StringBuffer wptsString = new StringBuffer();
if (wpts.length > 0) {
ra = formatter.format(wpts[0].getLon());
dec = formatter.format(wpts[0].getLat());
wptsString.append(ra + " " + dec);
for (int i = 1; i < wpts.length; i++) {
ra = formatter.format(wpts[i].getLon());
dec = formatter.format(wpts[i].getLat());
wptsString.append(", " + ra + " " + dec);
}
}
((SearchMethods.Polygon) method).getField().setValue(new String(wptsString));
}
}
示例9: makeMessage
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public static String makeMessage(PlotState.RotateType rotateType, double angle) {
final NumberFormat nf = NumberFormat.getFormat("#.#");
String retval;
switch (rotateType) {
case NORTH: retval= "Rotating North...";
break;
case ANGLE: retval= "Rotating to " + nf.format(angle) + " degrees ...";
break;
case UNROTATE: retval= "Returning to original rotation...";
break;
default: retval= "undefined";
break;
}
return retval;
}
示例10: getXMinMaxDescHTML
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
private String getXMinMaxDescHTML(MinMax xMinMax) {
String desc = "Remove out-of-bound points by defining a new X range.<br>";
if (xMinMax != null) {
NumberFormat nf_x = NumberFormat.getFormat(MinMax.getFormatString(xMinMax, 3));
desc += "Dataset min X: "+nf_x.format(xMinMax.getMin())+", max X: "+nf_x.format(xMinMax.getMax());
}
return desc;
}
示例11: getYMinMaxDescHTML
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
private String getYMinMaxDescHTML(MinMax yMinMax) {
String desc = "Remove out-of-bound points by defining a new Y range.<br>";
if (yMinMax != null) {
NumberFormat nf_y = NumberFormat.getFormat(MinMax.getFormatString(yMinMax, 3));
desc += "Dataset min Y: "+nf_y.format(yMinMax.getMin())+", max Y: "+nf_y.format(yMinMax.getMax());
}
return desc;
}
示例12: createText
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
/**
* Get the text to display in the pager that reflects the state of the pager.
*
* @return the text
*/
protected String createText () {
// Default text is 1 based.
NumberFormat formatter = NumberFormat.getFormat("#,###");
HasRows display = getDisplay();
Range range = display.getVisibleRange();
int pageStart = range.getStart() + 1;
int pageSize = range.getLength();
int dataSize = display.getRowCount();
int endIndex = Math.min(dataSize, pageStart + pageSize - 1);
endIndex = Math.max(pageStart, endIndex);
boolean exact = display.isRowCountExact();
return formatter.format(pageStart) + "-" + formatter.format(endIndex)
+ (exact ? " of " : " of over ") + formatter.format(dataSize);
}
示例13: createText
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
protected String createText() {
NumberFormat formatter = NumberFormat.getFormat("#,###");
HasRows display = getDisplay();
Range range = display.getVisibleRange();
int pageStart = range.getStart() + 1;
int pageSize = range.getLength();
int dataSize = display.getRowCount();
int endIndex = Math.min(dataSize,
pageStart
+ pageSize
- 1);
endIndex = Math.max(pageStart,
endIndex);
boolean exact = display.isRowCountExact();
if (dataSize == 0) {
return "0 " + of() + " 0";
} else if (pageStart == endIndex) {
return formatter.format(pageStart)
+ " " + of() + " "
+ formatter.format(dataSize);
}
return formatter.format(pageStart)
+ "-"
+ formatter.format(endIndex)
+ (exact ? " " + of() + " " : " " + of() + " " + over() + " ")
+ formatter.format(dataSize);
}
示例14: showDownloads
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public void showDownloads(List<DownloadStatus> status) {
String paths[] = new String[status.size()];
String progress[] = new String[status.size()];
for (int i = 0; i < paths.length; i++) {
DownloadStatus s = status.get(i);
paths[i] = s.getPath();
NumberFormat format = NumberFormat.getPercentFormat();
progress[i] = format.format(s.getProgress());
}
view.showDownloads(paths, progress);
}
示例15: formatIndicatorValue
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
/**
* Format the value <code>property</code> of the given indicator.
*
* @param indicator Indicator to use.
* @param property The property to retrieve.
*
* @return The value formatted according to the aggregation mode of the given indicator.
*/
private String formatIndicatorValue(final IndicatorDTO indicator, String property) {
final Double value = indicator.get(property);
if(value == null) {
return "";
}
final NumberFormat numberFormat = IndicatorNumberFormats.getNumberFormat(indicator);
return numberFormat.format(value);
}