List of usage examples for org.jfree.chart.plot PiePlot setURLGenerator
public void setURLGenerator(PieURLGenerator generator)
From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java
public JFreeChart makePieChart(ChartModel chartModel, NamedValuesDataModel dataModel, final IChartLinkGenerator linkGenerator) { final DefaultPieDataset dataset = new DefaultPieDataset(); for (NamedValue namedValue : dataModel) { if (namedValue.getName() != null) { dataset.setValue(namedValue.getName(), scaleNumber(namedValue.getValue(), dataModel.getScalingFactor())); }//from w w w.j a v a2s . c o m } boolean showLegend = (chartModel.getLegend() != null) && (chartModel.getLegend().getVisible()); String title = ""; if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null) && (chartModel.getTitle().getText().trim().length() > 0)) { title = chartModel.getTitle().getText(); } final JFreeChart chart = ChartFactory.createPieChart(title, dataset, showLegend, true, false); initChart(chart, chartModel); final PiePlot jFreePiePlot = (PiePlot) chart.getPlot(); if (linkGenerator != null) { jFreePiePlot.setURLGenerator(new PieURLGenerator() { public String generateURL(PieDataset arg0, Comparable arg1, int arg2) { return linkGenerator.generateLink(arg1.toString(), arg1.toString(), arg0.getValue(arg1)); } }); } jFreePiePlot.setNoDataMessage("No data available"); //$NON-NLS-1$ jFreePiePlot.setCircular(true); jFreePiePlot.setLabelGap(0.02); org.pentaho.chart.model.PiePlot chartBeansPiePlot = (org.pentaho.chart.model.PiePlot) chartModel.getPlot(); List<Integer> colors = getPlotColors(chartBeansPiePlot); int index = 0; for (NamedValue namedValue : dataModel) { if (namedValue.getName() != null) { jFreePiePlot.setSectionPaint(namedValue.getName(), new Color(0x00FFFFFF & colors.get(index % colors.size()))); } index++; } if (chartBeansPiePlot.getLabels().getVisible()) { jFreePiePlot.setLabelGenerator(new StandardPieSectionLabelGenerator()); Font font = ChartUtils.getFont(chartBeansPiePlot.getLabels().getFontFamily(), chartBeansPiePlot.getLabels().getFontStyle(), chartBeansPiePlot.getLabels().getFontWeight(), chartBeansPiePlot.getLabels().getFontSize()); if (font != null) { jFreePiePlot.setLabelFont(font); if (chartBeansPiePlot.getLabels().getColor() != null) { jFreePiePlot.setLabelPaint(new Color(0x00FFFFFF & chartBeansPiePlot.getLabels().getColor())); } if (chartBeansPiePlot.getLabels().getBackgroundColor() != null) { jFreePiePlot.setLabelBackgroundPaint( new Color(0x00FFFFFF & chartBeansPiePlot.getLabels().getBackgroundColor())); } } } else { jFreePiePlot.setLabelGenerator(null); } jFreePiePlot.setStartAngle(-chartBeansPiePlot.getStartAngle()); return chart; }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a pie chart with default settings that compares 2 datasets. * The colour of each section will be determined by the move from the value * for the same key in <code>previousDataset</code>. ie if value1 > value2 * then the section will be in green (unless <code>greenForIncrease</code> * is <code>false</code>, in which case it would be <code>red</code>). * Each section can have a shade of red or green as the difference can be * tailored between 0% (black) and percentDiffForMaxScale% (bright * red/green). /*from w w w. ja v a 2 s . co m*/ * <p> * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a * difference of 5% will have a half shade of red/green, a difference of * 10% or more will have a maximum shade/brightness of red/green. * <P> * The chart object returned by this method uses a {@link PiePlot} instance * as the plot. * <p> * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit * Xhenseval</a>. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param previousDataset the dataset for the last run, this will be used * to compare each key in the dataset * @param percentDiffForMaxScale scale goes from bright red/green to black, * percentDiffForMaxScale indicate the change * required to reach top scale. * @param greenForIncrease an increase since previousDataset will be * displayed in green (decrease red) if true. * @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? * @param subTitle displays a subtitle with colour scheme if true * @param showDifference create a new dataset that will show the % * difference between the two datasets. * * @return A pie chart. */ public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset, int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, boolean urls, boolean subTitle, boolean showDifference) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } List keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (Iterator it = keys.iterator(); it.hasNext();) { Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } return chart; }
From source file:KIDLYFactory.java
/** * Creates a chart that displays multiple pie plots. The chart object * returned by this method uses a {@link MultiplePiePlot} instance as the * plot./*w w w . ja v a 2 s .co m*/ * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param order the order that the data is extracted (by row or by column) * (<code>null</code> not permitted). * @param legend include a legend? * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A chart. */ public static JFreeChart createMultiplePieChart(String title, CategoryDataset dataset, TableOrder order, boolean legend, boolean tooltips, boolean urls) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPaint(null); plot.setOutlineStroke(null); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:KIDLYFactory.java
/** * Creates a chart that displays multiple pie plots. The chart object * returned by this method uses a {@link MultiplePiePlot} instance as the * plot./* w ww . j ava 2s . c o m*/ * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param order the order that the data is extracted (by row or by column) * (<code>null</code> not permitted). * @param legend include a legend? * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A chart. */ public static JFreeChart createMultiplePieChart3D(String title, CategoryDataset dataset, TableOrder order, boolean legend, boolean tooltips, boolean urls) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPaint(null); plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:KIDLYFactory.java
/** * Creates a pie chart with default settings. * <P>//w w w.j ava 2s .co m * The chart object returned by this method uses a {@link PiePlot} 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 urls configure chart to generate URLs? * * @return A pie chart. */ public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); 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; }
From source file:KIDLYFactory.java
/** * Creates a pie chart with default settings that compares 2 datasets. * The colour of each section will be determined by the move from the value * for the same key in <code>previousDataset</code>. ie if value1 > value2 * then the section will be in green (unless <code>greenForIncrease</code> * is <code>false</code>, in which case it would be <code>red</code>). * Each section can have a shade of red or green as the difference can be * tailored between 0% (black) and percentDiffForMaxScale% (bright * red/green)./* w ww .j a va 2 s . c o m*/ * <p> * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a * difference of 5% will have a half shade of red/green, a difference of * 10% or more will have a maximum shade/brightness of red/green. * <P> * The chart object returned by this method uses a {@link PiePlot} instance * as the plot. * <p> * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit * Xhenseval</a>. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param previousDataset the dataset for the last run, this will be used * to compare each key in the dataset * @param percentDiffForMaxScale scale goes from bright red/green to black, * percentDiffForMaxScale indicate the change * required to reach top scale. * @param greenForIncrease an increase since previousDataset will be * displayed in green (decrease red) if true. * @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? * @param subTitle displays a subtitle with colour scheme if true * @param showDifference create a new dataset that will show the % * difference between the two datasets. * * @return A pie chart. */ public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset, int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, boolean urls, boolean subTitle, boolean showDifference) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } List keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (Iterator it = keys.iterator(); it.hasNext();) { Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } currentTheme.apply(chart); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.LinkablePie.java
public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true;//w ww. j a v a 2s. co m JFreeChart chart = null; if (!threeD) { chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data legend, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); } else { chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data true, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(1.0f); plot.setDepthFactor(0.2); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer); MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }
From source file:lucee.runtime.tag.Chart.java
private void setUrl(JFreeChart chart) { if (StringUtil.isEmpty(url)) return;/* w w w . java 2 s . c o m*/ Plot plot = chart.getPlot(); if (plot instanceof PiePlot) { PiePlot pp = (PiePlot) plot; pp.setURLGenerator(new PieURLGenerator() { public String generateURL(PieDataset dataset, Comparable key, int pieIndex) { if (!StringUtil.contains(url, "?")) url += "?series=$SERIESLABEL$&category=$ITEMLABEL$&value=$VALUE$"; String retUrl = StringUtil.replace(url, "$ITEMLABEL$", URLUtilities.encode(key.toString(), "UTF-8"), false, true); retUrl = StringUtil.replace(retUrl, "$SERIESLABEL$", Integer.toString(pieIndex), false, true); retUrl = StringUtil.replace(retUrl, "$VALUE$", URLUtilities.encode(dataset.getValue(key).toString(), "UTF-8"), false, true); return retUrl; } }); } else if (plot instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) plot; CategoryItemRenderer renderer = cp.getRenderer(); renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator() { public String generateURL(CategoryDataset dataset, int series, int category) { if (!StringUtil.contains(url, "?")) url += "?series=$SERIESLABEL$&category=$ITEMLABEL$&value=$VALUE$"; String retUrl = StringUtil.replace(url, "$ITEMLABEL$", URLUtilities.encode(dataset.getColumnKey(category).toString(), "UTF-8"), false, true); retUrl = StringUtil.replace(retUrl, "$SERIESLABEL$", URLUtilities.encode(dataset.getRowKey(series).toString(), "UTF-8"), false, true); retUrl = StringUtil.replace(retUrl, "$VALUE$", URLUtilities.encode(dataset.getValue(series, category).toString(), "UTF-8"), false, true); return retUrl; } }); } else if (plot instanceof XYPlot) { XYPlot cp = (XYPlot) plot; XYItemRenderer renderer = cp.getRenderer(); renderer.setURLGenerator(new StandardXYURLGenerator() { public String generateURL(XYDataset dataset, int series, int category) { if (!StringUtil.contains(url, "?")) url += "?series=$SERIESLABEL$&category=$ITEMLABEL$&value=$VALUE$"; String itemLabel = _plotItemLables.get(category + 1) != null ? _plotItemLables.get(category + 1) : dataset.getX(series, category).toString(); String retUrl = StringUtil.replace(url, "$ITEMLABEL$", URLUtilities.encode(itemLabel, "UTF-8"), false, true); retUrl = StringUtil.replace(retUrl, "$SERIESLABEL$", URLUtilities.encode(dataset.getSeriesKey(series).toString(), "UTF-8"), false, true); retUrl = StringUtil.replace(retUrl, "$VALUE$", URLUtilities.encode(dataset.getY(series, category).toString(), "UTF-8"), false, true); return retUrl; } }); } }
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
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);/*from w ww .j ava 2 s. com*/ pieChart.setBackgroundPaint(chartDefinition.getChartBackgroundPaint()); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); plot.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); plot.setURLGenerator(urlGenerator); } return pieChart; }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java
@SuppressWarnings("unchecked") @Override//w w w . ja va 2 s . c o m public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP); boolean graphDisplayLabel = getParam(GraphSource.GRAPH_DISPLAY_LABEL, Boolean.class, false); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); String noDataMessage = getParam(GraphSource.GRAPH_NO_DATA_MESSAGE, String.class, DEFAULT_GRAPH_NO_DATA_MESSAGE); PieGraphData pieGraphData = makeDataSet(); Map<Comparable, Paint> colors = pieGraphData.colors; this.chart = ChartFactory.createPieChart(title, pieGraphData.data, false, graphToolTip, false); Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Paint labelColor = getParam(JFreeChartTimeSeriesGraphSource.GRAPH_LABEL_BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); this.chart.setBackgroundPaint(backgroundColor); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(plotColor); plot.setNoDataMessage(noDataMessage); if (!graphDisplayLabel) { plot.setLabelGenerator(null); } else { plot.setInteriorGap(0.001); plot.setMaximumLabelWidth(.3); // plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setShadowPaint(null); // plot.setOutlineVisible(false); //TODO use title font? Font font = plot.getLabelFont(); plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); plot.setLabelFont(font.deriveFont(font.getSize2D() * .75f)); plot.setLabelBackgroundPaint(labelColor); plot.setLabelShadowPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelGap(0.001); plot.setLabelLinkMargin(0.0); plot.setLabelLinksVisible(true); // plot.setSimpleLabels(true); // plot.setCircular(true); } if (!graphBorder) { plot.setOutlineVisible(false); } if (title != null && !"".equals(title)) { TextTitle title1 = new TextTitle(); title1.setText(title); title1.setFont(titleFont); title1.setPadding(3, 2, 5, 2); chart.setTitle(title1); } else { chart.setTitle((TextTitle) null); } plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); //Makes a wrapper for the legend to remove the border around it if (legend) { LegendTitle legend1 = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legend1.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend1.setWrapper(wrapper); legend1.setPosition(RectangleEdge.BOTTOM); legend1.setHorizontalAlignment(HorizontalAlignment.CENTER); if (params.get(GraphSource.LEGEND_FONT) instanceof Font) { legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT))); } chart.addSubtitle(legend1); plot.setLegendLabelGenerator(new PieGraphLabelGenerator()); } for (Comparable category : colors.keySet()) { plot.setSectionPaint(category, colors.get(category)); } plot.setToolTipGenerator(new PieGraphToolTipGenerator(pieGraphData)); plot.setURLGenerator(new PieGraphURLGenerator(pieGraphData)); initialized = true; }