List of usage examples for org.jfree.chart.plot PiePlot3D setForegroundAlpha
public void setForegroundAlpha(float alpha)
From source file:com.indicator_engine.controller.GraphController.java
private JFreeChart createPieChart(final PieDataset pdSet, final String chartTitle) { JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, pdSet, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290);//from w ww . j av a 2 s. c o m plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); return chart; }
From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java
@Override protected JFreeChart createChart() { // create the chart... pieDataSet = createDataset();/*from w ww . jav a2s.co m*/ final JFreeChart chart = ChartFactory.createPieChart3D("", // chart // title pieDataSet, // data false, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.getTitle().setPaint(new Color(0x5E5E5E)); chart.setBorderVisible(false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setOutlineVisible(false); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setStartAngle(290); plot.setBackgroundPaint(Color.white); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new JFreeChartLabelCustom()); final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { final Comparable key = (Comparable) keys.get(i); plot.setSectionPaint(key, Color.decode( "0x" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length])); } // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
private void drawGraph(String name, Integer[] responses) { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Answer 1", responses[0].doubleValue()); dataset.setValue("Answer 2", responses[1].doubleValue()); dataset.setValue("Answer 3", responses[2].doubleValue()); JFreeChart chart = ChartFactory.createPieChart3D(name, dataset, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f); plot.setCircular(true);/*ww w.j a v a 2 s . co m*/ final JFreeChartWrapper chartP = new JFreeChartWrapper(chart); GridLayout diagramLayout = new GridLayout(2, 2); diagramLayout.setSpacing(true); diagramLayout.setMargin(true); diagramLayout.setSizeFull(); diagramLayout.addComponent(chartP); diagramPanel.setContent(diagramLayout); }
From source file:com.esofthead.mycollab.ui.chart.PieChartWrapper.java
@Override protected JFreeChart createChart() { // create the chart... pieDataSet = createDataset();// w ww .j a va 2 s .c o m final JFreeChart chart = ChartFactory.createPieChart3D("", // chart // title pieDataSet, // data false, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.getTitle().setPaint(new Color(0x5E5E5E)); chart.setBorderVisible(false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setOutlineVisible(false); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setStartAngle(290); plot.setBackgroundPaint(Color.white); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new JFreeChartLabelCustom()); final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { final Comparable key = (Comparable) keys.get(i); int colorIndex = i % CHART_COLOR_STR.size(); plot.setSectionPaint(key, Color.decode("0x" + CHART_COLOR_STR.get(colorIndex))); } // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:Vista.CuentasCobrar.java
private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title dataset, // data true, // include legend true, false);// w ww. j a va2s .c om //chart.getLegend(); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); return chart; }
From source file:fuel.gui.stats.MotorStatsPanel.java
private void refreshGraphs(Motorcycle motor) { graphContainer.removeAll();// ww w .j a v a 2 s. co m if (motor != null) { DefaultPieDataset usageDataset = new DefaultPieDataset(); try { ResultSet thisMotor = database .Query("SELECT SUM(distance) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); ResultSet otherMotors = database.Query( "SELECT SUM(distance) FROM fuelrecords WHERE NOT motorcycleId = " + motor.getId(), true); thisMotor.next(); otherMotors.next(); usageDataset.setValue(motor.toString(), thisMotor.getInt("1")); usageDataset.setValue("Andere motoren", otherMotors.getInt("1")); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart usagePiechart = ChartFactory.createPieChart3D("", usageDataset, true, true, false); PiePlot3D plot3 = (PiePlot3D) usagePiechart.getPlot(); plot3.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel usagePiechartPanel = new ChartPanel(usagePiechart); usagePiechartPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Motorgebruik"))); usagePiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); usagePiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset stationDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet numberStations = database.Query( "SELECT DISTINCT stationId FROM fuelrecords WHERE stationId = " + station.getId(), true); if (numberStations.next()) { ResultSet otherMotors = database.Query("SELECT COUNT(*) FROM fuelrecords WHERE stationId = " + station.getId() + " AND motorcycleId = " + motor.getId(), true); otherMotors.next(); if (otherMotors.getInt("1") > 0) { stationDataset.setValue(station.toString(), otherMotors.getInt("1")); } } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart stationPiechart = ChartFactory.createPieChart3D("", stationDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) stationPiechart.getPlot(); plot2.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel stationPiechartPanel = new ChartPanel(stationPiechart); stationPiechartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Tankstation verhouding"))); stationPiechartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); stationPiechartPanel.setLayout(new BorderLayout()); DefaultPieDataset fuelDataset = new DefaultPieDataset(); try { ResultSet numberResults = database.Query("SELECT DISTINCT typeOfGas FROM fuelrecords", true); while (numberResults.next()) { ResultSet thisStation = database.Query( "SELECT SUM(liter) FROM fuelrecords WHERE typeOfGas = '" + numberResults.getString("typeOfGas") + "'AND motorcycleId = " + motor.getId(), true); thisStation.next(); if (thisStation.getDouble("1") > 0) { fuelDataset.setValue(numberResults.getString("TYPEOFGAS"), thisStation.getDouble("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot1 = (PiePlot3D) fuelPieChart.getPlot(); plot1.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel fuelPieChartPanel = new ChartPanel(fuelPieChart); fuelPieChartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Brandstof verhouding"))); fuelPieChartPanel.setPreferredSize(new java.awt.Dimension(240, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database .Query("SELECT distance/liter,date FROM fuelrecords WHERE motorcycleId = " + motor.getId() + " ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("DATE"), "Verbruik"); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart barChart = ChartFactory.createBarChart3D("", // chart title "", // domain axis label "Aantal", // range axis label barDataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = barChart.getCategoryPlot(); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); ChartPanel barChartPanel = new ChartPanel(barChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder("Verbruik")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); barChartPanel.setLayout(new BorderLayout()); JPanel piePanel = new JPanel(new GridLayout(0, 3)); piePanel.add(usagePiechartPanel); piePanel.add(stationPiechartPanel); piePanel.add(fuelPieChartPanel); //uitgaven DefaultPieDataset expensesDataset = new DefaultPieDataset(); try { Map<String, ResultSet> allCosts = new HashMap<String, ResultSet>(); ResultSet fuelCosts = database .Query("SELECT SUM(cost) FROM fuelrecords WHERE motorcycleId = " + motor.getId(), true); allCosts.put("Brandstof", fuelCosts); ResultSet expenses = database.Query("SELECT DISTINCT categoryid FROM expenses", true); while (expenses.next()) { ResultSet set = database.Query("SELECT SUM(costs) FROM expenses WHERE categoryid = " + expenses.getInt("categoryid") + " AND motorcycleid = " + motor.getId(), true); ResultSet set2 = database .Query("SELECT name FROM categories WHERE id = " + expenses.getInt("categoryid"), true); set2.next(); allCosts.put(set2.getString("name"), set); } for (Map.Entry<String, ResultSet> element : allCosts.entrySet()) { element.getValue().next(); if (element.getValue().getInt("1") > 0) { expensesDataset.setValue(element.getKey(), element.getValue().getInt("1")); } } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart expensesPiechart = ChartFactory.createPieChart3D("", expensesDataset, true, true, false); PiePlot3D plot4 = (PiePlot3D) expensesPiechart.getPlot(); plot4.setForegroundAlpha(0.6f); JPanel expensesPiePanel = new ChartPanel(expensesPiechart); expensesPiePanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Uitgaven"))); expensesPiePanel.setPreferredSize(new java.awt.Dimension(240, 240)); expensesPiePanel.setLayout(new BorderLayout()); graphContainer.add(piePanel); graphContainer.add(barChartPanel); graphContainer.add(expensesPiePanel); } revalidate(); repaint(); }
From source file:org.squale.squaleweb.util.graph.PieChartMaker.java
/** * Factorisation du code commun la gnration du graphe * /* www . j a v a 2 s. c om*/ * @param pRequest la requte * @return graphe de type Bubble */ private JFreeChart getCommonChart(HttpServletRequest pRequest) { JFreeChart chart = ChartFactory.createPieChart3D(mTitle, mDataSet, false, false, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); final double startAngle = 290D; pieplot3d.setStartAngle(startAngle); final float depthFactor = 0.1f; pieplot3d.setDepthFactor(depthFactor); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foregroundAlpha = 0.5f; pieplot3d.setForegroundAlpha(foregroundAlpha); // Si on est en anglais, on laisse les nombre formates avec des "," pour sparer les milliers // Si on est en francais on remplace les "," par des points NumberFormat numberFormat = SqualeWebActionUtils.getNumberFormat(pRequest); // Pour le formatter de %, on laisse celui par dfaut pieplot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} loc ({2})", numberFormat, NumberFormat.getPercentInstance())); return chart; }
From source file:org.adempiere.webui.dashboard.CalendarWindow.java
private void syncModel() { Hashtable<String, BigDecimal> ht = new Hashtable<String, BigDecimal>(); List<?> list = calendars.getModel().get(calendars.getBeginDate(), calendars.getEndDate(), null); int size = list.size(); for (Iterator<?> it = list.iterator(); it.hasNext();) { String key = ((ADCalendarEvent) it.next()).getR_RequestType_ID() + ""; if (!ht.containsKey(key)) ht.put(key, BigDecimal.ONE); else {/*from w w w .j a va 2 s.c om*/ BigDecimal value = ht.get(key); ht.put(key, value.add(BigDecimal.ONE)); } } Hashtable<Object, String> htTypes = new Hashtable<Object, String>(); for (int i = 0; i < lbxRequestTypes.getItemCount(); i++) { Listitem li = lbxRequestTypes.getItemAtIndex(i); if (li != null && li.getValue() != null) htTypes.put(li.getValue(), li.getLabel()); } DefaultPieDataset pieDataset = new DefaultPieDataset(); Enumeration<?> keys = ht.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); BigDecimal value = ht.get(key); String name = (String) htTypes.get(key); pieDataset.setValue(name == null ? "" : name, new Double(size > 0 ? value.doubleValue() / size * 100 : 0)); } JFreeChart chart = ChartFactory.createPieChart3D(Msg.getMsg(Env.getCtx(), "EventsAnalysis"), pieDataset, true, true, true); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(600, 250); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("Pie Chart", bytes); myChart.setContent(image); } catch (IOException e) { e.printStackTrace(); } htTypes = null; ht = null; }
From source file:Forms.SalesChart.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed DefaultPieDataset pieDataset = new DefaultPieDataset(); String conString = "jdbc:mysql://localhost:3306/nafis"; String username = "root"; String passward = ""; String sql = "SELECT * FROM sold"; try {/*from www . j av a 2 s .c o m*/ Connection con = (Connection) DriverManager.getConnection(conString, username, passward); Statement s = (Statement) con.prepareStatement(sql); ResultSet rs = s.executeQuery(sql); HashMap<String, Integer> map = new HashMap<String, Integer>(); while (rs.next()) { String name = rs.getString(2); String stock = rs.getString(3); String type = rs.getString(8); Integer oldVal = map.get(type); //System.out.println(oldVal); if (oldVal == null) { map.put(type, Integer.parseInt(stock)); } else { map.put(type, oldVal + Integer.parseInt(stock)); } } for (HashMap.Entry m : map.entrySet()) { //System.out.println(m.getKey()+" "+m.getValue()); pieDataset.setValue(m.getKey() + "", Integer.parseInt(m.getValue() + "")); } } catch (Exception e) { e.printStackTrace(); } JFreeChart chart = ChartFactory.createPieChart3D("pie chart", pieDataset, true, true, false); PiePlot3D p = (PiePlot3D) chart.getPlot(); p.setStartAngle(0); p.setDirection(Rotation.CLOCKWISE); p.setForegroundAlpha(0.5f); p.getBackgroundPaint(); ChartFrame frame = new ChartFrame("Pie Chart", chart); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setSize(750, 600); }
From source file:Interfaz.ClienteReporte.java
public ClienteReporte(ClienteVentana parent) { this.parent = parent; initComponents();//from w w w .ja v a2 s .c o m setLocationRelativeTo(null); // Fuente de Datos defaultpiedataset = new DefaultPieDataset(); defaultpiedataset.setValue("Total de Tickets Liberados", (Integer.parseInt(lrecibidos.getText()) - Integer.parseInt(lefectivos.getText()))); defaultpiedataset.setValue("Tickets Atendidos Satisfactoriamente", Integer.parseInt(lefectivos.getText())); //defaultpiedataset.setValue("Hacking", new Double(19.5D)); //defaultpiedataset.setValue("SEO", new Double(30.5D)); //defaultpiedataset.setValue("Redes", new Double(2.0D)); // Creando el Grafico chart = ChartFactory.createPieChart3D("Mi Proporcin", defaultpiedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); pieplot3d.setDepthFactor(0.5); pieplot3d.setStartAngle(290D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.5F); // Mostrar Grafico chartPanel = new ChartPanel(chart); chartPanel.setBounds(0, 0, 314, 270); jpGrafico.add(chartPanel); this.setVisible(true); }