当前位置: 首页>>代码示例>>Java>>正文


Java NumberFormat.format方法代码示例

本文整理汇总了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;
        }
    }
 
开发者ID:languageininteraction,项目名称:LanguageMemoryApp,代码行数:27,代码来源:ScorePageView.java

示例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);
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:16,代码来源:BaseWidget.java

示例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;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:11,代码来源:GeoUtil.java

示例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;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:11,代码来源:GeoUtil.java

示例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 );
}
 
开发者ID:Teiid-Designer,项目名称:teiid-webui,代码行数:28,代码来源:TeiidSimplePager.java

示例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;
   }
 
开发者ID:sharpie7,项目名称:circuitjs1,代码行数:30,代码来源:CircuitElm.java

示例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);
}
 
开发者ID:mcculls,项目名称:osgi-in-action,代码行数:37,代码来源:StockWatcher.java

示例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));
    }

}
 
开发者ID:lsst,项目名称:firefly,代码行数:28,代码来源:CatalogPanel.java

示例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;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:16,代码来源:RotateTask.java

示例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;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:9,代码来源:XYPlotOptionsPanel.java

示例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;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:9,代码来源:XYPlotOptionsPanel.java

示例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);
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:20,代码来源:SimplePager.java

示例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);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:28,代码来源:UberfireSimplePager.java

示例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);
}
 
开发者ID:alexjj,项目名称:encfsanywhere,代码行数:14,代码来源:ListPresenter.java

示例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);
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:20,代码来源:ProjectIndicatorManagementView.java


注:本文中的com.google.gwt.i18n.client.NumberFormat.format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。