List of usage examples for org.jfree.chart JFreeChart getPlot
public Plot getPlot()
From source file:org.operamasks.faces.render.graph.ScatterChartRenderer.java
protected JFreeChart createChart(UIChart comp) { JFreeChart chart = super.createChart(comp); if (chart != null) { Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { LineAndShapeRenderer r = (LineAndShapeRenderer) ((CategoryPlot) plot).getRenderer(); r.setBaseLinesVisible(false); r.setBaseShapesVisible(true); r.setDrawOutlines(false);/* w w w .ja va 2 s .com*/ } else if (plot instanceof XYPlot) { XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) ((XYPlot) plot).getRenderer(); r.setBaseLinesVisible(false); r.setBaseShapesVisible(true); r.setDrawOutlines(false); } } return chart; }
From source file:org.pentaho.chart.plugin.jfreechart.chart.multi.JFreeDefaultMultiChartGenerator.java
protected JFreeChart doCreateChart(ChartDocumentContext chartDocContext, ChartTableModel data) { final JFreeChart chart = createChart(chartDocContext, data, ChartMultiStyle.MULTI); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f);// ww w . j a v a 2s. c o m createRangeAxis(chartDocContext, data, chart); return chart; }
From source file:dbseer.gui.events.InformationChartMouseListener.java
@Override public void chartMouseClicked(ChartMouseEvent event) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); int x = (int) Math.round(xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM)); XYDataset dataset = plot.getDataset(); int maxX = DatasetUtilities.findMaximumDomainValue(dataset).intValue(); if (x >= 1 && x <= maxX) { int seriesCount = dataset.getSeriesCount(); int[] mixtures = new int[seriesCount - 1]; int total = 0; for (int i = 0; i < seriesCount - 1; ++i) { mixtures[i] = (int) dataset.getYValue(i, x - 1); total += mixtures[i];/*w w w. j av a 2s .c o m*/ } for (int i = 0; i < seriesCount - 1; ++i) { mixtures[i] = (int) Math.round((double) mixtures[i] / (double) total * 100.0); tpsMixturePanel.setMixture(i, mixtures[i]); } } }
From source file:org.nbrcp.demo.core.views.Scatterplot.java
private void setUpView() { JFreeChart chart = ChartFactory.createScatterPlot("", "X", "Y", Data.getDataset()); XYPlot plot = (XYPlot) chart.getPlot(); Shape dotShape = new Ellipse2D.Double(0, 0, 5, 5); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesShape(0, dotShape); final ChartPanel panel = new ChartPanel(chart, true); panel.setMinimumDrawHeight(10);/*from w ww. j a v a 2s .c o m*/ panel.setMaximumDrawHeight(2000); panel.setMinimumDrawWidth(10); panel.setMaximumDrawWidth(2000); panel.setSize(this.getSize()); this.add(panel); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.RingChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final RingPlot ringPlot = (RingPlot) chart.getPlot(); ringPlot.setSectionDepth(sectionDepth); }
From source file:de.xirp.chart.ChartManager.java
/** * Returns a bar chart. The chart is generated from the given * {@link de.xirp.db.Record} and key array. The * record is evaluated from the given start to the given stop * time, or is evaluated completely if the flag * <code>origTime</code> is set to <code>true</code>. * /*w w w . ja v a 2 s . co m*/ * @param record * The record containing the data. * @param keys * The keys to use. * @param start * The start time. * @param stop * The stop time. * @param origTime * A flag indicating if the original time should be * used. * @return A bar chart. * @see org.jfree.chart.JFreeChart * @see de.xirp.db.Record */ private static JFreeChart createBarChart(Record record, String[] keys, long start, long stop, boolean origTime) { String chartTitle = createChartTitle(record, keys); List<Observed> all = new ArrayList<Observed>(); TimeSeriesCollection dataset = createTimeSeriesAndFillAllObservedList(all, record, keys, origTime, start, stop); JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, I18n.getString("ChartManager.text.time"), //$NON-NLS-1$ true, I18n.getString("ChartManager.text.value"), dataset, PlotOrientation.VERTICAL, true, true, //$NON-NLS-1$ false); XYPlot plot = (XYPlot) chart.getPlot(); setXYPlot(plot, new Date(record.getStart())); exportAutomatically(all, chart); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.PieChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from ww w . j a v a2s.c o m*/ JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("plot", PiePlot.class, plot.getClass()); Assert.assertFalse("circular", ((PiePlot) plot).isCircular()); Assert.assertEquals("label format", "label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLabelGenerator()).getLabelFormat()); Assert.assertEquals("legend label format", "legend label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLegendLabelGenerator()).getLabelFormat()); chart = getChart("summary.chart2", 0); plot = chart.getPlot(); Assert.assertNull("label format", ((PiePlot) plot).getLabelGenerator()); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartDialog.java
public ChartDialog(JFreeChart chart) { this(chart.getPlot()); }
From source file:net.sf.dynamicreports.test.jasper.chart.Pie3DChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w . ja va2 s .c o m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("plot", PiePlot3D.class, plot.getClass()); Assert.assertTrue("circular", ((PiePlot) plot).isCircular()); Assert.assertEquals("label format", "label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLabelGenerator()).getLabelFormat()); Assert.assertEquals("legend label format", "legend label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLegendLabelGenerator()).getLabelFormat()); Assert.assertEquals("depth factor", 0.5, ((PiePlot3D) plot).getDepthFactor()); chart = getChart("summary.chart2", 0); plot = chart.getPlot(); Assert.assertNull("label format", ((PiePlot) plot).getLabelGenerator()); }
From source file:systeminformation.Chart.java
public JFreeChart create3DPieChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("", dataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); p.setLabelGenerator(gen);/*from w ww. j a v a 2 s.c om*/ // p.setSimpleLabels(true); p.setForegroundAlpha(0.5f); p.setBackgroundAlpha(0.2f); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); chart.setBorderVisible(true); return chart; }