List of usage examples for org.jfree.chart.plot PiePlot setSectionOutlinesVisible
public void setSectionOutlinesVisible(boolean visible)
From source file:com.thingsfx.swing.jfreechart.JFreeChartPanel.java
void initComponents() { PieDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createPieChart("JFree in JavaFX Chart Is Cool!", // chart title dataset, // data true, // include legend true, false);/* w w w . java 2s. c o m*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); add(new ChartPanel(chart)); }
From source file:nl.wur.plantbreeding.logic.jfreechart.PieChart.java
/** * Create the Pie Chart using the given dataset. * It assigns to the chart the given title, prints the legend if asked, * adds a tooltips of the given url.//from ww w. ja va 2 s. c om * @param dataset a PieDataset * @param title the title of the graph * @param boollegend wether to add the legend or not * @param tooltips wether to add the tooltips or not * @param urls wether to link the different part of the plot or not * @return a JFreeChart object of the pie chart */ public final JFreeChart createChart(final PieDataset dataset, final String title, final boolean boollegend, final boolean tooltips, final boolean urls) { JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data boollegend, // include legend tooltips, // include tooltips urls // include urls ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundAlpha(new Float(0.0)); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); plot.setOutlineVisible(false); // remove borders around the plot return chart; }
From source file:edu.uara.wrappers.customcharts.CustomPieChart.java
/** * Function to set out line visibility/*from w ww . java2 s .com*/ */ @Override public void setOutlineVisibility(boolean outLine) { PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(outLine); }
From source file:utils.Graphs.java
public static File generate(File baseFolder, String titles[], int[] values, Color backgroundColor) { DefaultPieDataset dataset = new DefaultPieDataset(); // add our data values int i = -1;// ww w . jav a2s. c o m for (String title : titles) { i++; dataset.setValue(title, values[i]); } final JFreeChart chart = // ChartFactory.createPieChart("", dataset, true, true, false); ChartFactory.createPieChart("", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); //PiePlot3D plot = (PiePlot3D) chart.getPlot(); //plot.setStartAngle(290); plot.setStartAngle(45); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); // final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(backgroundColor); // plot.setLegendLabelGenerator( // new StandardPieSectionLabelGenerator("{0} {2}")); chart.setBorderVisible(false); chart.getPlot().setOutlineVisible(false); chart.getLegend().setFrame(BlockBorder.NONE); // get the same background chart.setBackgroundPaint(backgroundColor); chart.getLegend().setBackgroundPaint(backgroundColor); // hide the shadow effects plot.setShadowXOffset(0); plot.setShadowYOffset(0); //chart.getLegend().setVisible(false); plot.setCircular(true); //plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}", NumberFormat.getNumberInstance(), NumberFormat plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); plot.setNoDataMessage("No data found."); Color greenColor = new Color(0x8FBC0C); Color redColor = new Color(0xFF0000); //Color redColor = new Color(0xDA6022); plot.setSectionPaint(0, greenColor); plot.setSectionPaint(1, redColor); plot.setSectionOutlinesVisible(true); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file = new File(baseFolder, "chart.png"); try { ChartUtilities.saveChartAsPNG(file, chart, 200, 160, info); } catch (IOException ex) { Logger.getLogger(Graphs.class.getName()).log(Level.SEVERE, null, ex); } // //// final ChartPanel chartPanel = new ChartPanel(chart, true); // final ChartPanel chartPanel = new ChartPanel(chart, true); // chartPanel.setMinimumDrawWidth(0); // chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); // chartPanel.setMinimumDrawHeight(0); // chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); // JDialog dialog = new JDialog(); // dialog.add(chartPanel); // dialog.setLayout(new GridLayout(1, 1)); // dialog.setSize(400, 200); // dialog.setVisible(true); return file; }
From source file:uom.research.thalassemia.util.PieChartCreator.java
/** * Creates a chart./*from w w w .j ava2s.c o m*/ * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data true, // 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 int itemIndex = 0; for (Object col : pieDataset.getKeys()) { plot.setSectionPaint(col.toString(), gradientPaints[itemIndex]); if (itemIndex == pieDataset.getItemCount() - 1) { itemIndex = 0; } itemIndex++; } 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; }
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 {/* w ww.j a va 2 s. 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 }); } }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Creates a Pie Chart based on map./* w w w . j a va2 s .c om*/ * * @return the Pie Chart generated. */ public JFreeChart getPieChart(Map<String, Double> pieValues) { DefaultPieDataset dataset = new DefaultPieDataset(); for (String key : pieValues.keySet()) { dataset.setValue(key, pieValues.get(key)); } JFreeChart chart = ChartFactory.createPieChart3D(null, // chart title dataset, // data true, // include legend true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(false); chart.setBorderPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setOutlinePaint(null); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.33); return chart; }
From source file:kolacer.Kolacer.java
private void upravPlot(PiePlot plot) { plot.setSectionOutlinesVisible(false); plot.setOutlinePaint(null);/*from w w w . j a v a 2s .c om*/ if (jRad_barvy_manual.isSelected()) { for (Udaj u : udaje) { plot.setSectionPaint(u.hodnota, u.barva); } } else if (jRad_barvy_auto.isSelected()) { Barvy.nastavBarvy(plot); } else if (jRad_barvy_gradient.isSelected()) { Barvy.nastavBarvy(plot, barvaGradA, barvaGradB); } if (!jCHB_popisky.isSelected()) plot.setLabelGenerator(null); else { plot.setLabelBackgroundPaint(new Color(0, 0, 0, 0)); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setSimpleLabels(true); plot.setInsets(new RectangleInsets(5, 5, 5, 400)); plot.setLabelFont(popisekGrafuFont); //plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1} hl. ({2})")); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}")); } plot.setBackgroundPaint(null); plot.setShadowPaint(null); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} ({2}) - {0}")); }
From source file:net.sqs2.omr.result.export.chart.ChartImageWriter.java
private void setSectionPaint(PieDataset dataSet, PiePlot piePlot) { Paint outlinePaint = Color.BLACK; Stroke outlineStroke = new BasicStroke(1.0f); if (this.itemBackgroundImages != null && 0 < this.itemBackgroundImages.length) { int index = 0; for (Object key : dataSet.getKeys()) { int imageIndex = index % this.itemBackgroundImages.length; BufferedImage texture = this.itemBackgroundImages[imageIndex]; Rectangle2D anchor = new Rectangle2D.Double(0, 0, texture.getWidth(), texture.getHeight()); TexturePaint fillPaint = new TexturePaint(texture, anchor); piePlot.setSectionPaint((Comparable<?>) key, fillPaint); piePlot.setSectionOutlinePaint((Comparable<?>) key, outlinePaint); piePlot.setSectionOutlineStroke((Comparable<?>) key, outlineStroke); index++;//from w ww . j a v a 2 s .c o m } } piePlot.setOutlineVisible(true); piePlot.setOutlinePaint(outlinePaint); piePlot.setOutlineStroke(outlineStroke); piePlot.setSectionOutlinesVisible(true); piePlot.setBaseSectionOutlinePaint(outlinePaint); piePlot.setBaseSectionOutlineStroke(outlineStroke); }
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 w w . j a v a 2 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; }