List of usage examples for org.jfree.chart JFreeChart getPlot
public Plot getPlot()
From source file:net.sf.dynamicreports.test.jasper.chart.MeterChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/* www .jav a 2 s . com*/ JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", MeterPlot.class, plot.getClass()); MeterPlot meterPlot = (MeterPlot) plot; Assert.assertEquals("value", 15, meterPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, meterPlot.getRange().getLowerBound()); Assert.assertEquals("data range high", 30d, meterPlot.getRange().getUpperBound()); Assert.assertEquals("value color", Color.BLUE, meterPlot.getValuePaint()); Assert.assertEquals("value mask", "15.0", meterPlot.getTickLabelFormat().format(15)); Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), meterPlot.getValueFont()); Assert.assertEquals("shape", DialShape.CIRCLE, meterPlot.getDialShape()); Assert.assertEquals("meter angle", 270, meterPlot.getMeterAngle()); Assert.assertEquals("units", "units", meterPlot.getUnits()); Assert.assertEquals("tick interval", 3d, meterPlot.getTickSize()); Assert.assertEquals("background color", Color.LIGHT_GRAY, meterPlot.getDialBackgroundPaint()); Assert.assertEquals("needle color", Color.CYAN, meterPlot.getNeedlePaint()); Assert.assertEquals("tick color", Color.MAGENTA, meterPlot.getTickPaint()); Assert.assertEquals("tick label font", new Font("Courier New", Font.PLAIN, 10), meterPlot.getTickLabelFont()); Assert.assertEquals("intervals size", 2, meterPlot.getIntervals().size()); intervalTest((MeterInterval) meterPlot.getIntervals().get(0), "red", new Color(1f, 0f, 0f, 0.8f), 25d, 30d); intervalTest((MeterInterval) meterPlot.getIntervals().get(1), "yellow", new Color(1f, 1f, 0f, 0.5f), 20d, 25d); }
From source file:org.openmrs.module.usagestatistics.web.view.chart.FoundByChartView.java
@Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { UsageStatisticsService svc = Context.getService(UsageStatisticsService.class); int[] stats = svc.getFoundByStats(getFromDate(), getUntilInclusiveDate(), getLocation(), getUsageFilter()); String labelLink = ContextProvider.getMessage("usagestatistics.foundBy.directLink"); String labelId = ContextProvider.getMessage("usagestatistics.foundBy.idSearch"); String labelName = ContextProvider.getMessage("usagestatistics.foundBy.nameSearch"); double total = stats[0]; DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(labelLink, 100.0 * stats[1] / total); dataset.setValue(labelId, 100.0 * stats[2] / total); dataset.setValue(labelName, 100.0 * stats[3] / total); JFreeChart chart = ChartFactory.createPieChart(null, dataset, false, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setInteriorGap(0.0);//from w w w .jav a2 s .co m plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); plot.setLabelFont(getFont()); return chart; }
From source file:org.jfree.chart.demo.CloneTest1.java
private JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Clone Test 1", "Time", "Value", xydataset, true, true, false);/*from www . ja v a2s . c o m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setAutoRange(true); valueaxis.setFixedAutoRange(60000D); return jfreechart; }
From source file:cgpanalyser.gui.chart.XYChartPanel.java
private int getDomainCrosshairValue(JFreeChart jfreechart) { XYPlot xyplot = (XYPlot) jfreechart.getPlot(); return (int) xyplot.getDomainCrosshairValue(); }
From source file:com.sjsu.uidesign.SystemUsage.java
public SystemUsage() { super();//from ww w .j av a2 s.c om super.setTitle("System Usage"); super.setSize(500, 500); super.setResizable(true); super.setLocationRelativeTo(null); //JLabel usageImage = new JLabel(); //usageImage.setIcon(new ImageIcon("Pie_3.png")); //usageImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sjsu/uidesign/Pie_3.png"))); // NOI18N //add(usageImage); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("System Idle", 30); pieDataset.setValue("System Busy", 70); JFreeChart pieChart = ChartFactory.createPieChart3D("System Usage", pieDataset, true, true, true); Plot Pie = pieChart.getPlot(); ChartPanel piePanel = new ChartPanel(pieChart); JPanel panelPie = new JPanel(); panelPie.removeAll(); panelPie.add(piePanel, BorderLayout.CENTER); panelPie.validate(); add(panelPie); }
From source file:org.operamasks.faces.render.graph.BarChartRenderer.java
protected void setChartStyles(JFreeChart chart, UIChart comp) { super.setChartStyles(chart, comp); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { setBarStyles((CategoryPlot) plot, comp); } else if (plot instanceof XYPlot) { setBarStyles((XYPlot) plot, comp); }// w w w .j a v a 2 s . co m }
From source file:org.jfree.chart.demo.PieChartDemo7.java
/** * Creates a new demo instance./* w w w . j av a 2 s.co m*/ * * @param title the frame title. */ public PieChartDemo7(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 2)); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Section 1", 23.3); dataset.setValue("Section 2", 56.5); dataset.setValue("Section 3", 43.3); dataset.setValue("Section 4", 11.1); JFreeChart chart1 = ChartFactory.createPieChart("Chart 1", dataset, false, false, false); JFreeChart chart2 = ChartFactory.createPieChart("Chart 2", dataset, false, false, false); PiePlot plot2 = (PiePlot) chart2.getPlot(); plot2.setCircular(false); JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false); PiePlot3D plot3 = (PiePlot3D) chart3.getPlot(); plot3.setForegroundAlpha(0.6f); plot3.setCircular(true); JFreeChart chart4 = ChartFactory.createPieChart3D("Chart 4", dataset, false, false, false); PiePlot3D plot4 = (PiePlot3D) chart4.getPlot(); plot4.setForegroundAlpha(0.6f); panel.add(new ChartPanel(chart1)); panel.add(new ChartPanel(chart2)); panel.add(new ChartPanel(chart3)); panel.add(new ChartPanel(chart4)); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:org.openmrs.module.pmtct.web.view.chart.AbstractChartView.java
/** * @see org.springframework.web.servlet.view.AbstractView *//*from w w w . j a v a 2s . co m*/ @Override @SuppressWarnings("unchecked") protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Respond as a PNG image response.setContentType("image/png"); // Disable caching response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); int width = 400; int height = 300; JFreeChart chart = createChart(model, request); chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setOutlineStroke(new BasicStroke(0)); chart.getPlot().setOutlinePaint(getBackgroundColor()); chart.getPlot().setBackgroundPaint(getBackgroundColor()); chart.getPlot().setNoDataMessage("No data available"); ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height); }
From source file:com.googlecode.logVisualizer.chart.PieChartBuilder.java
private JFreeChart createChart(final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart(getTitle(), dataset, isIncludeLegend(), true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); plot.setIgnoreNullValues(true);//w w w .j ava2s . c o m plot.setIgnoreZeroValues(true); return chart; }
From source file:gui.statistics.PieChartTest.java
/** * Creates new form PieChartTest/* ww w . j av a 2 s.com*/ */ public PieChartTest(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); Date a = new Date(2014 - 1900, 11, 1); Date b = new Date(2014 - 1900, 11, 31); DefaultPieDataset data = new DefaultPieDataset(); HashMap<String, BigDecimal> map = Database.getInstance().getTotalExpensesByCategory(a, b); for (String key : map.keySet()) { data.setValue(key, map.get(key).doubleValue()); } JFreeChart pieChart = ChartFactory.createPieChart("PIE CHART", data, true, false, Locale.GERMAN); PiePlot plot = (PiePlot) pieChart.getPlot(); plot.setLabelGenerator(null); BufferedImage pie = pieChart.createBufferedImage(500, 400); setSize(600, 500); jLabel1.setIcon(new ImageIcon(pie)); }