List of usage examples for org.jfree.chart.plot PiePlot3D setInteriorGap
public void setInteriorGap(double percent)
From source file:chart.PieChart3D.java
public static void main(String[] args) throws Exception { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("IPhone 5s", new Double(20)); dataset.setValue("SamSung Grand", new Double(20)); dataset.setValue("MotoG", new Double(40)); dataset.setValue("Nokia Lumia", new Double(10)); JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title dataset, // data true, // include legend true, false);// ww w .jav a 2 s.c o m final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File pieChart3D = new File("pie_Chart3D.jpeg"); ChartUtilities.saveChartAsJPEG(pieChart3D, chart, width, height); }
From source file:statistique.PieChart3D.java
public static void main(String[] args) throws Exception { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("IPhone 5s", new Double(20)); dataset.setValue("SamSung Grand", new Double(20)); dataset.setValue("MotoG", new Double(40)); dataset.setValue("Nokia Lumia", new Double(10)); JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title dataset, // data true, // include legend true, false);//from w ww. j ava 2s . co m final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); int width = 640; /* Width of the image */ int height = 480; /* Height of the image */ File pieChart3D = new File("pie_Chart3D.png"); ChartUtilities.saveChartAsPNG(pieChart3D, chart, width, height); }
From source file:graphic.Grafico.java
private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico, float transparencia, String tipo) { DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < nome.toArray().length; i++) { data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString())); }/* w ww. ja v a 2 s . co m*/ JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true); java.awt.Color cor = new java.awt.Color(200, 200, 200); chart.setBackgroundPaint(cor); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelLinksVisible(true); plot.setNoDataMessage("No existem dados para serem exibidos no grfico"); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(transparencia); plot.setInteriorGap(0.20); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:br.com.ifpb.models.Grafico.java
/** * /* www. j a va2s. com*/ * @param nome * @param valor * @param tituloGrafico * @param transparencia * @param tipo * @return */ private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico, float transparencia, String tipo) { DefaultPieDataset data = new DefaultPieDataset(); for (int i = 0; i < nome.toArray().length; i++) { data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString())); } JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true); java.awt.Color cor = new java.awt.Color(200, 200, 200); chart.setBackgroundPaint(cor); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setLabelLinksVisible(true); plot.setNoDataMessage("No existem dados para serem exibidos "); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(transparencia); plot.setInteriorGap(0.20); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:org.jfree.chart.demo.PieChart3DDemo2.java
/** * Creates a new demo.//from w ww.ja v a 2 s. c o m * * @param title the frame title. */ public PieChart3DDemo2(final String title) { super(title); // create a dataset... final DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Java", new Double(43.2)); data.setValue("Visual Basic", new Double(10.0)); data.setValue("C/C++", new Double(17.5)); data.setValue("PHP", new Double(32.5)); data.setValue("Perl", new Double(12.5)); // create the chart... final JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 2", // chart title data, // data true, // include legend true, false); chart.setBackgroundPaint(Color.yellow); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.33); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); final Rotator rotator = new Rotator(plot); rotator.start(); }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChart3DDemo2.java
/** * Creates a demo chart./* ww w.j a v a2s. c o m*/ * * @param dataset the dataset. * * @return A chart. */ protected JFreeChart createChart(PieDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart title dataset, // dataset !legendPanelOn, // include legend false, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.05); // 0.33 used to work with JFreeChart 1.0.05 for (int i = 0; i < pulloutFlag.length; i++) { //System.out.println("\""+pulloutFlag[i]+"\""); if (pulloutFlag[i].equals("1")) { Comparable key = dataset.getKey(i); plot.setExplodePercent(key, 0.30); } } if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } setCategorySummary(dataset); return chart; }
From source file:UserInterface.ControlManagerRole.ControlManagerWorkAreaJPanel.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: int co2Level = 0; int noxLevel = 0; int comboBoston = 0; int co2Level1 = 0; int noxLevel1 = 0; int comboNewYork = 0; for (Network network : system.getNetworkList()) { if (network.getName().equalsIgnoreCase("boston")) { for (Customer customer : network.getCustomerDirectory().getCustomerDirectory()) { for (Sensor sensor : customer.getSensorDirectory().getSensorDirectory()) { co2Level += sensor.getCurrentEmissionCO2(); noxLevel += sensor.getCurrentEmissionNOx(); }//from w w w .j a v a 2s .c om } } } comboBoston = co2Level + noxLevel; for (Network network : system.getNetworkList()) { if (network.getName().equalsIgnoreCase("New York")) { for (Customer customer : network.getCustomerDirectory().getCustomerDirectory()) { for (Sensor sensor : customer.getSensorDirectory().getSensorDirectory()) { co2Level1 += sensor.getCurrentEmissionCO2(); noxLevel1 += sensor.getCurrentEmissionNOx(); } } } } comboNewYork = co2Level1 + noxLevel1; DefaultPieDataset dataset22 = new DefaultPieDataset(); dataset22.setValue("Fuel Emission by Boston", new Integer(comboBoston)); dataset22.setValue("Fuel Emission by New York ", new Integer(comboNewYork)); JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title dataset22, // data true, // include legend true, false); final PiePlot3D plot = (PiePlot3D) chart22.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparisonbetween two networks", chart22); frame33.setVisible(true); frame33.setSize(500, 400); }
From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java
public void displayChart(Date date1) { int total = 0; int k;//from w ww . j av a 2 s . co m int count = 0; int avg = 0; Sensor s = (Sensor) jTable1.getValueAt(0, 0); Date b = s.getDate(); DateFormat formatter = new SimpleDateFormat("MM/dd/yy"); Date date = new Date(); try { date = formatter.parse("12/11/16"); } catch (Exception e) { } //date = System.out.println(jTable1.getValueAt(0, 5)); System.out.println(jTable1.getValueAt(0, 4)); list = new ArrayList<>(); for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionCO2(); count++; } } avg = total / count; list.add(avg); int avg1 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionCO2(); count++; } } avg = total / count; list.add(avg); for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getNormalCO2(); count++; } } avg1 = total / count; int avg3 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionNOx(); count++; } } avg3 = total / count; int avg4 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getNormalNOx(); count++; } } avg4 = total / count; int avg5 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarCurrentEmissionCO2(); count++; } } avg5 = total / count; int avg6 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarNormalCO2(); count++; } } avg6 = total / count; int avg7 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarCurrentEmissionNOx(); count++; } } avg7 = total / count; int avg8 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarNormalNOx(); count++; } } avg8 = total / count; int combo = avg + avg3; int combo1 = avg5 + avg7; DefaultPieDataset dataset22 = new DefaultPieDataset(); dataset22.setValue("Fuel Emission", new Integer(combo)); dataset22.setValue("Solar Emission ", new Integer(combo1)); JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title dataset22, // data true, // include legend true, false); final PiePlot3D plot = (PiePlot3D) chart22.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparison from different sources", chart22); frame33.setVisible(true); frame33.setSize(500, 400); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(avg, b, "curr CO2"); dataset.setValue(avg1, b, "normal CO2"); dataset.setValue(avg3, b, "current NOx"); dataset.setValue(avg4, b, "normal NOx"); //dataset.setValue(a1,b1,"current"); JFreeChart chart = ChartFactory.createBarChart("Normal Fuel Emission Chart", "CO2 Emission", "in (g/KM)", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Bar Chart for Customer", chart); frame.setVisible(true); frame.setSize(500, 400); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.setValue(avg5, b, "curr CO2"); dataset1.setValue(avg6, b, "normal CO2"); dataset1.setValue(avg7, b, "current NOx"); dataset1.setValue(avg8, b, "normal NOx"); //dataset.setValue(a1,b1,"current"); JFreeChart chart2 = ChartFactory.createBarChart("Solar Emission Chart", "CO2 Emission", "in (g/KM)", dataset1, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p1 = chart.getCategoryPlot(); p1.setRangeGridlinePaint(Color.BLACK); ChartFrame frame1 = new ChartFrame("Bar Chart for Customer", chart2); frame1.setVisible(true); frame1.setSize(500, 400); }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a pie chart with 3D effect./*from ww w . java 2s . c o m*/ * * @return A pie chart. */ private static JFreeChart createPieChart3D() { JFreeChart chart = ChartFactory.createPieChart3D(null, null, false, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderPaint(Color.white); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDarkerSides(true); plot.setBaseSectionOutlinePaint(new Color(0, 0, 0, 0)); plot.setStartAngle(0.0); plot.setInteriorGap(0.10); plot.setLabelGenerator(null); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(Color.white); 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; }