List of usage examples for org.jfree.chart.plot PiePlot setShadowPaint
public void setShadowPaint(Paint paint)
From source file:com.orsonpdf.demo.PDFPieChartDemo1.java
/** * Creates a chart.//from w ww . j a va 2 s. c om * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", dataset, false, false, false); chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); plot.setShadowPaint(null); plot.setLabelShadowPaint(null); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 1.0f); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:org.openfaces.component.chart.impl.configuration.ShadowConfigurator.java
public void configure(ConfigurablePlot plot, ChartView view) { PieChartView pieChartView = (PieChartView) view; PiePlot piePlot = (PiePlot) plot; piePlot.setShadowPaint(pieChartView.getShadowColor()); piePlot.setShadowXOffset(pieChartView.getShadowXOffset()); piePlot.setShadowYOffset(pieChartView.getShadowYOffset()); }
From source file:org.gephi.desktop.context.ContextPieChart.java
public ContextPieChart() { data = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null);/*w w w .j a v a 2s . c o m*/ chart.setPadding(new RectangleInsets(0, 0, 0, 0)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.WHITE); plot.setLabelGap(0.5); plot.setCircular(true); plot.setInteriorGap(0); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222)); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD)); chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false); ((FlowLayout) chartPanel.getLayout()).setHgap(0); ((FlowLayout) chartPanel.getLayout()).setVgap(0); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); }
From source file:org.gephi.desktop.partition.PartitionPie.java
public void setup(Partition partition) { data = new DefaultPieDataset(); for (Part p : partition.getParts()) { data.setValue(p.getDisplayName(), p.getPercentage()); }// w ww . j ava 2 s. c o m final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); //plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.BLACK); //plot.setLabelGap(0.05); plot.setCircular(true); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); for (Part p : partition.getParts()) { plot.setSectionPaint(p.getDisplayName(), p.getColor()); } chartPanel = new ChartPanel(chart, true); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); add(chartPanel, BorderLayout.CENTER); }
From source file:com.rapidminer.template.gui.RoleRequirementSelector.java
private JFreeChart makeChart(ExampleSet exampleSet, Attribute att) { DefaultPieDataset pieDataset = new DefaultPieDataset(); if (att.isNominal()) { for (String val : att.getMapping().getValues()) { pieDataset.setValue(val, exampleSet.getStatistics(att, Statistics.COUNT, val)); }//from w ww . j a v a 2 s . co m } JFreeChart chart = ChartFactory.createPieChart(null, pieDataset, true, false, false); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setFrame(BlockBorder.NONE); chart.setBackgroundImageAlpha(0.0f); chart.setBorderVisible(false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setShadowPaint(null); plot.setOutlineVisible(false); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); plot.setCircular(true); return chart; }
From source file:org.sonar.server.charts.deprecated.PieChart.java
private void configurePlot() { PiePlot plot = (PiePlot) jfreechart.getPlot(); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDataset(dataset);//from www . j a va 2 s .c om plot.setBackgroundAlpha(0.0f); plot.setCircular(true); plot.setLabelGenerator(null); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setShadowPaint(null); plot.setLabelLinkMargin(0.0); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.10); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final Plot plot = chart.getPlot(); final MultiplePiePlot mpp = (MultiplePiePlot) plot; final JFreeChart pc = mpp.getPieChart(); configureSubChart(pc);//from w w w .ja va 2 s. c o m final PiePlot pp = (PiePlot) pc.getPlot(); if (StringUtils.isEmpty(getTooltipFormula()) == false) { pp.setToolTipGenerator(new FormulaPieTooltipGenerator(getRuntime(), getTooltipFormula())); } if (StringUtils.isEmpty(getUrlFormula()) == false) { pp.setURLGenerator(new FormulaPieURLGenerator(getRuntime(), getUrlFormula())); } if (shadowPaint != null) { pp.setShadowPaint(shadowPaint); } if (shadowXOffset != null) { pp.setShadowXOffset(shadowXOffset.doubleValue()); } if (shadowYOffset != null) { pp.setShadowYOffset(shadowYOffset.doubleValue()); } final CategoryDataset c = mpp.getDataset(); if (c != null) { final String[] colors = getSeriesColor(); final int keysSize = c.getColumnKeys().size(); for (int i = 0; i < colors.length; i++) { if (keysSize > i) { pp.setSectionPaint(c.getColumnKey(i), parseColorFromString(colors[i])); } } } if (StringUtils.isEmpty(getLabelFont()) == false) { pp.setLabelFont(Font.decode(getLabelFont())); } if (Boolean.FALSE.equals(getItemsLabelVisible())) { pp.setLabelGenerator(null); } else { final ExpressionRuntime runtime = getRuntime(); final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat fastPercent = new FastDecimalFormat(FastDecimalFormat.TYPE_PERCENT, locale); final FastDecimalFormat fastInteger = new FastDecimalFormat(FastDecimalFormat.TYPE_INTEGER, locale); final DecimalFormat numFormat = new DecimalFormat(fastInteger.getPattern(), new DecimalFormatSymbols(locale)); numFormat.setRoundingMode(RoundingMode.HALF_UP); final DecimalFormat percentFormat = new DecimalFormat(fastPercent.getPattern(), new DecimalFormatSymbols(locale)); percentFormat.setRoundingMode(RoundingMode.HALF_UP); final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( multipieLabelFormat, numFormat, percentFormat); pp.setLabelGenerator(labelGen); } }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java
@SuppressWarnings("unchecked") @Override//from w w w. java 2 s .co 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; }
From source file:edu.gmu.cs.sim.util.media.chart.PieChartGenerator.java
protected void buildChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); chart = ChartFactory.createMultiplePieChart("Untitled Chart", dataset, org.jfree.util.TableOrder.BY_COLUMN, false, true, false);/* w w w . ja v a 2 s . c om*/ chart.setAntiAlias(true); //chartPanel = new ScrollableChartPanel(chart, true); chartPanel = buildChartPanel(chart); //chartHolder.getViewport().setView(chartPanel); setChartPanel(chartPanel); JFreeChart baseChart = (JFreeChart) ((MultiplePiePlot) (chart.getPlot())).getPieChart(); PiePlot base = (PiePlot) (baseChart.getPlot()); base.setIgnoreZeroValues(true); base.setLabelOutlinePaint(java.awt.Color.WHITE); base.setLabelShadowPaint(java.awt.Color.WHITE); base.setMaximumLabelWidth(0.25); // allow bigger labels by a bit (this will make the chart smaller) base.setInteriorGap(0.000); // allow stretch to compensate for the bigger label width base.setLabelBackgroundPaint(java.awt.Color.WHITE); base.setOutlinePaint(null); base.setBackgroundPaint(null); base.setShadowPaint(null); base.setSimpleLabels(false); // I think they're false anyway // change the look of the series title to be smaller StandardChartTheme theme = new StandardChartTheme("Hi"); TextTitle title = new TextTitle("Whatever", theme.getLargeFont()); title.setPaint(theme.getAxisLabelPaint()); title.setPosition(RectangleEdge.BOTTOM); baseChart.setTitle(title); // this must come last because the chart must exist for us to set its dataset setSeriesDataset(dataset); }
From source file:com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.java
public void updatePlotter() { int categoryCount = prepareData(); String maxClassesProperty = ParameterService .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT); int maxClasses = 20; try {//from www . j ava 2s. c om if (maxClassesProperty != null) { maxClasses = Integer.parseInt(maxClassesProperty); } } catch (NumberFormatException e) { // LogService.getGlobal().log("Pie Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", // LogService.WARNING); LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.pie_chart_plotter_parsing_error"); } boolean createLegend = categoryCount > 0 && categoryCount < maxClasses; if (categoryCount <= MAX_CATEGORIES) { JFreeChart chart = createChart(pieDataSet, createLegend); // set the background color for the chart... chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setShadowPaint(new Color(104, 104, 104, 100)); int size = pieDataSet.getKeys().size(); for (int i = 0; i < size; i++) { Comparable<?> key = pieDataSet.getKey(i); plot.setSectionPaint(key, getColorProvider(true).getPointColor(i / (double) (size - 1))); boolean explode = false; for (String explosionGroup : explodingGroups) { if (key.toString().startsWith(explosionGroup) || explosionGroup.startsWith(key.toString())) { explode = true; break; } } if (explode) { plot.setExplodePercent(key, this.explodingAmount); } } plot.setLabelFont(LABEL_FONT); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); plot.setOutlinePaint(Color.WHITE); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); } else { // LogService.getGlobal().logNote("Too many columns (" + categoryCount + // "), this chart is only able to plot up to " + MAX_CATEGORIES + // " different categories."); LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.too_many_columns", new Object[] { categoryCount, MAX_CATEGORIES }); } }