Example usage for java.text NumberFormat getNumberInstance

List of usage examples for java.text NumberFormat getNumberInstance

Introduction

In this page you can find the example usage for java.text NumberFormat getNumberInstance.

Prototype

public static NumberFormat getNumberInstance(Locale inLocale) 

Source Link

Document

Returns a general-purpose number format for the specified locale.

Usage

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a generic Time Bar Chart.// w  w  w  .  j a  v a  2s. c  o m
 *
 * @param title      the title of the Chart.
 * @param valueLabel the X Axis Label.
 * @param data       the data to populate with.
 * @return the generated Chart.
 */
private JFreeChart createTimeBarChart(String title, String color, String valueLabel, XYDataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    DateAxis xAxis = generateTimeAxis();

    NumberAxis yAxis = new NumberAxis(valueLabel);
    NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale());
    formatter.setMaximumFractionDigits(2);
    formatter.setMinimumFractionDigits(0);
    yAxis.setNumberFormatOverride(formatter);
    yAxis.setAutoRangeIncludesZero(true);

    return createChart(title, data, xAxis, yAxis, orientation, new XYBarRenderer(),
            GraphDefinition.getDefinition(color));
}

From source file:name.gumartinm.weather.information.widget.WidgetIntentService.java

private RemoteViews makeView(final Current current, final WeatherLocation weatherLocation,
        final int appWidgetId) {

    // 1. Update units of measurement.

    UnitsConversor tempUnitsConversor;/*w ww  . j av a 2s.c  om*/
    String keyPreference = this.getApplicationContext()
            .getString(R.string.widget_preferences_temperature_units_key);
    String realKeyPreference = keyPreference + "_" + appWidgetId;
    // What was saved to permanent storage (or default values if it is the first time)
    final int tempValue = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE)
            .getInt(realKeyPreference, 0);
    final String tempSymbol = this.getResources()
            .getStringArray(R.array.weather_preferences_temperature)[tempValue];
    if (tempValue == 0) {
        tempUnitsConversor = new UnitsConversor() {

            @Override
            public double doConversion(final double value) {
                return value - 273.15;
            }

        };
    } else if (tempValue == 1) {
        tempUnitsConversor = new UnitsConversor() {

            @Override
            public double doConversion(final double value) {
                return (value * 1.8) - 459.67;
            }

        };
    } else {
        tempUnitsConversor = new UnitsConversor() {

            @Override
            public double doConversion(final double value) {
                return value;
            }

        };
    }

    // 2. Update country.
    keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_country_switch_key);
    realKeyPreference = keyPreference + "_" + appWidgetId;
    // What was saved to permanent storage (or default values if it is the first time)
    final boolean isCountry = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE)
            .getBoolean(realKeyPreference, false);

    // 3. Formatters
    final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
    tempFormatter.applyPattern("###.##");

    // 4. Prepare data for RemoteViews.
    String tempMax = "";
    if (current.getMain().getTemp_max() != null) {
        double conversion = (Double) current.getMain().getTemp_max();
        conversion = tempUnitsConversor.doConversion(conversion);
        tempMax = tempFormatter.format(conversion) + tempSymbol;
    }
    String tempMin = "";
    if (current.getMain().getTemp_min() != null) {
        double conversion = (Double) current.getMain().getTemp_min();
        conversion = tempUnitsConversor.doConversion(conversion);
        tempMin = tempFormatter.format(conversion) + tempSymbol;
    }
    Bitmap picture;
    if ((current.getWeather().size() > 0) && (current.getWeather().get(0).getIcon() != null)
            && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) {
        final String icon = current.getWeather().get(0).getIcon();
        picture = BitmapFactory.decodeResource(this.getResources(),
                IconsList.getIcon(icon).getResourceDrawable());
    } else {
        picture = BitmapFactory.decodeResource(this.getResources(), R.drawable.weather_severe_alert);
    }
    final String city = weatherLocation.getCity();
    final String country = weatherLocation.getCountry();

    // 5. Insert data in RemoteViews.
    final RemoteViews remoteView = new RemoteViews(this.getApplicationContext().getPackageName(),
            R.layout.appwidget);
    remoteView.setImageViewBitmap(R.id.weather_appwidget_image, picture);
    remoteView.setTextViewText(R.id.weather_appwidget_temperature_max, tempMax);
    remoteView.setTextViewText(R.id.weather_appwidget_temperature_min, tempMin);
    remoteView.setTextViewText(R.id.weather_appwidget_city, city);
    if (!isCountry) {
        remoteView.setViewVisibility(R.id.weather_appwidget_country, View.GONE);
    } else {
        // TODO: It is as if Android had a view cache. If I did not set VISIBLE value,
        // the country field would be gone forever... :/
        remoteView.setViewVisibility(R.id.weather_appwidget_country, View.VISIBLE);
        remoteView.setTextViewText(R.id.weather_appwidget_country, country);
    }

    // 6. Activity launcher.
    final Intent resultIntent = new Intent(this.getApplicationContext(), WidgetConfigure.class);
    resultIntent.putExtra("actionFromUser", true);
    resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    // From: http://stackoverflow.com/questions/4011178/multiple-instances-of-widget-only-updating-last-widget
    final Uri data = Uri.withAppendedPath(Uri.parse("PAIN" + "://widget/id/"), String.valueOf(appWidgetId));
    resultIntent.setData(data);

    final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this.getApplicationContext());
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(WidgetConfigure.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);
    remoteView.setOnClickPendingIntent(R.id.weather_appwidget, resultPendingIntent);

    return remoteView;
}

From source file:org.jumpmind.db.platform.AbstractDdlBuilder.java

/**
 * Sets the locale that is used for number and date formatting (when
 * printing default values and in generates insert/update/delete
 * statements).//from  w  w w .  j a va2 s  . c om
 *
 * @param localeStr
 *            The new locale or <code>null</code> if default formatting
 *            should be used; Format is "language[_country[_variant]]"
 */
public void setValueLocale(String localeStr) {
    if (localeStr != null) {
        int sepPos = localeStr.indexOf('_');
        String language = null;
        String country = null;
        String variant = null;

        if (sepPos > 0) {
            language = localeStr.substring(0, sepPos);
            country = localeStr.substring(sepPos + 1);
            sepPos = country.indexOf('_');
            if (sepPos > 0) {
                variant = country.substring(sepPos + 1);
                country = country.substring(0, sepPos);
            }
        } else {
            language = localeStr;
        }
        if (language != null) {
            Locale locale = null;

            if (variant != null) {
                locale = new Locale(language, country, variant);
            } else if (country != null) {
                locale = new Locale(language, country);
            } else {
                locale = new Locale(language);
            }

            valueLocale = localeStr;
            setValueDateFormat(DateFormat.getDateInstance(DateFormat.SHORT, locale));
            setValueTimeFormat(DateFormat.getTimeInstance(DateFormat.SHORT, locale));
            setValueNumberFormat(NumberFormat.getNumberInstance(locale));
            return;
        }
    }
    valueLocale = null;
    setValueDateFormat(null);
    setValueTimeFormat(null);
    setValueNumberFormat(null);
}

From source file:com.ibm.mil.readyapps.physio.fragments.ProgressFragment.java

private void gatherDetailedData(List<Integer> data, String route, StringBuilder builder) {
    Locale locale = getResources().getConfiguration().locale;
    NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);

    // set performance
    String performance = numberFormat.format(data.get(data.size() - 1));
    builder.append("scope.setPerformance('");
    builder.append(performance);//from w  w w.j ava  2  s. c  o  m
    builder.append("');");

    // set time frame
    String format;
    String unit;
    String timeSpan = route.split("_")[2];
    switch (timeSpan) {
    case "day":
        format = "MMMM d - ha";
        unit = "Today";
        break;
    case "week":
        format = "MMMM d";
        unit = "Today";
        break;
    case "month":
        format = "MMM d";
        unit = "This Week";
        break;
    default:
        format = "MMMM yyyy";
        unit = "This Month";
        break;
    }

    SimpleDateFormat dateFormat = new SimpleDateFormat(format, locale);
    String timeFrame = dateFormat.format(new Date());

    // add additional time frame text for month
    if (timeSpan.equals("month")) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.WEEK_OF_YEAR, -1);
        dateFormat.applyLocalizedPattern("MMMM d");
        timeFrame = dateFormat.format(calendar.getTime()) + " - " + timeFrame;
    }

    builder.append("scope.setTimeFrame('");
    builder.append(timeFrame);
    builder.append("');");

    builder.append("scope.setUnit('");
    builder.append(unit);
    builder.append("');");

    // set optional goal
    if (route.contains("steps") || route.contains("calories")) {
        String goal;
        if (route.contains("steps")) {
            goal = numberFormat.format(DataManager.getCurrentPatient().getStepGoal());
        } else {
            goal = numberFormat.format(DataManager.getCurrentPatient().getCalorieGoal());
        }

        builder.append("scope.setGoal('");
        builder.append(goal);
        builder.append("');");
    }
}

From source file:org.apache.empire.struts2.jsp.controls.TextInputControl.java

protected NumberFormat getNumberFormat(DataType dataType, Locale locale, Column column) {
    if (column == null)
        return NumberFormat.getNumberInstance(locale);
    // Column is supplied
    String type = StringUtils.valueOf(column.getAttribute(InputControl.NUMBER_FORMAT_ATTRIBUTE));
    NumberFormat nf = null;/*from   w w  w  .  ja va 2s . c  om*/
    if (type.equalsIgnoreCase("Integer"))
        nf = NumberFormat.getIntegerInstance(locale);
    /*
    else if (type.equalsIgnoreCase("Currency"))
    {   // nf = NumberFormat.getCurrencyInstance(locale);
    // Currency does not work as desired!
    nf = NumberFormat.getNumberInstance(locale);
    }
    else if (type.equalsIgnoreCase("Percent"))
    nf = NumberFormat.getPercentInstance(locale);
    */
    else
        nf = NumberFormat.getNumberInstance(locale);
    // Groups Separator?
    Object groupSep = column.getAttribute(InputControl.NUMBER_GROUPSEP_ATTRIBUTE);
    if (groupSep != null)
        nf.setGroupingUsed(ObjectUtils.getBoolean(groupSep));
    // Fraction Digits?
    Object fractDigit = column.getAttribute(InputControl.NUMBER_FRACTION_DIGITS);
    if (fractDigit != null) {
        int fractionDigits = ObjectUtils.getInteger(fractDigit);
        nf.setMaximumFractionDigits(fractionDigits);
        nf.setMinimumFractionDigits(fractionDigits);
    }
    // Number format
    return nf;
}

From source file:com.intuit.karate.cucumber.KarateJunitFormatter.java

private String formatTime(double time) {
    DecimalFormat nfmt = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
    nfmt.applyPattern("0.######");
    return nfmt.format(time);
}

From source file:name.gumartinm.weather.information.fragment.current.CurrentFragment.java

private void updateUI(final Current current) {
    // 1. Update units of measurement.
    final UnitsConversor tempUnitsConversor = new TempUnitsConversor(
            this.getActivity().getApplicationContext());
    final UnitsConversor windConversor = new WindUnitsConversor(this.getActivity().getApplicationContext());
    final UnitsConversor pressureConversor = new PressureUnitsConversor(
            this.getActivity().getApplicationContext());

    // 2. Formatters
    final DecimalFormat numberFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
    numberFormatter.applyPattern("###.##");
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.US);

    // 3. Prepare data for UI.
    String tempMax = "";
    if (current.getMain().getTemp_max() != null) {
        double conversion = (Double) current.getMain().getTemp_max();
        conversion = tempUnitsConversor.doConversion(conversion);
        tempMax = numberFormatter.format(conversion) + tempUnitsConversor.getSymbol();
    }/*from  w w w.  j a v a  2  s.  co  m*/
    String tempMin = "";
    if (current.getMain().getTemp_min() != null) {
        double conversion = (Double) current.getMain().getTemp_min();
        conversion = tempUnitsConversor.doConversion(conversion);
        tempMin = numberFormatter.format(conversion) + tempUnitsConversor.getSymbol();
    }
    Bitmap picture;
    if ((current.getWeather().size() > 0) && (current.getWeather().get(0).getIcon() != null)
            && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) {
        final String icon = current.getWeather().get(0).getIcon();
        picture = BitmapFactory.decodeResource(this.getResources(),
                IconsList.getIcon(icon).getResourceDrawable());
    } else {
        picture = BitmapFactory.decodeResource(this.getResources(), R.drawable.weather_severe_alert);
    }

    String description = this.getString(R.string.text_field_description_when_error);
    if (current.getWeather().size() > 0) {
        description = current.getWeather().get(0).getDescription();
    }

    String humidityValue = "";
    if ((current.getMain() != null) && (current.getMain().getHumidity() != null)) {
        final double conversion = (Double) current.getMain().getHumidity();
        humidityValue = numberFormatter.format(conversion);
    }
    String pressureValue = "";
    if ((current.getMain() != null) && (current.getMain().getPressure() != null)) {
        double conversion = (Double) current.getMain().getPressure();
        conversion = pressureConversor.doConversion(conversion);
        pressureValue = numberFormatter.format(conversion);
    }
    String windValue = "";
    if ((current.getWind() != null) && (current.getWind().getSpeed() != null)) {
        double conversion = (Double) current.getWind().getSpeed();
        conversion = windConversor.doConversion(conversion);
        windValue = numberFormatter.format(conversion);
    }
    String rainValue = "";
    if ((current.getRain() != null) && (current.getRain().get3h() != null)) {
        final double conversion = (Double) current.getRain().get3h();
        rainValue = numberFormatter.format(conversion);
    }
    String cloudsValue = "";
    if ((current.getClouds() != null) && (current.getClouds().getAll() != null)) {
        final double conversion = (Double) current.getClouds().getAll();
        cloudsValue = numberFormatter.format(conversion);
    }
    String snowValue = "";
    if ((current.getSnow() != null) && (current.getSnow().get3h() != null)) {
        final double conversion = (Double) current.getSnow().get3h();
        snowValue = numberFormatter.format(conversion);
    }
    String feelsLike = "";
    if (current.getMain().getTemp() != null) {
        double conversion = (Double) current.getMain().getTemp();
        conversion = tempUnitsConversor.doConversion(conversion);
        feelsLike = numberFormatter.format(conversion);
    }
    String sunRiseTime = "";
    if (current.getSys().getSunrise() != null) {
        final long unixTime = (Long) current.getSys().getSunrise();
        final Date unixDate = new Date(unixTime * 1000L);
        sunRiseTime = dateFormat.format(unixDate);
    }
    String sunSetTime = "";
    if (current.getSys().getSunset() != null) {
        final long unixTime = (Long) current.getSys().getSunset();
        final Date unixDate = new Date(unixTime * 1000L);
        sunSetTime = dateFormat.format(unixDate);
    }

    // 4. Update UI.
    final TextView tempMaxView = (TextView) getActivity().findViewById(R.id.weather_current_temp_max);
    tempMaxView.setText(tempMax);
    final TextView tempMinView = (TextView) getActivity().findViewById(R.id.weather_current_temp_min);
    tempMinView.setText(tempMin);
    final ImageView pictureView = (ImageView) getActivity().findViewById(R.id.weather_current_picture);
    pictureView.setImageBitmap(picture);

    final TextView descriptionView = (TextView) getActivity().findViewById(R.id.weather_current_description);
    descriptionView.setText(description);

    ((TextView) getActivity().findViewById(R.id.weather_current_humidity_value)).setText(humidityValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_humidity_units))
            .setText(this.getActivity().getApplicationContext().getString(R.string.text_units_percent));

    ((TextView) getActivity().findViewById(R.id.weather_current_pressure_value)).setText(pressureValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_pressure_units))
            .setText(pressureConversor.getSymbol());

    ((TextView) getActivity().findViewById(R.id.weather_current_wind_value)).setText(windValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_wind_units)).setText(windConversor.getSymbol());

    ((TextView) getActivity().findViewById(R.id.weather_current_rain_value)).setText(rainValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_rain_units))
            .setText(this.getActivity().getApplicationContext().getString(R.string.text_units_mm3h));

    ((TextView) getActivity().findViewById(R.id.weather_current_clouds_value)).setText(cloudsValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_clouds_units))
            .setText(this.getActivity().getApplicationContext().getString(R.string.text_units_percent));

    ((TextView) getActivity().findViewById(R.id.weather_current_snow_value)).setText(snowValue);
    ((TextView) getActivity().findViewById(R.id.weather_current_snow_units))
            .setText(this.getActivity().getApplicationContext().getString(R.string.text_units_mm3h));

    ((TextView) getActivity().findViewById(R.id.weather_current_feelslike_value)).setText(feelsLike);
    ((TextView) getActivity().findViewById(R.id.weather_current_feelslike_units))
            .setText(tempUnitsConversor.getSymbol());

    ((TextView) getActivity().findViewById(R.id.weather_current_sunrise_value)).setText(sunRiseTime);

    ((TextView) getActivity().findViewById(R.id.weather_current_sunset_value)).setText(sunSetTime);

    this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.VISIBLE);
    this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.GONE);
    this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
}

From source file:at.asitplus.regkassen.core.base.util.CashBoxUtils.java

/**
 * get double value from arbitrary String represent a double (0,00) or (0.00)
 *
 * @param taxSetValue double value as String
 * @return double value/*from  w  w  w. j a  v a2s  . co m*/
 * @throws Exception
 */
public static double getDoubleFromTaxSet(String taxSetValue) throws Exception {
    //try format ("0,00")
    NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
    DecimalFormat decimalFormat = (DecimalFormat) nf;
    Exception parseException;
    try {
        return decimalFormat.parse(taxSetValue).doubleValue();
    } catch (ParseException ignored) {
    }
    //if Austrian/German format fail, try US format (0.00)
    nf = NumberFormat.getNumberInstance(Locale.US);
    decimalFormat = (DecimalFormat) nf;
    try {
        return decimalFormat.parse(taxSetValue).doubleValue();
    } catch (ParseException e) {
        parseException = e;
    }
    throw parseException;
}

From source file:de.xwic.appkit.webbase.table.DefaultColumnLabelProvider.java

private String toString(Object value) {
    String text;/*from  w ww .j  av a 2  s .c o  m*/

    if (value == null) {
        text = "";
    } else if (value instanceof Date) {
        // special treatment for date objects
        text = dateFormatter.format((Date) value);
    } else if (value instanceof Calendar) {
        Calendar c = (Calendar) value;
        text = dateFormatter.format(c.getTime());
    } else if (value instanceof Long) {
        NumberFormat nf = NumberFormat.getNumberInstance(locale);
        text = nf.format(((Long) value).longValue());
    } else if (value instanceof Double) {
        NumberFormat nf = NumberFormat.getNumberInstance(locale);
        nf.setMinimumFractionDigits(2);
        nf.setMaximumFractionDigits(2);
        text = nf.format(((Double) value).doubleValue());
    } else if (propertyEditor != null) {
        propertyEditor.setValue(value);
        text = propertyEditor.getAsText();
    } else if (value instanceof IPicklistEntry) {
        text = ((IPicklistEntry) value).getBezeichnung(locale.getLanguage());
    } else if (value instanceof IEntity) {
        IEntity entity = (IEntity) value;
        DAO<?> dao = DAOSystem.findDAOforEntity(entity.type());
        text = dao.buildTitle(entity);
    } else if (value instanceof Collection<?>) {
        // set of picklist entries
        StringBuffer sb = new StringBuffer();
        for (Iterator<?> it = ((Collection<?>) value).iterator(); it.hasNext();) {
            Object o = it.next();
            if (sb.length() != 0) {
                sb.append(",");
            }
            sb.append(toString(o));
        }
        text = sb.toString();
    } else if (value instanceof Object[]) {
        StringBuffer sb = new StringBuffer();
        Object[] values = (Object[]) value;
        for (int i = 0; i < values.length; i++) {
            if (sb.length() != 0) {
                sb.append(",");
            }
            sb.append(toString(values[i]));
        }
        text = sb.toString();
    } else {
        text = value.toString();
    }
    return text;

}

From source file:org.jboss.dashboard.displayer.chart.MeterChartDisplayerXMLFormat.java

protected void formatDisplayer(DataDisplayer displayer, PrintWriter out, int indent) throws Exception {
    super.formatDisplayer(displayer, out, indent);

    Locale locale = LocaleManager.currentLocale();
    NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
    MeterChartDisplayer meterDisplayer = (MeterChartDisplayer) displayer;
    if (meterDisplayer.getType().equals("meter")) {
        printIndent(out, indent++);/*  w  w  w . j ava 2 s. c o m*/
        out.println("<meter>");
        // Meter properties.
        // Position type
        printIndent(out, indent);
        out.print("<positionType>");
        out.print(StringEscapeUtils.escapeXml(meterDisplayer.getPositionType()));
        out.println("</positionType>");
        // Min value
        printIndent(out, indent);
        out.print("<minValue>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getMinValue())));
        out.println("</minValue>");
        // Thresholds.
        printIndent(out, indent);
        out.print("<warningThreshold>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getWarningThreshold())));
        out.println("</warningThreshold>");
        printIndent(out, indent);
        out.print("<criticalThreshold>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getCriticalThreshold())));
        out.println("</criticalThreshold>");
        // Normal interval
        // Interval descriptions. Hide them until the global legend will be available.
        /*
        Map descripNormalInterval = meterDisplayer.getDescripNormalIntervalI18nMap();
        Iterator descripNormalIntervalKeys = descripNormalInterval.keySet().iterator();
        while (descripNormalIntervalKeys.hasNext()) {
            Locale l = (Locale) descripNormalIntervalKeys.next();
            printIndent(out, indent);
            out.print("<descripNormalInterval language");
            out.print("=\"" + StringEscapeUtils.escapeXml(l.toString()) + "\">");
            out.print(StringEscapeUtils.escapeXml((String) descripNormalInterval.get(l)));
            out.println("</descripNormalInterval>");
        }
        */
        // Warning interval.
        // Interval descriptions. Hide them until the global legend will be available.
        /*
        Map descripWarningInterval = meterDisplayer.getDescripWarningIntervalI18nMap();
        Iterator descripWarningIntervalKeys = descripWarningInterval.keySet().iterator();
        while (descripWarningIntervalKeys.hasNext()) {
            Locale l = (Locale) descripWarningIntervalKeys.next();
            printIndent(out, indent);
            out.print("<descripWarningInterval language");
            out.print("=\"" + StringEscapeUtils.escapeXml(l.toString()) + "\">");
            out.print(StringEscapeUtils.escapeXml((String) descripWarningInterval.get(l)));
            out.println("</descripWarningInterval>");
        }
        */
        // Critical interval.
        // Interval descriptions. Hide them until the global legend will be available.
        /*
        Map descripCriticalInterval = meterDisplayer.getDescripCriticalIntervalI18nMap();
        Iterator descripCriticalIntervalKeys = descripCriticalInterval.keySet().iterator();
        while (descripCriticalIntervalKeys.hasNext()) {
            Locale l = (Locale) descripCriticalIntervalKeys.next();
            printIndent(out, indent);
            out.print("<descripCriticalInterval language");
            out.print("=\"" + StringEscapeUtils.escapeXml(l.toString()) + "\">");
            out.print(StringEscapeUtils.escapeXml((String) descripCriticalInterval.get(l)));
            out.println("</descripCriticalInterval>");
        }
        */
        // Max value
        printIndent(out, indent);
        out.print("<maxValue>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getMaxValue())));
        out.println("</maxValue>");
        // Maximum number of ticks.
        printIndent(out, indent);
        out.print("<maxMeterTicks>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getMaxMeterTicks())));
        out.println("</maxMeterTicks>");
        printIndent(out, --indent);
        out.println("</meter>");
    } else if (meterDisplayer.getType().equals("thermometer")) {
        printIndent(out, indent++);
        out.println("<thermometer>");

        // Position type
        printIndent(out, indent);
        out.print("<positionType>");
        out.print(StringEscapeUtils.escapeXml(meterDisplayer.getPositionType()));
        out.println("</positionType>");
        // Lower bound
        printIndent(out, indent);
        out.print("<thermoLowerBound>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getThermoLowerBound())));
        out.println("</thermoLowerBound>");
        // Thresholds.
        printIndent(out, indent);
        out.print("<warningThermoThreshold>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getWarningThermoThreshold())));
        out.println("</warningThermoThreshold>");
        printIndent(out, indent);
        out.print("<criticalThermoThreshold>");
        out.print(
                StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getCriticalThermoThreshold())));
        out.println("</criticalThermoThreshold>");
        // Upper bound
        printIndent(out, indent);
        out.print("<thermoUpperBound>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getThermoUpperBound())));
        out.println("</thermoUpperBound>");
        printIndent(out, --indent);
        out.println("</thermometer>");
    } else if (meterDisplayer.getType().equals("dial")) {
        printIndent(out, indent++);
        out.println("<dial>");
        // Position type
        printIndent(out, indent);
        out.print("<positionType>");
        out.print(StringEscapeUtils.escapeXml(meterDisplayer.getPositionType()));
        out.println("</positionType>");
        // Pointer type.
        printIndent(out, indent);
        out.print("<pointerType>");
        out.print(StringEscapeUtils.escapeXml(meterDisplayer.getPointerType()));
        out.println("</pointerType>");
        // Lower bound.
        printIndent(out, indent);
        out.print("<dialLowerBound>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getDialLowerBound())));
        out.println("</dialLowerBound>");
        // Upper bound.
        printIndent(out, indent);
        out.print("<dialUpperBound>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getDialUpperBound())));
        out.println("</dialUpperBound>");
        // Max ticks.
        printIndent(out, indent);
        out.print("<maxTicks>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getMaxTicks())));
        out.println("</maxTicks>");
        // Minor tick count.
        printIndent(out, indent);
        out.print("<minorTickCount>");
        out.print(StringEscapeUtils.escapeXml(numberFormat.format(meterDisplayer.getMinorTickCount())));
        out.println("</minorTickCount>");
        printIndent(out, --indent);
        out.println("</dial>");
    }
}