List of usage examples for org.jfree.chart.plot PiePlot setOutlinePaint
public void setOutlinePaint(Paint paint)
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 ww w. j a v a2 s. c om*/ } } piePlot.setOutlineVisible(true); piePlot.setOutlinePaint(outlinePaint); piePlot.setOutlineStroke(outlineStroke); piePlot.setSectionOutlinesVisible(true); piePlot.setBaseSectionOutlinePaint(outlinePaint); piePlot.setBaseSectionOutlineStroke(outlineStroke); }
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 w w . j a v a 2 s . co m 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.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java
private byte[] generatePieChart(String siteId, PieDataset dataset, int width, int height, boolean render3d, float transparency, boolean smallFontInDomainAxis) { JFreeChart chart = null;//from w w w . ja va 2 s .com if (render3d) chart = ChartFactory.createPieChart3D(null, dataset, false, false, false); else chart = ChartFactory.createPieChart(null, dataset, false, false, false); PiePlot plot = (PiePlot) chart.getPlot(); // set start angle (135 or 150 deg so minor data has more space on the left) plot.setStartAngle(150D); // set transparency plot.setForegroundAlpha(transparency); // set background chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor())); plot.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor())); // fix border offset chart.setPadding(new RectangleInsets(5, 5, 5, 5)); plot.setInsets(new RectangleInsets(1, 1, 1, 1)); // set chart border plot.setOutlinePaint(null); chart.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc")); // set antialias chart.setAntiAlias(true); BufferedImage img = chart.createBufferedImage(width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(img, "png", out); } catch (IOException e) { LOG.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private PiePlot getPiePlot(List<cfCHARTSERIESData> series, String pieSliceStyle, boolean bShow3D) throws cfmBadFileException { org.jfree.data.general.DefaultPieDataset dataset = new org.jfree.data.general.DefaultPieDataset(); cfCHARTSERIESData seriesData = series.get(0); int num = seriesData.getNumItems(); for (int j = 0; j < num; j++) { dataset.setValue(seriesData.getItemName(j), seriesData.getItemValue(j)); }/*w ww . j a va 2s.com*/ // Create a pie plot PiePlot plot; if (bShow3D) { plot = new PiePlot3D(dataset); ((PiePlot3D) plot).setDepthFactor(0.1); } else { if (seriesData.getType().equals("pie")) { // It's a 2D pie chart plot = new PiePlot(dataset); } else { // It's a 2D ring chart plot = new org.jfree.chart.plot.RingPlot(dataset); ((org.jfree.chart.plot.RingPlot) plot).setSeparatorsVisible(false); } } // If a colorList attribute was specified on the cfchartseries tag // then set the section paint for each slice of the pie. List<String> colorList = seriesData.getColorList(); if (colorList != null) { for (int i = 0; i < colorList.size(); i++) { plot.setSectionPaint(i, convertStringToColor(colorList.get(i))); } } // Don't display a shadow plot.setShadowPaint(null); // Only display the name in the Legend plot.setLegendLabelGenerator(new org.jfree.chart.labels.StandardPieSectionLabelGenerator("{0}")); // Don't draw an outline around the chart plot.setOutlinePaint(null); if (pieSliceStyle.equals("sliced")) { for (int j = 0; j < num; j++) plot.setExplodePercent(j, .1); } return plot; }