Java Code Examples for org.jfree.chart.plot.PiePlot#setExplodePercent()
The following examples show how to use
org.jfree.chart.plot.PiePlot#setExplodePercent() .
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: ChartJFreeChartOutputPie.java From gama with GNU General Public License v3.0 | 6 votes |
@Override protected void createNewSerie(final IScope scope, final String serieid) { // final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, // serieid); if(!IdPosition.containsKey(serieid)) { final PiePlot plot = (PiePlot) this.chart.getPlot(); // final DefaultPieDataset firstdataset = (DefaultPieDataset) // plot.getDataset(); nbseries++; IdPosition.put(serieid, nbseries - 1); if (getStyle().equals(IKeyword.EXPLODED)) { plot.setExplodePercent(serieid, 0.20); } } // DEBUG.LOG("new serie"+serieid+" at // "+IdPosition.get(serieid)+" jfds "+jfreedataset.size()+" datasc "+" // nbse "+nbseries); }
Example 2
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 3
Source File: PieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureExplode( final PiePlot pp ) { final PieDataset pieDS = pp.getDataset(); final int explodeType = computeExplodeType(); if ( explodeType == EXPLODE_VALUE ) { try { final int actualSegment = Integer.parseInt( explodeSegment ); if ( actualSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( actualSegment ), explodePct.doubleValue() ); } } catch ( Exception ignored ) { } return; } // Calculate min and max... if ( pieDS != null ) { final int itemCount = pieDS.getItemCount(); Number maxNum = new Double( Integer.MIN_VALUE ); Number minNum = new Double( Integer.MAX_VALUE ); int maxSegment = -1; int minSegment = -1; for ( int i = 0; i < itemCount; i++ ) { final Number nbr = pieDS.getValue( i ); if ( nbr.doubleValue() > maxNum.doubleValue() ) { maxNum = nbr; maxSegment = i; } if ( nbr.doubleValue() < minNum.doubleValue() ) { minNum = nbr; minSegment = i; } } if ( explodeType == EXPLODE_MIN ) { //$NON-NLS-1$ if ( minSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( minSegment ), explodePct.doubleValue() ); } } else { if ( maxSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( maxSegment ), explodePct.doubleValue() ); } } } }