Example usage for com.google.gwt.i18n.client NumberFormat getFormat

List of usage examples for com.google.gwt.i18n.client NumberFormat getFormat

Introduction

In this page you can find the example usage for com.google.gwt.i18n.client NumberFormat getFormat.

Prototype

public static NumberFormat getFormat(String pattern) 

Source Link

Document

Gets a NumberFormat instance for the default locale using the specified pattern and the default currencyCode.

Usage

From source file:org.mklab.taskit.client.ui.RecordView.java

License:Apache License

/**
 * ????//from   ww w.  j  a v  a  2  s .  c o  m
 * 
 * @param record ?
 */
@SuppressWarnings("nls")
public void setRecord(RecordProxy record) {
    final double percentOfAverage = record.getStatistics().getAverage()
            / record.getStatistics().getMaximumScore() * 100;

    final NumberFormat fmt = NumberFormat.getFormat("00.00");
    this.rank.setText(
            String.valueOf(record.getRank()) + "/" + String.valueOf(record.getStatistics().getStudentCount()));
    this.achievementRatio
            .setText(fmt.format(record.getScore() / record.getStatistics().getMaximumScore() * 100) + "%");
    this.deviation.setText(fmt.format(record.getDeviation()));
    this.average.setText(fmt.format(percentOfAverage) + "%");
    this.standardDeviation.setText(fmt.format(record.getStatistics().getStandardDeviation()));
}

From source file:org.obiba.opal.web.gwt.app.client.magma.variable.view.ContingencyTableView.java

License:Open Source License

private String formatDecimal(double number) {
    NumberFormat nf = NumberFormat.getFormat("#.##");
    return nf.format(number);
}

From source file:org.obiba.opal.web.gwt.app.client.magma.view.ContinuousSummaryView.java

License:Open Source License

private void addGridStat(String title, double number, int row) {
    NumberFormat nf = NumberFormat.getFormat("#.####");

    grid.setWidget(row, 0, new Label(title));
    grid.setWidget(row, 1, new Label(String.valueOf(nf.format(number))));
}

From source file:org.obiba.opal.web.gwt.app.client.magma.view.GeoSummaryView.java

License:Open Source License

private void addDescriptiveStatistics() {
    grid.clear();/*from ww  w .  ja  v a  2  s. c  o m*/
    grid.setHeader(0, translations.descriptiveStatistics());
    grid.setHeader(1, translations.value());

    int row = 0;
    NumberFormat nf = NumberFormat.getFormat("#.##");

    grid.setWidget(row, 0, new Label(translations.approxArea()));
    grid.setWidget(row++, 1, new Label(String.valueOf(nf.format(map.getApproxArea()))));
}

From source file:org.openelis.modules.scriptlet.client.cf.ScriptletProxy.java

License:Open Source License

@Override
public String format(Double risk, String pattern) {
    if (risk == null)
        return null;

    if (formatter == null)
        formatter = NumberFormat.getFormat(pattern);

    return formatter.format(risk);
}

From source file:org.openelis.modules.scriptlet.client.ms.ScriptletProxy.java

License:Open Source License

@Override
public String format(Double risk, String pattern) {
    if (risk == null)
        return null;
    return NumberFormat.getFormat(pattern).format(risk);
}

From source file:org.openmoney.omlets.mobile.client.payments.PaymentDetailsPage.java

License:Open Source License

/**
 * Renders the form with the given data//from   w  ww. ja  va  2 s  .  co m
 */
private void renderTransferData() {

    Transfer transfer = data.getTransfer();
    ;
    JsArray<CustomFieldValue> customFieldValues = transfer.getCustomValues();

    String loggedName = LoggedUser.get().getInitialData().getProfile().getName();
    String mytransferNameFrom = transfer.getTransferType().getFrom().getName();
    String transferName = transfer.getBasicMember() == null ? transfer.getSystemAccountName()
            : transfer.getBasicMember().getName();

    // Set from and to
    String from = transfer.getAmount() > 0 ? transferName : mytransferNameFrom;
    String to = transfer.getAmount() > 0 ? mytransferNameFrom : transferName;

    Map<String, String> formData = new LinkedHashMap<String, String>();

    // Add transfer properties
    formData.put(messages.date(), transfer.getFormattedProcessDate());
    formData.put(messages.paymentNumber(), transfer.getTransactionNumber());
    formData.put(messages.from(), from);
    formData.put(messages.to(), to);
    //formData.put(messages.type(), transfer.getTransferType().getName());
    NumberFormat numberFormat = NumberFormat.getFormat("###,###,###.00;-###,###,###.00");
    formData.put(messages.amount(), numberFormat.format(Double.parseDouble(transfer.getAmount().toString())));
    formData.put("Currency", transfer.getTransferType().getFrom().getCurrency().getName());
    formData.put(messages.description(), transfer.getDescription());

    // Add custom fields
    if (customFieldValues != null && customFieldValues.length() > 0) {
        for (int i = 0; i < customFieldValues.length(); i++) {
            CustomFieldValue value = customFieldValues.get(i);
            formData.put(value.getDisplayName(), value.getValue());
        }
    }
    form.setData(formData);

    List<PageAction> actions = new ArrayList<PageAction>();

    // Add contact action if related member is not a contact yet
    if (data.isCanAddContact()) {
        // actions.add(getAddToContactsAction());
    }

    // Add payment action if contact can make member/system payments
    if (transfer.getBasicMember() == null && LoggedUser.get().getInitialData().canMakeSystemPayments()) {
        actions.add(getNewPaymentAction());
    } else if (transfer.getBasicMember() != null && LoggedUser.get().getInitialData().canMakeMemberPayments()) {
        actions.add(getNewPaymentAction());
    }

    // Add actions asynchronously
    OmletsMobile.get().getMainLayout().addActions(actions, true);

    // Display loaded data
    container.setVisible(true);
}

From source file:org.opentaps.gwt.common.client.listviews.CurrencyColumnConfig.java

License:Open Source License

/**
 * The implementation of the <code>Renderer</code> interface that produce the content of the cell.
 * @param value the value of the current record for this cell
 * @param cellMetadata a <code>CellMetadata</code> value
 * @param record the current <code>Record</code> value
 * @param rowIndex the row index of the current record
 * @param colNum the column index of this cell
 * @param store a <code>Store</code> value
 * @return the cell content as an HTML string
 *//*from   ww w .  j  a va2  s .c  om*/
public String render(Object value, CellMetadata cellMetadata, Record record, int rowIndex, int colNum,
        Store store) {
    if (value == null) {
        return "";
    }
    String amount = (String) value;

    NumberFormat fmt = null;
    String currency = currencyCode;
    if (currencyIndex != null) {
        currencyCode = record.getAsString(currencyIndex);
    }
    if (currencyCode == null) {
        fmt = NumberFormat.getCurrencyFormat();
    } else {
        try {
            fmt = NumberFormat.getCurrencyFormat(currencyCode);
        } catch (Exception e) {
            // Note: there is a bug in getCurrencyFormat and it does not work by looking at the properties file
            // but is limited to 4 hard coded currencies
            UtilUi.logWarning(
                    "Cannot set currency format with currency code [" + currencyCode + "] " + e.getMessage(),
                    MODULE, "render");
            // manually build the format and use the currency code as the currency symbol
            // this pattern is the currency pattern but with the currency symbol removed
            fmt = NumberFormat.getFormat("#,##0.00;(#,##0.00)");
            return currencyCode + " " + fmt.format(new BigDecimal(amount).doubleValue());
        }
    }
    return fmt.format(new BigDecimal(amount).doubleValue());
}

From source file:org.pathvisio.wikipathways.client.GeneTooltip.java

License:Apache License

private Panel createDataPanel(GeneInfo geneInfo) {
    Map<String, Set<ExpressionValue>> data = geneInfo.getData();

    List<String> experiments = new ArrayList<String>();
    for (Set<ExpressionValue> evs : data.values()) {
        for (ExpressionValue ev : evs) {
            if (!experiments.contains(ev.getExperiment())) {
                experiments.add(ev.getExperiment());
            }//  w w w  .jav a 2  s.  com
        }
    }
    Collections.sort(experiments);

    Grid grid = new Grid(data.size() + 1, experiments.size() + 1);

    NumberFormat format = NumberFormat.getFormat("0.###E0");

    int row = 0;

    //Create header
    if (data.size() > 0) {
        Label lbl = new Label("Condition");
        lbl.addStyleName(STYLE_DATA_HEADER);
        grid.setWidget(row, 0, lbl);
        for (int i = 0; i < experiments.size(); i++) {
            lbl = new Label(experiments.get(i));
            lbl.addStyleName(STYLE_DATA_HEADER);
            grid.setWidget(row, i + 1, lbl);
        }
        row++;
    }

    for (String factor : data.keySet()) {
        Set<ExpressionValue> values = data.get(factor);
        Label flbl = new Label(factor);
        flbl.addStyleName(STYLE_DATA_FACTOR);

        for (ExpressionValue value : values) {
            int col = 1 + experiments.indexOf(value.getExperiment());
            String valueStr = format.format(value.getPvalue());
            Label vlbl = new Label(valueStr);
            vlbl.addStyleName(STYLE_DATA_VALUE);
            if (value.getSign() > 0) {
                vlbl.addStyleName(STYLE_DATA_VALUE_UP);
            } else {
                vlbl.addStyleName(STYLE_DATA_VALUE_DOWN);
            }
            grid.setWidget(row, col, vlbl);
        }
        grid.setWidget(row++, 0, flbl);
    }
    return grid;
}

From source file:org.pentaho.gwt.widgets.client.formatter.JSNumberTextFormatter.java

License:Open Source License

public JSNumberTextFormatter(final String pattern) {
    formatter = NumberFormat.getFormat(pattern);
    setupNativeFunctions(getInstance());
}