本文整理汇总了Java中com.google.gwt.i18n.client.NumberFormat.getFormat方法的典型用法代码示例。如果您正苦于以下问题:Java NumberFormat.getFormat方法的具体用法?Java NumberFormat.getFormat怎么用?Java NumberFormat.getFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.i18n.client.NumberFormat
的用法示例。
在下文中一共展示了NumberFormat.getFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumberFormat
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
private NumberFormat getNumberFormat() {
NumberFormat nf;
if (sciNote) {
nf= NumberFormat.getScientificFormat();
}
else {
StringBuffer sb= new StringBuffer(9);
if (precision==0) {
nf= NumberFormat.getFormat("#");
}
else {
sb.append("#.");
for(int i= 0; (i<precision); i++) sb.append("#");
nf= NumberFormat.getFormat(sb.toString());
}
}
return nf;
}
示例2: setValue
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public void setValue(T value) {
this.value = value;
double val = 0;
if (value == null) {
val = this.min;
} else {
val = value.doubleValue();
}
if (val > this.max) {
val = this.max;
} else if (val < this.min) {
val = this.min;
}
this.progressBarElement.setAttribute(OutputProgressBar.ATT_ARIA_VALUE, value + "");
double percent = 100 * (val - this.min) / (this.max - this.min);
this.progressBarElement.getStyle().setProperty("width", percent, Unit.PCT);
NumberFormat formatter = NumberFormat.getFormat("#.##");
String stringToDisplay = this.format;
stringToDisplay = RegExp.compile("\\{0\\}").replace(stringToDisplay, formatter.format(val));
stringToDisplay = RegExp.compile("\\{1\\}").replace(stringToDisplay, formatter.format(percent));
stringToDisplay = RegExp.compile("\\{2\\}").replace(stringToDisplay, formatter.format(this.min));
stringToDisplay = RegExp.compile("\\{3\\}").replace(stringToDisplay, formatter.format(this.max));
this.progressBarElement.removeAllChildren();
if (this.displayValue) {
this.progressBarElement.setInnerText(stringToDisplay);
} else {
SpanElement reader = Document.get().createSpanElement();
reader.setInnerText(stringToDisplay);
reader.addClassName("sr-only");
this.progressBarElement.appendChild(reader);
}
}
示例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: 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);
}
示例7: 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));
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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);
}
示例12: 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);
}
示例13: getNumberFormat
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
protected NumberFormat getNumberFormat(String pattern) {
if (StringUtils.isBlank(pattern)) {
return getNumberFormat(ColumnSettings.NUMBER_PATTERN);
}
NumberFormat format = numberPatternMap.get(pattern);
if (format == null) {
format = NumberFormat.getFormat(pattern);
numberPatternMap.put(pattern, format);
}
return format;
}
示例14: NumberRenderer
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
public NumberRenderer(String numberFormatPattern, boolean hasFraction) {
numberFormat = NumberFormat.getFormat(numberFormatPattern);
this.hasFraction = hasFraction;
if (!hasFraction) {
numberFormat.overrideFractionDigits(0);
}
}
示例15: scaleToString
import com.google.gwt.i18n.client.NumberFormat; //导入方法依赖的package包/类
/**
* Convert a scale to a string representation.
*
* @param scale scale to convert
* @param precision precision for the scale, or 0
* @param significantDigits maximum number of significant digits
* @return string representation for the scale
*/
public static String scaleToString(double scale, int precision, int significantDigits) {
NumberFormat numberFormat = NumberFormat.getFormat("###,###");
if (scale > 0 && scale < 1.0) {
int denominator = round((int) Math.round(1.0 / scale), precision, significantDigits);
return "1 : " + numberFormat.format(denominator);
} else if (scale >= 1.0) {
int nominator = round((int) Math.round(scale), precision, significantDigits);
return numberFormat.format(nominator) + " : 1";
} else {
return ERROR_SCALE;
}
}