List of usage examples for org.jfree.chart.plot PiePlot3D setSectionPaint
public void setSectionPaint(Comparable key, Paint paint)
From source file:org.sonar.plugins.abacus.chart.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*www .j av a 2 s .c o m*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(360); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.WHITE); plot.setDarkerSides(false); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.15); return plot; }
From source file:org.sonar.plugins.scmstats.charts.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*from w w w. j a v a2s . com*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(180); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.GREEN); plot.setDarkerSides(true); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.GRAY); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.01); plot.setMaximumLabelWidth(0.25); return plot; }
From source file:net.nosleep.superanalyzer.analysis.views.EncodingKindView.java
private void refreshDataset() { PiePlot3D plot = (PiePlot3D) _chart.getPlot(); _dataset.clear();/*w w w . j ava 2 s. c o m*/ // plot.clearSectionPaints(true); Hashtable kindHash = null; if (_comboBox == null) { kindHash = _analysis.getEncodingKinds(Analysis.KIND_TRACK, null); } else { ComboItem item = (ComboItem) _comboBox.getSelectedItem(); kindHash = _analysis.getEncodingKinds(item.getKind(), item.getValue()); } Color[] colors = Theme.getColorSet(); Enumeration e = kindHash.keys(); int i = 0; while (e.hasMoreElements()) { String kindName = (String) e.nextElement(); Integer count = (Integer) kindHash.get(kindName); // if (count.intValue() > 0) { _dataset.setValue(kindName, new Double(count)); plot.setSectionPaint(kindName, colors[5 - (i % colors.length)]); // mod it in case we don't have enough colors i++; if (i > colors.length) i = 0; // } } // plot.notifyListeners(new PlotChangeEvent(plot)); // _chartPanel.invalidate(); }
From source file:GroupProject.OriginalChartUI.java
/** * The method to draw pie chart/* w w w .j a v a 2 s . com*/ * @param pieChartData the data used in the pie chart * @param pieTitle the measurement of pie chart */ public void drawPieChart(Map<String, Long> pieChartData, String pieTitle) { String title = pieTitle; ArrayList<String> keyArrayList = new ArrayList<>(); ArrayList<Long> valueArrayList = new ArrayList<>(); ArrayList<Color> colorArrayList = new ArrayList<>(); colorArrayList.add(new Color(222, 235, 247)); colorArrayList.add(new Color(109, 166, 217)); colorArrayList.add(new Color(155, 195, 230)); colorArrayList.add(new Color(126, 146, 222)); colorArrayList.add(new Color(96, 158, 218)); colorArrayList.add(new Color(53, 132, 203)); colorArrayList.add(new Color(46, 116, 180)); colorArrayList.add(new Color(31, 77, 119)); DefaultPieDataset dataset = new DefaultPieDataset(); Set set = pieChartData.keySet(); for (Map.Entry<String, Long> data : pieChartData.entrySet()) { String key = data.getKey(); Long value = data.getValue(); keyArrayList.add(key); valueArrayList.add(value); } for (int i = 0; i < valueArrayList.size(); i++) { dataset.setValue(keyArrayList.get(i), valueArrayList.get(i)); } JFreeChart chart = ChartFactory.createPieChart3D(title, dataset); chart.setBorderVisible(false); chart.setBorderPaint(new Color(255, 255, 255)); PiePlot3D plot = (PiePlot3D) chart.getPlot(); for (int i = 0; i < valueArrayList.size(); i++) { Color color = colorArrayList.get(i); plot.setSectionPaint(keyArrayList.get(i), color); } plot.setOutlineVisible(false); plot.setForegroundAlpha(0.6f); plot.setStartAngle(0); plot.setBackgroundPaint(new java.awt.Color(255, 255, 255)); ChartPanel chartPanel = new ChartPanel(chart); chartDisplayPanel.removeAll(); chartDisplayPanel.add(chartPanel, BorderLayout.CENTER); chartDisplayPanel.validate(); }