List of usage examples for org.jfree.chart.plot PiePlot3D setLabelPaint
public void setLabelPaint(Paint paint)
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a pie chart with 3D effect./* w w w . ja va2 s .com*/ * * @return A pie chart. */ private static JFreeChart createPieChart3D() { JFreeChart chart = ChartFactory.createPieChart3D(null, null, false, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderPaint(Color.white); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDarkerSides(true); plot.setBaseSectionOutlinePaint(new Color(0, 0, 0, 0)); plot.setStartAngle(0.0); plot.setInteriorGap(0.10); plot.setLabelGenerator(null); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(Color.white); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setLabelPadding(RectangleInsets.ZERO_INSETS); plot.setLabelFont(new Font("Dialog", Font.PLAIN, 12)); plot.setLabelPaint(Color.darkGray); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{2}")); return chart; }
From source file:org.sonar.plugins.scmstats.charts.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*from w w w . j av a2 s. co m*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(180); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.GREEN); plot.setDarkerSides(true); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.GRAY); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.01); plot.setMaximumLabelWidth(0.25); return plot; }
From source file:org.sonar.plugins.abacus.chart.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/* w w w . ja v a2 s . c o m*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(360); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.WHITE); plot.setDarkerSides(false); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.15); return plot; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*w ww .ja va 2 s. c o m*/ 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.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * */// ww w . j a v a 2 s . c o m protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPie3DPlot jrPlot = (JRPie3DPlot) getPlot(); double depthFactor = jrPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPlot.getDepthFactorDouble().doubleValue(); boolean isCircular = jrPlot.getCircular() == null ? false : jrPlot.getCircular().booleanValue(); piePlot3D.setDepthFactor(depthFactor); piePlot3D.setCircular(isCircular); PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPlot.getItemLabel(); if (labelGenerator != null) { piePlot3D.setLabelGenerator(labelGenerator); } else if (jrPlot.getLabelFormat() != null) { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat())); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } if (jrPlot.getLegendLabelFormat() != null) { piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLegendLabelFormat())); } if (itemLabel != null && itemLabel.getFont() != null) { piePlot3D.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale())); } else { piePlot3D.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), 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()); } return jfreeChart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
/** * *//* w ww .ja va 2s .c o m*/ protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPie3DPlot jrPlot = (JRPie3DPlot) getPlot(); double depthFactor = jrPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPlot.getDepthFactorDouble().doubleValue(); boolean isCircular = jrPlot.getCircular() == null ? false : jrPlot.getCircular().booleanValue(); piePlot3D.setDepthFactor(depthFactor); piePlot3D.setCircular(isCircular); PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPlot.getItemLabel(); if (labelGenerator != null) { piePlot3D.setLabelGenerator(labelGenerator); } else if (jrPlot.getLabelFormat() != null) { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat())); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } else { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator()); } if (jrPlot.getLegendLabelFormat() != null) { piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLegendLabelFormat())); } Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; piePlot3D.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); 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()); } return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * *///from w ww . j a v a 2 s.c om protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); 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()))); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } if (itemLabel != null && itemLabel.getFont() != null) { piePlot3D.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale())); } else { piePlot3D.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), 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()))); } return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *//* w ww . j a v a 2 s . c om*/ protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); 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()))); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } else { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator()); } Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; piePlot3D.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); 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()))); } return jfreeChart; }