List of usage examples for org.jfree.chart.plot PiePlot3D setForegroundAlpha
public void setForegroundAlpha(float alpha)
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserDiskSpace.java
/** Builds and lays out the GUI. */ void buildGUI() { data.removeAll();/* w w w. j a v a 2 s . co m*/ DiskQuota quota = view.isDiskSpaceLoaded(); if (quota != null) { DefaultPieDataset dataset = new DefaultPieDataset(); long free = quota.getAvailableSpace(); long used = quota.getUsedSpace(); if (free < 0 || used < 0) { buildChartNotAvailable(); return; } dataset.setValue("Free " + UIUtilities.formatFileSize(free), free); dataset.setValue("Used " + UIUtilities.formatFileSize(used), used); try { JFreeChart chart = ChartFactory.createPieChart3D("", dataset, false, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.55f); data.add(new ChartPanel(chart), BorderLayout.CENTER); } catch (Exception e) { buildChartNotAvailable(); } } else { JXBusyLabel busyLabel = new JXBusyLabel(); busyLabel.setBackground(UIUtilities.BACKGROUND_COLOR); busyLabel.setEnabled(true); busyLabel.setBusy(true); JPanel p = UIUtilities.buildComponentPanelCenter(busyLabel); p.setBackground(UIUtilities.BACKGROUND_COLOR); data.add(p, BorderLayout.CENTER); } revalidate(); repaint(); }
From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.chartdemo.MultiAPIChartDemo.java
/** * Creates a sample chart.//from www .j a v a 2 s .c o m * * @return A chart. */ private JFreeChart createChart(final int year) { final JFreeChart chart = ChartFactory.createPieChart3D("Programming Language of the Year " + year, // chart title createSampleDataset(), // data true, // include legend true, false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); // plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChart3DDemo1.java
/** * Creates a sample chart.//w w w . ja v a 2 s .com * * @param dataset the dataset. * * @return A chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); /* 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); } }*/ plot.setNoDataMessage("No data to display"); if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } setCategorySummary(dataset); return chart; }
From source file:taller.GraficoTorta.java
public GraficoTorta(int posX, int posY, double[] datos, String[] labels, String titulo) { super(""); try {// w ww .j a v a2 s . c om DefaultPieDataset defaultpiedataset = new DefaultPieDataset(); for (int i = 0; i < datos.length; i++) defaultpiedataset.setValue(labels[i], datos[i]); JFreeChart jfreechart = ChartFactory.createPieChart3D(titulo, defaultpiedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setDarkerSides(true); pieplot3d.setStartAngle(0D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.75F); pieplot3d.setNoDataMessage("No hay Datos que Mostrar"); jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(300, 300)); setContentPane(jpanel); pack(); RefineryUtilities.centerFrameOnScreen(this); } catch (Exception e) { } }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChart3DDemo3.java
/** * Creates a sample chart.//from www .j a v a2 s .co m * * @param dataset the dataset. * * @return A chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new CustomPieSectionLabelGenerator()); 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:fuel.gui.stats.StationStatsPanel.java
private void refreshGraphs() { graphContainer.removeAll();// www . j a va 2 s.c o m DefaultPieDataset usageDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet thisStation = database .Query("SELECT SUM(liter) FROM fuelrecords WHERE stationId = " + station.getId(), true); thisStation.next(); usageDataset.setValue(station.toString(), thisStation.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("Tankstation verhouding"))); usagePieChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); 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") + "'", true); thisStation.next(); fuelDataset.setValue(numberResults.getString("typeOfGas"), thisStation.getInt("1")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) fuelPieChart.getPlot(); plot2.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(320, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database.Query("SELECT cost/liter,date FROM fuelrecords ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("date"), "Prijs per liter"); } } 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("Prijs per liter")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); JPanel piePanel = new JPanel(new GridLayout(0, 2)); piePanel.add(usagePieChartPanel); piePanel.add(fuelPieChartPanel); graphContainer.add(piePanel); graphContainer.add(barChartPanel); revalidate(); repaint(); }
From source file:org.jfree.chart.demo.PieChart3DDemo2.java
/** * Creates a new demo./*w w w .j a v a 2s . c om*/ * * @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:org.pentaho.reporting.engine.classic.demo.ancient.demo.chartdemo.TableJFreeChartDemo.java
/** * Creates a sample chart.// ww w.jav a2 s. c o m * * @return A chart. */ private JFreeChart createChart(final int year, final int[] votes) { final JFreeChart chart = ChartFactory.createPieChart3D("Programming Language of the Year " + (year), // chart title createSampleDataset(votes), // data true, // include legend true, false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); // plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChart3DDemo2.java
/** * Creates a demo chart./*w w w. j a v a 2 s . 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:de.suse.swamp.modules.scheduledjobs.Statistics.java
/** * Generating the frontpage graph that shows the total amount of different wf types *//* ww w . ja v a2 s .com*/ protected void generateFrontpageGraph() { // count the number of workflows of each type: List names = wfman.getWorkflowTemplateNames(); DefaultPieDataset dataset = new DefaultPieDataset(); int wfcount = 0; for (Iterator it = names.iterator(); it.hasNext();) { String template = (String) it.next(); PropertyFilter templatefilter = new PropertyFilter(); templatefilter.addWfTemplate(template); int count = wfman.getWorkflowIds(templatefilter, null).size(); if (count > 0) { dataset.setValue(template, new Double(count)); } wfcount += count; } // only generate graph if workflows exist if (wfcount > 0) { JFreeChart chart = ChartFactory.createPieChart3D("Workflows inside SWAMP", dataset, false, false, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.6f); File image = new File(statPath + fs + "workflows.png"); if (image.exists()) image.delete(); try { ChartUtilities.saveChartAsPNG(image, chart, 500, 350); } catch (java.io.IOException exc) { Logger.ERROR("Error writing image to file: " + exc.getMessage()); } } }