List of usage examples for org.jfree.chart.plot PiePlot setOutlineVisible
public void setOutlineVisible(boolean visible)
From source file:org.sonar.server.charts.deprecated.PieChart.java
private void applyParams() { applyCommonParams();/* ww w .ja va2 s.com*/ configureColors(params.get(CHART_PARAM_COLORS)); addMeasures(params.get(CHART_PARAM_VALUES)); // -- Plot PiePlot plot = (PiePlot) jfreechart.getPlot(); plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE)) && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE))); }
From source file:uom.research.thalassemia.util.PieChartCreator.java
/** * Creates a chart.// www . ja v a 2 s. c om * * @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:org.talend.dataprofiler.chart.ChartDecorator.java
/** * /*from w ww . j av a2 s. c o m*/ * DOC qiongli Comment method "decoratePiePlot". * * @param chart */ private static void decoratePiePlot(JFreeChart chart) { Font font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$ TextTitle textTitle = chart.getTitle(); // MOD msjian TDQ-5213 2012-5-7: fixed NPE if (textTitle != null) { textTitle.setFont(font); } setLegendFont(chart); // TDQ-5213~ PiePlot plot = (PiePlot) chart.getPlot(); font = new Font("Monospaced", Font.PLAIN, 10);//$NON-NLS-1$ plot.setLabelFont(font); plot.setNoDataMessage("No data available"); //$NON-NLS-1$ StandardPieSectionLabelGenerator standardPieSectionLabelGenerator = new StandardPieSectionLabelGenerator( ("{0}:{2}"), //$NON-NLS-1$ NumberFormat.getNumberInstance(), new DecimalFormat(PERCENT_FORMAT)); plot.setLabelGenerator(standardPieSectionLabelGenerator); plot.setLabelLinkPaint(Color.GRAY); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelGap(0.02D); plot.setOutlineVisible(false); plot.setMaximumLabelWidth(0.2D); plot.setCircular(false); // remove the shadow of the pie chart plot.setShadowXOffset(0); plot.setShadowYOffset(0); }
From source file:org.gephi.desktop.context.ContextPieChart.java
public ContextPieChart() { data = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null);//from w ww. j ava2 s . c o m chart.setPadding(new RectangleInsets(0, 0, 0, 0)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.WHITE); plot.setLabelGap(0.5); plot.setCircular(true); plot.setInteriorGap(0); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222)); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD)); chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false); ((FlowLayout) chartPanel.getLayout()).setHgap(0); ((FlowLayout) chartPanel.getLayout()).setVgap(0); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); }
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.// www . j a v a 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:org.gephi.desktop.partition.PartitionPie.java
public void setup(Partition partition) { data = new DefaultPieDataset(); for (Part p : partition.getParts()) { data.setValue(p.getDisplayName(), p.getPercentage()); }/*from w w w. j av a 2 s .co m*/ final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); //plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.BLACK); //plot.setLabelGap(0.05); plot.setCircular(true); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); for (Part p : partition.getParts()) { plot.setSectionPaint(p.getDisplayName(), p.getColor()); } chartPanel = new ChartPanel(chart, true); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); add(chartPanel, BorderLayout.CENTER); }
From source file:ch.zhaw.init.walj.projectmanagement.util.chart.PieChart.java
/** * creates the pie chart//from w ww.jav a 2s. c o m * @throws NumberFormatException * @throws IOException */ public void createChart() throws NumberFormatException, IOException { // create dataset with used and remaining budget DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("spent", con.getUsedBudget(project)); dataset.setValue("remaining", con.getRemainingBudget(project)); // create chart JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false); // set color and style PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("remaining", new Color(0, 101, 166)); plot.setSectionPaint("spent", new Color(0, 62, 102)); plot.setLabelGenerator(null); plot.setBackgroundPaint(Color.WHITE); plot.setShadowXOffset(0); plot.setShadowYOffset(0); plot.setOutlineVisible(false); plot.setInteriorGap(0); // set size and save it as JPEG int width = 350; /* Width of the image */ int height = 350; /* Height of the image */ File pieChart = new File(path + "/Charts/BudgetProject" + project.getID() + ".jpg"); ChartUtilities.saveChartAsJPEG(pieChart, chart, width, height); }
From source file:com.rapidminer.template.gui.RoleRequirementSelector.java
private JFreeChart makeChart(ExampleSet exampleSet, Attribute att) { DefaultPieDataset pieDataset = new DefaultPieDataset(); if (att.isNominal()) { for (String val : att.getMapping().getValues()) { pieDataset.setValue(val, exampleSet.getStatistics(att, Statistics.COUNT, val)); }// w w w.j a v a 2s.com } JFreeChart chart = ChartFactory.createPieChart(null, pieDataset, true, false, false); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setFrame(BlockBorder.NONE); chart.setBackgroundImageAlpha(0.0f); chart.setBorderVisible(false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setShadowPaint(null); plot.setOutlineVisible(false); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); plot.setCircular(true); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a pie chart./*from ww w . j av a 2 s.c o m*/ * * @return A pie chart. */ private static JFreeChart createPieChart() { JFreeChart chart = ChartFactory.createPieChart(null, null, false, true, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setInteriorGap(0.06); plot.setStartAngle(0.0); plot.setLabelGenerator(null); plot.setBaseSectionOutlinePaint(Color.white); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setLabelPadding(RectangleInsets.ZERO_INSETS); plot.setLabelFont(new Font("Dialog", Font.PLAIN, 12)); plot.setLabelPaint(Color.darkGray); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{2}")); return chart; }
From source file:com.polivoto.vistas.Charts.java
private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); DefaultPieDataset data = new DefaultPieDataset(); // Fuente de Datos for (Opcion opc : opciones) { data.setValue(opc.getNombre(), opc.getCantidad()); }/*from ww w . j a va2 s. co m*/ // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS false); chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Roboto", 0, 28)); // Crear el Panel del Grafico con ChartPanel ChartPanel chartPanel = new ChartPanel(chart); PiePlot plot = (PiePlot) chart.getPlot(); Rectangle bounds = panel.getBounds(); chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height); panel.add(chartPanel); plot.setLabelGenerator(null); plot.setBackgroundPaint(Color.white); plot.setOutlineVisible(false); //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}"); //plot.setLabelGenerator(labels); plot.setBaseSectionOutlinePaint(Color.white); plot.setShadowXOffset(0); plot.setShadowYOffset(0); //#7cb5ec,#f45b5b,#90ed7d,#434348, //#f7a35c,#8085e9,#f15c80,#e4d354, //#2b908f,#91e8e1 Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125), new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128), new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) }; PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, data); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); Font nwfont = new Font("Roboto", 0, 18); legend.setItemFont(nwfont); legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white)); legend.setBackgroundPaint(Color.WHITE); legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0)); //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5); //legend.setItemLabelPadding(padding); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}")); plot.setLegendItemShape(new Rectangle(25, 25)); return panel; }