List of usage examples for java.text NumberFormat getPercentInstance
public static NumberFormat getPercentInstance(Locale inLocale)
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *///ww w. j a v a 2 s.c om protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot) getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // // } Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * *///from w ww. ja va 2s .co m protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot) getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } if (itemLabel != null && itemLabel.getFont() != null) { piePlot.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale())); } else { piePlot.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale())); } if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( ((JRPiePlot) getPlot()).getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } return jfreeChart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *///from www .ja v a 2s. com protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart); PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot(); double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPie3DPlot.getDepthFactorDouble(); boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular(); piePlot3D.setDepthFactor(depthFactor); piePlot3D.setCircular(isCircular); boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPie3DPlot.getItemLabel(); if (labelGenerator != null) { piePlot3D.setLabelGenerator(labelGenerator); } else if (jrPie3DPlot.getLabelFormat() != null) { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default section label is just the key, so there's no need to set localized number formats // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } piePlot3D.setLabelFont( fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null && itemLabel.getColor() != null) { piePlot3D.setLabelPaint(itemLabel.getColor()); } else { piePlot3D.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot3D.setLabelGenerator(null); } if (jrPie3DPlot.getLegendLabelFormat() != null) { piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default legend label is just the key, so there's no need to set localized number formats return jfreeChart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*w ww .java 2s.c o m*/ protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart); PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot) getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default section label is just the key, so there's no need to set localized number formats // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } piePlot.setLabelFont( fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default legend label is just the key, so there's no need to set localized number formats return jfreeChart; }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java
protected final String formatZoomText(final double zoom) { final NumberFormat numberFormat = NumberFormat.getPercentInstance(swingGuiContext.getLocale()); return (numberFormat.format(zoom)); }