Example usage for org.jfree.chart.plot XYPlot getRenderer

List of usage examples for org.jfree.chart.plot XYPlot getRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRenderer.

Prototype

public XYItemRenderer getRenderer() 

Source Link

Document

Returns the renderer for the primary dataset.

Usage

From source file:org.spf4j.perf.impl.chart.Charts.java

private static JFreeChart createJFreeChart(final String chartName, final String uom,
        final XYDataset timeseriescollection) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(chartName, "Time", uom, timeseriescollection,
            true, true, false);/*from  ww  w  .  ja  va2 s. c  om*/
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setVerticalTickLabels(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator("Tooltip {0}"));
    return jfreechart;
}

From source file:org.jfree.chart.demo.RelativeDateFormatDemo2.java

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("RelativeDateFormat Demo 2", "Date ", true,
            "Time To Complete", intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);
    DateAxis dateaxis = new DateAxis();
    RelativeDateFormat relativedateformat = new RelativeDateFormat();
    relativedateformat.setShowZeroDays(false);
    relativedateformat.setSecondFormatter(new DecimalFormat("00"));
    dateaxis.setDateFormatOverride(relativedateformat);
    xyplot.setRangeAxis(dateaxis);// ww  w  .  j a v  a2s  . com
    return jfreechart;
}

From source file:org.jfree.chart.demo.selection.SelectionDemo1.java

/**
 * Creates a chart.//from ww  w.j a v a  2s  . com
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices", "Date", "Price Per Unit", dataset);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setBaseShapesVisible(true);
    r.setBaseShapesFilled(true);
    r.setUseFillPaint(true);
    r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
    r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));

    //add selection specific rendering
    IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);

    //register plot as selection change listener
    ext.addChangeListener(plot);

    return chart;
}

From source file:org.jfree.chart.demo.selection.SelectionDemo8.java

/**
 * Creates a chart./*from  w  w  w .  j a v  a2 s .c om*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices", "Date", "Price Per Unit", dataset);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setBaseShapesVisible(true);
    r.setBaseShapesFilled(true);
    r.setUseFillPaint(true);
    r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
    r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));

    r.setDrawOutlines(true);

    //add selection specific rendering
    IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);

    //register plot as selection change listener
    ext.addChangeListener(plot);

    return chart;
}

From source file:org.jfree.chart.demo.TimeSeriesDemo14.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Bug Report Submissions for Java", "Date",
            "Evaluation ID", xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
        xylineandshaperenderer.setUseFillPaint(true);
        xylineandshaperenderer.setBaseFillPaint(Color.white);
    }/*from   ww  w .  j  a  v a  2  s . c  o m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    return jfreechart;
}

From source file:org.jfree.chart.demo.RelativeDateFormatDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Exercise Chart", "Elapsed Time",
            "Beats Per Minute", xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }//from  ww  w  .j a v  a  2s  .c  om
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    Minute minute = new Minute(0, 9, 1, 10, 2006);
    RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond());
    relativedateformat.setSecondFormatter(new DecimalFormat("00"));
    dateaxis.setDateFormatOverride(relativedateformat);
    return jfreechart;
}

From source file:org.jfree.expdemo.SelectionDemo1.java

/**
 * Creates a chart./* ww w .ja v a2s .  c  o m*/
 * 
 * @param dataset
 *            a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension ext) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setBaseShapesVisible(true);
    r.setBaseShapesFilled(true);
    r.setUseFillPaint(true);
    r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
    r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));

    //add selection specific rendering
    IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;

}

From source file:org.jfree.chart.demo.YieldCurveDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield",
            xydataset, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15);
    xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime()));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }//from  www.j  av a 2 s  .  com
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    jfreechart.addSubtitle(new TextTitle("November 2005"));
    TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm");
    texttitle.setFont(new Font("Dialog", 0, 9));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

From source file:org.jfree.chart.demo.CrosshairDemo4.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Crosshair Demo 4", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}

From source file:org.jfree.chart.demo.selection.SelectionDemo4.java

/**
 * Creates a chart.// w w  w .ja va2  s .  c o m
 * 
 * @param dataset  a dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(IntervalXYDataset dataset, DatasetSelectionExtension<XYCursor> ext) {
    JFreeChart chart = ChartFactory.createHistogram("SelectionDemo4", null, null, dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setForegroundAlpha(0.85f);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setDefaultOutlinePaint(Color.red);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(renderer, ext, Color.white);

    //register plot as selection change listener
    ext.addChangeListener(plot);

    return chart;
}