List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.XYLineAndShapePlot.java
@Override protected void applyRendering(XYPlot plot) { NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, DATA_COLOR); //Unfortunately, the tooltips are not visible, when the graph gets rendered as a PNG StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator() { private static final long serialVersionUID = -5803780142385784897L; @Override//from w w w . ja v a2 s . c om public String generateToolTip(XYDataset dataset, int series, int item) { return new StringBuilder(BUILD).append(dataset.getXValue(series, item)).append(COLON) .append(dataset.getYValue(series, item)).toString(); } }; renderer.setBaseToolTipGenerator(toolTipGenerator); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL,//from w w w . ja v a 2 s .c o m // !legendPanelOn, false, // no legend true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:net.sourceforge.openforecast.examples.ForecastingChartDemo.java
/** * A demonstration application showing a quarterly time series * along with the forecast values.// w ww. ja v a 2s. co m * @param title the frame title. */ public ForecastingChartDemo(String title) { super(title); // Create a title... String chartTitle = "OpenForecast Demo"; XYDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Quarterly Sales (Units sold)", dataset, true, // Legend true, // Tooltips false);// URLs XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; r.setPlotShapes(true); r.setDefaultShapesFilled(Boolean.TRUE); } ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:celeste.Celeste.java
public void generarGrafica(XYSeriesCollection coleccion, boolean shapes) { JFreeChart grafica;/*from w ww.j av a 2s.c o m*/ grafica = ChartFactory.createXYLineChart("", "", "", coleccion, PlotOrientation.HORIZONTAL, true, true, false); // configuracion de la grafica XYPlot xyplot = (XYPlot) grafica.getPlot(); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); int n = coleccion.getSeriesCount(); for (int l = 1; l < n; l = l + 2) { xylineandshaperenderer.setSeriesShape(l, new Ellipse2D.Double(-3 + l, -3 + l, 15, 15)); xylineandshaperenderer.setSeriesShapesVisible(l, shapes); } //generacion ventana grafica ChartPanel Panel = new ChartPanel(grafica); JFrame Ventana = new JFrame("JFreeChart"); Ventana.getContentPane().add(Panel); Ventana.pack(); Ventana.setVisible(true); Ventana.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); }
From source file:net.sourceforge.openforecast.examples.ExponentialSmoothingChartDemo.java
/** * A demonstration application showing a quarterly time series * along with the forecast values.//from w w w . j a va 2 s . c o m * @param title the frame title. */ public ExponentialSmoothingChartDemo(String title) { super(title); // Create a title... String chartTitle = "OpenForecast Demo"; XYDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Quarterly Sales (Units sold)", dataset, true, // Legend true, // Tooltips false);// URLs XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; r.setPlotShapes(true); r.setDefaultShapesFilled(Boolean.TRUE); } ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo2.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);/*from w w w . j a va2s . co m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // setXSummary(dataset); //X is time renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperBubbleChart.java
/** * Creates a chart.//from w w w. j a v a 2 s .c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(XYZDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, // chart titl rangeLabel, // y axis label domainLabel, // x axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator()); // 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.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:org.jgrasstools.gears.utils.chart.Scatter.java
private void setShapeLinesVisibility(XYPlot plot) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); int seriesCount = plot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesShapesVisible(i, showShapes); renderer.setSeriesLinesVisible(i, showLines); }// w w w . j a v a 2 s.c o m }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3.java
protected JFreeChart createLegend(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, domainLabel, rangeLabel, dataset, true, true, false);/*from ww w . j a v a 2 s. c om*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer; rr.setBaseShapesVisible(true); rr.setBaseShapesFilled(true); } renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java
protected JFreeChart createLegend(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // url );// w ww . j a v a 2s . co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); plot.setRenderer(renderer); return chart; }