List of usage examples for org.jfree.chart.plot PiePlot setLabelShadowPaint
public void setLabelShadowPaint(Paint paint)
From source file:com.orsonpdf.demo.PDFPieChartDemo1.java
/** * Creates a chart.//from w w w .j a v a 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:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**//from w w w. ja v a2 s . c o m * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
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);/*from w w w . jav a 2 s. c om*/ 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()); }//www .j av a2 s .co 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: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);// www .j a v a2 s. c o m 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.uttesh.pdfngreport.handler.PdfReportHandler.java
/** * Not Used for the current release// w w w .ja va2 s .c o m * * @param dataSet */ public void pieExplodeChart(DefaultPieDataset dataSet, String os) { try { JFreeChart chart = ChartFactory.createPieChart("", dataSet, true, true, false); ChartStyle.theme(chart); PiePlot plot = (PiePlot) chart.getPlot(); plot.setForegroundAlpha(0.6f); plot.setCircular(true); plot.setSectionPaint("Passed", Color.decode("#019244")); plot.setSectionPaint("Failed", Color.decode("#EE6044")); plot.setSectionPaint("Skipped", Color.decode("#F0AD4E")); Color transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f); //plot.setLabelLinksVisible(Boolean.FALSE); plot.setLabelOutlinePaint(transparent); plot.setLabelBackgroundPaint(transparent); plot.setLabelShadowPaint(transparent); plot.setLabelLinkPaint(Color.GRAY); Font font = new Font("SansSerif", Font.PLAIN, 10); plot.setLabelFont(font); plot.setLabelPaint(Color.DARK_GRAY); plot.setExplodePercent("Passed", 0.10); //plot.setExplodePercent("Failed", 0.10); //plot.setExplodePercent("Skipped", 0.10); plot.setSimpleLabels(true); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); if (os != null && os.equalsIgnoreCase("w")) { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } else { ChartUtilities.saveChartAsPNG( new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE), chart, 560, 200); } } catch (Exception e) { e.printStackTrace(System.err); if (os != null && os.equalsIgnoreCase("w")) { new File(reportLocation + Constants.BACKWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } else { new File(reportLocation + Constants.FORWARD_SLASH + Constants.REPORT_CHART_FILE).delete(); } System.exit(-1); } }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *///from ww w . j av a 2 s . c o m protected JFreeChart createPieChart() throws JRException { JFreeChart jfreeChart = super.createPieChart(); PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setShadowXOffset(0); piePlot.setShadowYOffset(0); PieDataset pieDataset = piePlot.getDataset(); if (pieDataset != null) { for (int i = 0; i < pieDataset.getItemCount(); i++) { piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT); //makes pie colors darker //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]); } } piePlot.setCircular(true); return jfreeChart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a pie chart./*from www .j a v a2 s . co m*/ * * @return A pie chart. */ private static JFreeChart createPieChart() { JFreeChart chart = ChartFactory.createPieChart(null, null, false, true, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setInteriorGap(0.06); plot.setStartAngle(0.0); plot.setLabelGenerator(null); plot.setBaseSectionOutlinePaint(Color.white); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(null); 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:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java
@SuppressWarnings("unchecked") @Override/*from ww w. j ava 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; }
From source file:probe.com.view.body.quantcompare.PieChart.java
private String initPieChart(int width, int height, String title) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int x = 0; x < labels.length; x++) { dataset.setValue(labels[x], values[x]); }/*from w ww. j a va2 s. c om*/ PiePlot plot = new PiePlot(dataset); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0); plot.setLabelFont(new Font("Verdana", Font.BOLD, 10)); plot.setLabelGenerator(new PieSectionLabelGenerator() { @Override public String generateSectionLabel(PieDataset pd, Comparable cmprbl) { return valuesMap.get(cmprbl.toString()); } @Override public AttributedString generateAttributedSectionLabel(PieDataset pd, Comparable cmprbl) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelShadowPaint(null); plot.setLabelPaint(Color.WHITE); plot.setLabelOutlinePaint(null); plot.setBackgroundPaint(Color.WHITE); plot.setInteriorGap(0); plot.setShadowPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f)); plot.setInteriorGap(0.05); for (String label : labels) { plot.setSectionPaint(label, defaultKeyColorMap.get(label)); } JFreeChart chart = new JFreeChart(plot); // chart.setTitle(new TextTitle(title, new Font("Verdana", Font.BOLD, 13))); chart.setBorderPaint(null); chart.setBackgroundPaint(null); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setItemFont(new Font("Verdana", Font.PLAIN, 10)); String imgUrl = saveToFile(chart, width, height); return imgUrl; }