Java Code Examples for org.jfree.chart.plot.PiePlot#setSectionPaint()
The following examples show how to use
org.jfree.chart.plot.PiePlot#setSectionPaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFreeChartTest.java From testarea-itext5 with GNU Affero General Public License v3.0 | 6 votes |
public static JFreeChart generatePieChart() { DefaultPieDataset dataSet = new DefaultPieDataset(); dataSet.setValue("China", 30); dataSet.setValue("India", 30); dataSet.setValue("United States", 40); JFreeChart chart = ChartFactory.createPieChart("", dataSet, false, true, false); PiePlot piePlot = (PiePlot) chart.getPlot(); piePlot.setBackgroundPaint(Color.WHITE); // set background color white piePlot.setOutlineVisible(false); // remove background border piePlot.setLabelGenerator(null); // remove pie section labels piePlot.setSectionPaint("China", Color.GRAY); piePlot.setSectionPaint("India", Color.GREEN); piePlot.setSectionPaint("United States", Color.BLUE); piePlot.setShadowPaint(Color.WHITE); return chart; }
Example 2
Source File: TypeRepartitionPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
@Override public JFreeChart initChart() { JFreeChart chart = ChartFactory.createPieChart3D("Type repartition", getDataSet(), false,true, true); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("B", Color.BLACK); plot.setSectionPaint("W", Color.WHITE); plot.setSectionPaint("U", Color.BLUE); plot.setSectionPaint("G", Color.GREEN); plot.setSectionPaint("R", Color.RED); plot.setSectionPaint("multi", Color.YELLOW); plot.setSectionPaint("uncolor", Color.GRAY); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%")); plot.setLabelGenerator(generator); return chart; }
Example 3
Source File: RarityRepartitionPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
@Override public JFreeChart initChart() { JFreeChart chart = ChartFactory.createPieChart3D("Rarity repartition", getDataSet(), false, true, true); PiePlot plot = (PiePlot) chart.getPlot(); for(MTGRarity r : MTGRarity.values()) { plot.setSectionPaint(r.toPrettyString(),r.toColor()); } PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"),new DecimalFormat("0.00%")); plot.setLabelGenerator(generator); return chart; }
Example 4
Source File: ManaRepartitionPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
@Override public JFreeChart initChart() { JFreeChart chart = ChartFactory.createPieChart3D("Color repartition", // chart title getDataSet(), // data false, // include legend true, true); PiePlot plot = (PiePlot) chart.getPlot(); for(MTGColor c : MTGColor.values()) { plot.setSectionPaint(c,c.toColor()); } plot.setSectionPaint("Multi", Color.YELLOW); plot.setSectionPaint("multi", Color.YELLOW); plot.setSimpleLabels(true); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{1}", new DecimalFormat("0"), new DecimalFormat("0.00%")); plot.setLabelGenerator(generator); return chart; }
Example 5
Source File: DefaultChartService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getMultiplePieChart( BaseChart chart, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW, !chart.isHideLegend(), false, false ); setBasicConfig( multiplePieChart, chart ); if ( multiplePieChart.getLegend() != null ) { multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT ); } MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot(); JFreeChart pieChart = multiplePiePlot.getPieChart(); pieChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); pieChart.getTitle().setFont( SUB_TITLE_FONT ); PiePlot piePlot = (PiePlot) pieChart.getPlot(); piePlot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setLabelFont( LABEL_FONT ); piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) ); piePlot.setSimpleLabels( true ); piePlot.setIgnoreZeroValues( true ); piePlot.setIgnoreNullValues( true ); piePlot.setShadowXOffset( 0d ); piePlot.setShadowYOffset( 0d ); for ( int i = 0; i < dataSets[0].getColumnCount(); i++ ) { piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] ); } return multiplePieChart; }
Example 6
Source File: ChartImageGenerator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getMultiplePieChart( final Visualization visualization, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( visualization.getName(), dataSets[0], TableOrder.BY_ROW, !visualization.isHideLegend(), false, false ); setBasicConfig( multiplePieChart, visualization ); if ( multiplePieChart.getLegend() != null ) { multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT ); } MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot(); JFreeChart pieChart = multiplePiePlot.getPieChart(); pieChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); pieChart.getTitle().setFont( SUB_TITLE_FONT ); PiePlot piePlot = (PiePlot) pieChart.getPlot(); piePlot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setLabelFont( LABEL_FONT ); piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) ); piePlot.setSimpleLabels( true ); piePlot.setIgnoreZeroValues( true ); piePlot.setIgnoreNullValues( true ); piePlot.setShadowXOffset( 0d ); piePlot.setShadowYOffset( 0d ); for ( int i = 0; i < dataSets[0].getColumnCount(); i++ ) { piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] ); } return multiplePieChart; }
Example 7
Source File: AbstractPieChartPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
public void updatePlotter() { int categoryCount = prepareData(); String maxClassesProperty = ParameterService .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT); int maxClasses = 20; try { 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(true); 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 }); } }
Example 8
Source File: PieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureChart( final JFreeChart chart ) { super.configureChart( chart ); final Plot plot = chart.getPlot(); final PiePlot pp = (PiePlot) plot; final PieDataset pieDS = pp.getDataset(); pp.setDirection( rotationClockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE ); if ( ( explodeSegment != null ) && ( explodePct != null ) ) { configureExplode( pp ); } if ( StringUtils.isEmpty( getTooltipFormula() ) == false ) { pp.setToolTipGenerator( new FormulaPieTooltipGenerator( getRuntime(), getTooltipFormula() ) ); } if ( StringUtils.isEmpty( getUrlFormula() ) == false ) { pp.setURLGenerator( new FormulaPieURLGenerator( getRuntime(), getUrlFormula() ) ); } pp.setIgnoreNullValues( ignoreNulls ); pp.setIgnoreZeroValues( ignoreZeros ); 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, true ); final FastDecimalFormat fastInteger = new FastDecimalFormat( FastDecimalFormat.TYPE_INTEGER, locale, true ); 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( pieLabelFormat, numFormat, percentFormat ); pp.setLabelGenerator( labelGen ); final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator( pieLegendLabelFormat, numFormat, percentFormat ); pp.setLegendLabelGenerator( legendGen ); } if ( StringUtils.isEmpty( getLabelFont() ) == false ) { pp.setLabelFont( Font.decode( getLabelFont() ) ); } if ( pieDS != null ) { final String[] colors = getSeriesColor(); for ( int i = 0; i < colors.length; i++ ) { if ( i < pieDS.getItemCount() ) { pp.setSectionPaint( pieDS.getKey( i ), parseColorFromString( colors[ i ] ) ); } else { break; } } } if ( shadowPaint != null ) { pp.setShadowPaint( shadowPaint ); } if ( shadowXOffset != null ) { pp.setShadowXOffset( shadowXOffset.doubleValue() ); } if ( shadowYOffset != null ) { pp.setShadowYOffset( shadowYOffset.doubleValue() ); } pp.setCircular( circular ); if ( isShowBorder() == false || isChartSectionOutline() == false ) { chart.setBorderVisible( false ); chart.getPlot().setOutlineVisible( false ); } }
Example 9
Source File: PieChartDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 10
Source File: PieChartFXDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 11
Source File: PieChartFXDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 12
Source File: MinimapPanel.java From dsworkbench with Apache License 2.0 | 4 votes |
private void renderChartInfo() { HashMap<Object, Marker> marks = new HashMap<>(); DefaultPieDataset dataset = buildDataset(marks); JFreeChart chart = ChartFactory.createPieChart( null, // chart title dataset, // data true, // include legend true, false); chart.setBackgroundPaint(null); //chart.setBorderStroke(null); chart.setBorderVisible(false); final PiePlot plot = (PiePlot) chart.getPlot(); // plot.setBackgroundPaint(null); // plot.setShadowPaint(null); for(Object o: marks.keySet()) { if (iCurrentView == ID_ALLY_CHART) { Ally a = (Ally) o; plot.setSectionPaint(a.getTag(), marks.get(a).getMarkerColor()); } else { Tribe t = (Tribe) o; plot.setSectionPaint(t.getName(), marks.get(t).getMarkerColor()); } } //plot.setCircular(true); // plot.setMaximumLabelWidth(30.0); /* * plot.setLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {2}", NumberFormat.getNumberInstance(), * NumberFormat.getPercentInstance())); */ // chart.getLegend().setVerticalAlignment(VerticalAlignment.CENTER); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // plot.setMaximumLabelWidth(20.0); plot.setLabelGenerator(null); plot.setBackgroundPaint(Constants.DS_BACK); /* * plot.setInteriorGap(0.0); plot.setLabelGap(0.0); */ plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); /* * plot.getL plot.setLabelFont(g2d.getFont().deriveFont(10.0f)); */ //plot.setLabelGenerator(null); //plot.setMaximumLabelWidth(30.0); //plot.getLabelDistributor().distributeLabels(10.0, 20.0); //chart.draw(g2d, new Rectangle2D.Float(20, 20, 100, 100)); // g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); plot.setOutlineVisible(false); mChartImage = chart.createBufferedImage(getWidth(), getHeight()); //chart.draw(g2d, new Rectangle2D.Float(50, 50, 400, 400)); //g2d.drawImage(bi, 30, 30, null); // g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); //bi = chart.createBufferedImage(240, 240); // g2d.drawImage(bi, 30, 30, null); }
Example 13
Source File: CommonPieChartAction.java From bamboobsc with Apache License 2.0 | 4 votes |
private void setPlotColor(PiePlot plot, List<String> names, List<String> colors) throws Exception { for (int ix=0; ix<names.size(); ix++) { plot.setSectionPaint( names.get(ix), Color.decode(colors.get(ix)) ); } }
Example 14
Source File: PieChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 15
Source File: PieChartDemo1.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 16
Source File: MultiPieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
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 ); 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 ); } }
Example 17
Source File: PieChartDemo1.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 18
Source File: PieChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }
Example 19
Source File: PieChartFXDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", dataset); // set a custom background for the chart 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); // 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.setDefaultSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setDefaultSectionOutlineStroke(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; }
Example 20
Source File: PieChartDemo1.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart 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); // 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); 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; }