@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); 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);
/** * Creates a pie chart with 3D effect. * * @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.setBackgroundPaint(null); 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.gray); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{2}")); return chart; }
RectangleInsets insets = getInsets(); insets.trim(plotArea); drawBackground(g2, plotArea); double gapPercent = getInteriorGap(); double labelPercent = 0.0; if (getLabelGenerator() != null) { labelPercent = getLabelGap() + getMaximumLabelWidth(); double hGap = plotArea.getWidth() * getInteriorGap(); double vGap = plotArea.getHeight() * getInteriorGap(); double igx1 = plotArea.getX() + hGap; double igx2 = plotArea.getMaxX() - hGap; if (isCircular()) { // is circular? double min = Math.min(linkW, linkH) / 2; linkX = (linkX + linkX + linkW) / 2 - min; PiePlotState state = initialise(g2, plotArea, this, null, info); double hh = linkW * getLabelLinkMargin(); double vv = linkH * getLabelLinkMargin(); Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, linkY + vv / 2.0, linkW - hh, linkH - vv); double maximumExplodePercent = getMaximumExplodePercent(); double percent = maximumExplodePercent / (1.0 + maximumExplodePercent);
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); if (labelGenerator != null) piePlot3D.setLabelGenerator(labelGenerator); piePlot3D.setLabelGenerator( new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat()) ); piePlot3D.setLegendLabelGenerator( new StandardPieSectionLabelGenerator(jrPlot.getLegendLabelFormat()) ); piePlot3D.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale())); piePlot3D.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale())); piePlot3D.setLabelPaint(itemLabel.getColor()); piePlot3D.setLabelPaint(getChart().getForecolor()); piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
/** * Creates a 3D pie chart using the specified dataset. The chart object * returned by this method uses a {@link PiePlot3D} instance as the * plot. * * @param title the chart title ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A pie chart. */ public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls) { PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a 3D pie chart using the specified dataset. The chart object * returned by this method uses a {@link PiePlot3D} instance as the * plot. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale (<code>null</code> not permitted). * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12));
/** * Creates a pie chart with a three dimensional effect using the specified * dataset. * * @param dataset the dataset ({@code null} permitted). */ public PiePlot3D(PieDataset dataset) { super(dataset); setCircular(false, false); }
RectangleInsets insets = getInsets(); insets.trim(plotArea); drawBackground(g2, plotArea); if (getShadowGenerator() != null) { dataImage = new BufferedImage((int) plotArea.getWidth(), (int) plotArea.getHeight(), BufferedImage.TYPE_INT_ARGB); double gapPercent = getInteriorGap(); double labelPercent = 0.0; if (getLabelGenerator() != null) { labelPercent = getLabelGap() + getMaximumLabelWidth(); double hGap = plotArea.getWidth() * getInteriorGap(); double vGap = plotArea.getHeight() * getInteriorGap(); double igx1 = plotArea.getX() + hGap; double igx2 = plotArea.getMaxX() - hGap; if (isCircular()) { // is circular? double min = Math.min(linkW, linkH) / 2; linkX = (linkX + linkX + linkW) / 2 - min; PiePlotState state = initialise(g2, plotArea, this, null, info); double hh = linkW * getLabelLinkMargin(); double vv = linkH * getLabelLinkMargin(); Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, linkY + vv / 2.0, linkW - hh, linkH - vv);
boolean urls) { PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); plot.setURLGenerator(new StandardPieURLGenerator());
/** * Creates a 3D pie chart using the specified dataset. The chart object * returned by this method uses a {@link PiePlot3D} instance as the * plot. * * @param title the chart title ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale ({@code null} not permitted). * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { Args.nullNotPermitted(locale, "locale"); PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
private static JFreeChart createPieDatasetChart( final PieDatasetChartDefinition chartDefinition ) { // TODO Make the following accessible from the chartDefinition boolean tooltips = true; boolean urls = true; // ----------------------------------------------------------- String title = chartDefinition.getTitle(); boolean legend = chartDefinition.isLegendIncluded(); PiePlot plot = null; plot = chartDefinition.isThreeD() ? new PiePlot3D( chartDefinition ) : new PiePlot( chartDefinition ); JFreeChartEngine.updatePlot( plot, chartDefinition ); JFreeChart pieChart = new JFreeChart( title, chartDefinition.getTitleFont(), plot, legend ); TextTitle seriesTitle = new TextTitle( "Series Title", new Font( "SansSerif", Font.BOLD, 12 ) ); //$NON-NLS-1$ //$NON-NLS-2$ seriesTitle.setPosition( RectangleEdge.BOTTOM ); pieChart.setTitle( title ); pieChart.setBackgroundPaint( chartDefinition.getChartBackgroundPaint() ); if ( tooltips ) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); plot.setToolTipGenerator( tooltipGenerator ); } if ( urls ) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); plot.setURLGenerator( urlGenerator ); } return pieChart; }
/** * Creates a pie chart with a three dimensional effect using the specified * dataset. * * @param dataset the dataset (<code>null</code> permitted). */ public PiePlot3D(PieDataset dataset) { super(dataset); setCircular(false, false); }
plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12));