| package agent.lastTest; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| import java.io.*; |
| import org.jfree.chart.*; |
| import org.jfree.chart.plot.PiePlot3D; |
| import org.jfree.data.general.DefaultPieDataset; |
| import java.awt.image.BufferedImage; |
| |
| public class PieChartWrapper { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| private DefaultPieDataset data; |
| private JFreeChart chart; |
| private String chartTitle = ""; |
| private boolean dataChanged = false; |
| |
| |
| public PieChartWrapper () { |
| data = new DefaultPieDataset(); |
| } |
| |
| |
| |
| |
| |
| public void setTitle (String title) { |
| chartTitle = title; |
| } |
| |
| |
| |
| |
| |
| public void addData (String label, double value) { |
| data.setValue(label, new Double(value)); |
| dataChanged = true; |
| } |
| |
| |
| |
| |
| |
| public void clearData () { |
| data = new DefaultPieDataset(); |
| dataChanged = true; |
| } |
| |
| |
| private void createChart () { |
| if ((chart == null) || dataChanged) { |
| chart = ChartFactory.createPieChart3D(chartTitle, data, true, false, false); |
| |
| PiePlot3D pieplot3d = (PiePlot3D)chart.getPlot(); |
| pieplot3d.setForegroundAlpha(0.5F); |
| dataChanged = false; |
| } |
| } |
| |
| |
| |
| |
| |
| public BufferedImage getAsBufferedImage (int width, int height) { |
| createChart(); |
| return chart.createBufferedImage (width, height); |
| } |
| |
| |
| |
| |
| |
| |
| public void sendToJpgFile (String fileName, int width, int height) |
| throws FileNotFoundException, IOException { |
| createChart(); |
| NotesChartHelper.sendToJpgFile(chart, fileName, width, height); |
| } |
| |
| |
| |
| |
| |
| |
| |
| public void displayAsDialog (int width, int height) { |
| createChart(); |
| NotesChartHelper.displayAsDialog(chart, chartTitle, width, height); |
| } |
| } |
| |
| |