Example usage for java.text NumberFormat getMaximumFractionDigits

List of usage examples for java.text NumberFormat getMaximumFractionDigits

Introduction

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

Prototype

public int getMaximumFractionDigits() 

Source Link

Document

Returns the maximum number of digits allowed in the fraction portion of a number.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getIntegerInstance();
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getNumberInstance();
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getPercentInstance();
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.CANADA);
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.CANADA);
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getIntegerInstance(Locale.CANADA);
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getPercentInstance(Locale.CANADA);
    System.out.println(numberFormat.getMaximumFractionDigits());
}

From source file:com.bdb.weather.display.day.DayRainPane.java

/**
 * Constructor./* ww w.j a va2  s .c o m*/
 */
public DayRainPane() {
    setPrefSize(400, 300);
    chart = ChartFactory.createBarChart("Water Cycle", "Hour", "", null, PlotOrientation.VERTICAL, true, true,
            false);

    chartViewer = new ChartViewer(chart);

    rainPlot = (CategoryPlot) chart.getPlot();
    rainPlot.setNoDataMessage("There is no data for the specified day");

    BarRenderer renderer = (BarRenderer) rainPlot.getRenderer();
    renderer.setBasePaint(Color.BLUE);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesItemLabelGenerator(0, new RainItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, Depth.getDefaultFormatter()));
    StandardCategoryToolTipGenerator ttgen = new StandardCategoryToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, Depth.getDefaultFormatter());
    rainPlot.getRenderer().setSeriesToolTipGenerator(0, ttgen);

    NumberFormat etFormatter = (NumberFormat) Depth.getDefaultFormatter().clone();
    etFormatter.setMaximumFractionDigits(etFormatter.getMaximumFractionDigits() + 1);
    renderer.setSeriesItemLabelGenerator(1, new RainItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, etFormatter));
    ttgen = new StandardCategoryToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            etFormatter);
    rainPlot.getRenderer().setSeriesToolTipGenerator(1, ttgen);

    rainPlot.setRangeAxis(valueAxis);
    rainPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90);

    dataTable = new TableView();

    TableColumn<RainItem, Integer> hourColumn = new TableColumn<>(HOUR_ROW_KEY);
    hourColumn.setCellValueFactory(new PropertyValueFactory(HOUR_ROW_KEY));
    dataTable.getColumns().add(hourColumn);

    TableColumn<RainItem, Depth> rainfallColumn = new TableColumn<>("Rainfall");
    rainfallColumn.setCellValueFactory(new PropertyValueFactory(RAIN_ROW_KEY));
    dataTable.getColumns().add(rainfallColumn);

    TableColumn<RainItem, Depth> etColumn = new TableColumn<>(ET_ROW_KEY);
    etColumn.setCellValueFactory(new PropertyValueFactory(ET_ROW_KEY));
    dataTable.getColumns().add(etColumn);

    this.setTabContents(chartViewer, dataTable);
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.AbstractChartExpression.java

/**
 * Reduces standard tick unit array to meet  formatting  precision and avoid duplicated values (PRD-5821)
 *
 * @return//from  w ww . j  av  a 2 s  . co m
 */
protected void standardTickUnitsApplyFormat(NumberAxis numberAxis, NumberFormat format) {
    final TickUnits standardTickUnits = (TickUnits) numberAxis.getStandardTickUnits();
    TickUnits cutTickUnits = new TickUnits();
    double formatterMinSize = 1 / Math.pow(10, format.getMaximumFractionDigits());
    for (int i = 0; i < standardTickUnits.size(); i++) {
        if (Double.compare(standardTickUnits.get(i).getSize(), formatterMinSize) >= 0) {
            cutTickUnits.add(new NumberTickUnit(standardTickUnits.get(i).getSize()));
        }
    }
    numberAxis.setStandardTickUnits(cutTickUnits);
}