List of usage examples for org.jfree.chart.plot PiePlot setSectionOutlinesVisible
public void setSectionOutlinesVisible(boolean visible)
From source file:fr.inria.soctrace.framesoc.ui.piechart.view.StatisticsPieChartView.java
/** * Creates the chart.//from w w w.ja v a 2s . c o m * * @param dataset * the dataset. * @param loader * the pie chart loader * @param dataRequested * flag indicating if the data have been requested for the current loader and the * current interval * @return the pie chart */ private JFreeChart createChart(PieDataset dataset, String title, IPieChartLoader loader, boolean dataRequested) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, HAS_LEGEND, HAS_TOOLTIPS, HAS_URLS); // legend if (HAS_LEGEND) { LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.LEFT); } // plot PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage( "No data available " + (dataRequested ? "in this time interval" : "yet. Press the Load button.")); plot.setCircular(true); plot.setLabelGenerator(null); // hide labels plot.setBackgroundPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setShadowPaint(Color.WHITE); plot.setBaseSectionPaint(Color.WHITE); StandardPieToolTipGenerator g = (StandardPieToolTipGenerator) plot.getToolTipGenerator(); NumberFormat format = ValueLabelProvider.getActualFormat(loader.getFormat(), getTimeUnit()); StandardPieToolTipGenerator sg = new StandardPieToolTipGenerator(g.getLabelFormat(), format, g.getPercentFormat()); plot.setToolTipGenerator(sg); for (Object o : dataset.getKeys()) { String key = (String) o; plot.setSectionPaint(key, loader.getColor(key).getAwtColor()); } return chart; }
From source file:msi.gama.outputs.layers.ChartLayerStatement.java
private void createSlices(final IScope scope) throws GamaRuntimeException { int i = 0;/* www . java 2 s. co m*/ dataset = new DefaultPieDataset(); final PiePlot plot = (PiePlot) chart.getPlot(); for (final ChartData e : datas) { final String legend = e.getName(); ((DefaultPieDataset) dataset).insertValue(i++, legend, null); history.append(legend); history.append(','); } if (history.length() > 0) { history.deleteCharAt(history.length() - 1); } history.append(Strings.LN); plot.setDataset((DefaultPieDataset) dataset); i = 0; for (final ChartData e : datas) { plot.setSectionPaint(i++, e.getColor()); } plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})")); if (exploded) { for (final Object c : ((DefaultPieDataset) dataset).getKeys()) { plot.setExplodePercent((Comparable) c, 0.20); } } plot.setSectionOutlinesVisible(false); plot.setLabelFont(getLabelFont()); plot.setNoDataMessage("No data available yet"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setInteriorGap(0); }
From source file:semaforo.Semaforo.java
public static void SemaforoGrafico(JFreeChart chart) { // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), Color.BLACK, new Point(400, 200), Color.BLACK)); // customise the title position and font TextTitle t = chart.getTitle();/*from w w w . j a v a 2s. c o m*/ t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 0)); PiePlot plot = null; plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.00); plot.setOutlineVisible(true); // use gradients and white borders for the section colours plot.setBaseSectionOutlinePaint(Color.BLACK); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(0.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 0)); plot.setLabelLinkPaint(Color.BLACK); plot.setLabelLinkStroke(new BasicStroke(0.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(null); plot.setLabelBackgroundPaint(Color.BLACK); plot.setLabelShadowPaint(Color.BLACK); // add a subtitle giving the data source // Mostramos la grafica dentro del jPanel1 panel = new ChartPanel(chart); panel.setBackground(Color.BLACK); panel.repaint(); jPanel3.setLayout(null); jPanel3.setLayout(new java.awt.BorderLayout()); jPanel3.remove(panel); jPanel3.add(panel); jPanel3.repaint(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); jTabbedPane1.setPreferredSize(new Dimension(screenSize.width, screenSize.height)); }
From source file:semaforo.Semaforo.java
public static void editGrafico() { DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2);//from w w w.ja v a 2s . c o m double cfd = 0.0; double bull = 0.0; double bear = 0.0; if (countCfd != 0) cfd = (countCfd * 100) / (countBear + countBull + countCfd); if (countBull != 0) bull = ((countBull * 100) / (countBear + countBull + countCfd)); if (countBear != 0) bear = ((countBear * 100) / (countBear + countBull + countCfd)); Semaforo.l1.setText("CFD (" + String.format("%.2f", cfd) + "%)"); Semaforo.l2.setText("BULL (" + String.format("%.2f", bull) + "%)"); Semaforo.l3.setText("BEAR (" + String.format("%.2f", bear) + "%)"); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("CFD (" + cfd + "%)", new Integer((int) countCfd)); pieDataset.setValue("BULL (" + bull + "%)", new Integer((int) countBull)); pieDataset.setValue("BEAR (" + bear + "%)", new Integer((int) countBear)); JFreeChart chart = null; chart = ChartFactory.createPieChart("", // chart title pieDataset, // data false, // no legend false, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), Color.BLACK, new Point(400, 200), Color.BLACK)); // 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, 0)); PiePlot plot = null; plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.00); plot.setOutlineVisible(true); // use gradients and white borders for the section colours plot.setBaseSectionOutlinePaint(Color.BLACK); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(0.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 0)); plot.setLabelLinkPaint(Color.BLACK); plot.setLabelLinkStroke(new BasicStroke(0.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(null); plot.setLabelBackgroundPaint(Color.BLACK); plot.setLabelShadowPaint(Color.BLACK); // add a subtitle giving the data source // Mostramos la grafica dentro del jPanel1 Semaforo.panel.setChart(chart); }