List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:org.jfree.chart.demo.MouseListenerDemo3.java
public void chartMouseClicked(ChartMouseEvent chartmouseevent) { org.jfree.chart.entity.ChartEntity chartentity = chartmouseevent.getEntity(); if (chartentity != null && (chartentity instanceof LegendItemEntity)) { LegendItemEntity legenditementity = (LegendItemEntity) chartentity; @SuppressWarnings("rawtypes") Comparable comparable = legenditementity.getSeriesKey(); XYPlot xyplot = (XYPlot) chart.getPlot(); XYDataset xydataset = xyplot.getDataset(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); for (int i = 0; i < xydataset.getSeriesCount(); i++) { xyitemrenderer.setSeriesStroke(i, new BasicStroke(1.0F)); if (xydataset.getSeriesKey(i).equals(comparable)) xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0F)); }/*from w w w . j ava 2 s . c o m*/ } }
From source file:lifnetwork.ChartSave.java
public ChartSave() { super(ChartFactory.createScatterPlot("Population Fire", "Time (s)", "Neuron #", (new XYSeriesCollection()), PlotOrientation.VERTICAL, false, false, false)); fireChart = this.getChart(); fireChart.setNotify(false);/* ww w .j av a 2 s. c o m*/ XYPlot plot = fireChart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new Rectangle2D.Double(0, 0, 1, 1)); fireCollection = (XYSeriesCollection) plot.getDataset(); fireSeries = new XYSeries("fires"); fireCollection.addSeries(fireSeries); }
From source file:org.jfree.chart.demo.LineChartDemo3.java
/** * Creates a chart./*from w w w. j a va 2 s . c om*/ * * @param dataset a dataset. * * @return A chart based on the supplied dataset. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 3", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:com.jml.main.Graph.java
public void drawScatterPlot(String title, XYDataset xYDataset) { JFreeChart chart = ChartFactory.createScatterPlot(title, "X axis label", "Y axis label", xYDataset); XYPlot plot = chart.getXYPlot(); Random random = new Random(); for (int i = 0; i < dataset.getSeriesCount(); ++i) { plot.getRenderer().setSeriesPaint(i, new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))); }//from w w w . j av a 2s . c o m panel = new ChartPanel(chart); this.add(panel); this.pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.SimpleScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);/* w w w . j a v a 2 s . c o m*/ Font font = new Font("Tahoma", Font.BOLD, titleDimension); //TextTitle title = new TextTitle(name, font); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); int seriesN = dataset.getSeriesCount(); if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = (Color) colorMap.get(serieName); if (color != null) { renderer.setSeriesPaint(i, color); } } } // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); if (legend == true) { drawLegend(chart); } return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.XyAreaChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w w w. ja v a2 s . co m*/ JFreeChart chart = getChart("summary.chart1", 0); Axis axis = chart.getXYPlot().getDomainAxis(); XYPlot plot = chart.getXYPlot(); Assert.assertEquals("renderer", XYAreaRenderer.class, plot.getRenderer().getClass()); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart2", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:org.codehaus.mojo.chronos.chart.HistogramChartGenerator.java
protected final JFreeChart createHistogramChart(ResponsetimeSamples samples, String label, ResourceBundle bundle, ReportConfig config) { HistogramDataset histogramdataset = new HistogramDataset(); double[] sampleArray = samples.extractResponsetimes(config.getResponsetimedivider()); histogramdataset.addSeries(label, sampleArray, BINS); HistogramDataset dataset = histogramdataset; JFreeChart chart = ChartFactory.createHistogram(bundle.getString("chronos.label.histogram"), bundle.getString("chronos.label.histogram.x"), bundle.getString("chronos.label.histogram.y"), dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setForegroundAlpha(FOREGROUND_ALPHA); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); if (config.isShowpercentile()) { String label1 = bundle.getString("chronos.label.percentile95.arrow"); double value = samples.getPercentile95(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label1, value); }//from www .j av a 2 s . co m if (config.isShowaverage()) { String label2 = bundle.getString("chronos.label.average.arrow"); double value = samples.getAverage(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label2, value); } return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.ScatterPlotChartExpression.java
protected JFreeChart computeXYChart(final XYDataset xyDataset) { final JFreeChart chart; if (xyDataset instanceof TimeSeriesCollection) { chart = ChartFactory.createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, isShowLegend(), false, false); final XYPlot xyPlot = chart.getXYPlot(); final XYLineAndShapeRenderer itemRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(itemRenderer.getBaseToolTipGenerator()); renderer.setURLGenerator(itemRenderer.getURLGenerator()); xyPlot.setRenderer(renderer);/*from w w w .j a v a2 s . co m*/ } else { final PlotOrientation orientation = computePlotOrientation(); chart = ChartFactory.createScatterPlot(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false); } chart.getXYPlot().setRenderer(new XYDotRenderer()); configureLogarithmicAxis(chart.getXYPlot()); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.XyBarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/* w ww .j av a2 s. co m*/ JFreeChart chart = getChart("summary.chart1", 0); XYPlot plot = chart.getXYPlot(); Assert.assertEquals("renderer", XYBarRenderer.class, plot.getRenderer().getClass()); Assert.assertTrue("show labels", plot.getRenderer().getBaseItemLabelsVisible()); //Assert.assertFalse("show tick labels", plot.getDomainAxis().isTickMarksVisible()); //Assert.assertFalse("show tick marks", plot.getDomainAxis().isTickLabelsVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:org.rioproject.examples.hospital.ui.PatientStatsPanel.java
private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataSet, Color color) { JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataSet, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, color); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setRange(0, 150);//from w ww . java 2s .c o m ValueAxis xAxis = plot.getDomainAxis(); xAxis.setAutoRange(true); xAxis.setFixedAutoRange(5 * MINUTE); return chart; }