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

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

Introduction

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

Prototype

public void setDataset(int index, XYDataset dataset) 

Source Link

Document

Sets a dataset for the plot and sends a change event to all registered listeners.

Usage

From source file:de.laures.cewolf.taglib.CewolfChartFactory.java

public static JFreeChart getOverlaidChartInstance(String chartType, String title, String xAxisLabel,
        String yAxisLabel, int xAxisType, int yAxisType, List plotDefinitions)
        throws ChartValidationException, DatasetProduceException {
    final int chartTypeConst = getChartTypeConstant(chartType);
    final AxisFactory axisFactory = AxisFactory.getInstance();
    switch (chartTypeConst) {
    case OVERLAY_XY:
        ValueAxis domainAxis = (ValueAxis) axisFactory.createAxis(ORIENTATION_HORIZONTAL, xAxisType,
                xAxisLabel);/*from  w ww.ja  v  a  2  s .  c  o  m*/
        // get main plot
        PlotDefinition mainPlotDef = (PlotDefinition) plotDefinitions.get(0);
        check((Dataset) mainPlotDef.getDataset(), XYDataset.class, chartType);
        XYPlot plot = (XYPlot) mainPlotDef.getPlot(chartTypeConst);
        plot.setDomainAxis(domainAxis);
        plot.setRangeAxis((ValueAxis) axisFactory.createAxis(ORIENTATION_VERTICAL, yAxisType, yAxisLabel));
        //plot.setRenderer(new StandardXYItemRenderer());
        // add second and later datasets to main plot
        for (int plotidx = 1; plotidx < plotDefinitions.size(); plotidx++) {
            PlotDefinition subPlotDef = (PlotDefinition) plotDefinitions.get(plotidx);
            check((Dataset) subPlotDef.getDataset(), XYDataset.class, chartType);
            plot.setDataset(plotidx, (XYDataset) subPlotDef.getDataset());

            int rendererIndex = PlotTypes.getRendererIndex(subPlotDef.getType());
            XYItemRenderer rend = (XYItemRenderer) PlotTypes.getRenderer(rendererIndex);
            plot.setRenderer(plotidx, rend);
        }
        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    case OVERLAY_CATEGORY://added by lrh 2005-07-11
        CategoryAxis domainAxis2 = (CategoryAxis) axisFactory.createAxis(ORIENTATION_HORIZONTAL, xAxisType,
                xAxisLabel);
        // get main plot
        mainPlotDef = (PlotDefinition) plotDefinitions.get(0);
        check((Dataset) mainPlotDef.getDataset(), CategoryDataset.class, chartType);
        CategoryPlot plot2 = (CategoryPlot) mainPlotDef.getPlot(chartTypeConst);
        plot2.setDomainAxis(domainAxis2);
        plot2.setRangeAxis((ValueAxis) axisFactory.createAxis(ORIENTATION_VERTICAL, yAxisType, yAxisLabel));
        //plot.setRenderer(new StandardXYItemRenderer());
        // add second and later datasets to main plot
        for (int plotidx = 1; plotidx < plotDefinitions.size(); plotidx++) {
            PlotDefinition subPlotDef = (PlotDefinition) plotDefinitions.get(plotidx);
            check((Dataset) subPlotDef.getDataset(), CategoryDataset.class, chartType);
            plot2.setDataset(plotidx, (CategoryDataset) subPlotDef.getDataset());

            int rendererIndex = PlotTypes.getRendererIndex(subPlotDef.getType());
            CategoryItemRenderer rend2 = (CategoryItemRenderer) PlotTypes.getRenderer(rendererIndex);
            plot2.setRenderer(plotidx, rend2);
        }
        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot2, true);
    default:
        throw new UnsupportedChartTypeException(chartType + " is not supported.");
    }
}

From source file:osh.comdriver.simulation.cruisecontrol.ScheduleDrawer.java

/**
 * Creates a chart.//from  w  ww.j a  v a 2s  . c  o  m
 *
 * @param dataset1  a dataset.
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset1, //power
        XYDataset dataset2, //costs
        XYDataset dataset3, long time) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("schedule", // title
            "time", // x-axis label
            "power", // y-axis label
            dataset1, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();

    NumberAxis axis1 = new NumberAxis("power");
    NumberAxis axis2 = new NumberAxis("costs");
    axis1.setAutoRangeIncludesZero(true);
    axis1.setUpperBound(5000);
    axis1.setLowerBound(-5000);
    axis2.setAutoRangeIncludesZero(true);
    axis2.setUpperBound(50);
    axis2.setLowerBound(0);
    plot.setRangeAxis(0, axis1);
    plot.setRangeAxis(1, axis2);

    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 0);

    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);
    //TODO: SHADOWS OFF

    final StandardXYItemRenderer r1 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r2 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r3 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r4 = new StandardXYItemRenderer();
    plot.setRenderer(0, r1);
    plot.setRenderer(1, r2);
    plot.setRenderer(2, r3);
    plot.setRenderer(3, r4);

    int numberOfSeries = 0;
    numberOfSeries += dataset1.getSeriesCount();
    numberOfSeries += dataset2.getSeriesCount();
    numberOfSeries += dataset3.getSeriesCount();

    Color[] color = new Color[numberOfSeries];

    for (int i = 0; i < numberOfSeries / 2; i++) {
        color[i] = Color.getHSBColor(i * 1.0f / (numberOfSeries / 2), 1.0f, 1.0f);
    }

    int i = 0;

    for (int j = 0; j < dataset1.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset2.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset3.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }

    // NOW line
    double upperBound = plot.getRangeAxis(1).getUpperBound();
    double lowerBound = plot.getRangeAxis(1).getLowerBound();

    XYSeries nowLine = new XYSeries("now");
    nowLine.add(time * 1000, lowerBound);
    nowLine.add(time * 1000, upperBound);
    XYSeriesCollection nowColl = new XYSeriesCollection(); //power axis
    nowColl.addSeries(nowLine);
    XYDataset nowSet = nowColl;

    plot.setDataset(3, nowSet);
    plot.mapDatasetToRangeAxis(3, 1);

    plot.getRendererForDataset(nowSet).setSeriesPaint(0, Color.DARK_GRAY);
    plot.getRendererForDataset(nowSet).setSeriesStroke(0, (Stroke) new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f));

    plot.setDomainAxis(new DateAxis());
    plot.getDomainAxis().setAutoRange(false);

    long begin = (time / 86400) * 86400 * 1000; //beginning of day
    long end = begin + 86400 * 2 * 1000;

    plot.getDomainAxis().setRange(begin, end);

    return chart;

}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDirectionDataset(600);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", xydataset, true,
            true, false);//from   w  w  w  .j  a v  a2 s. c  o m
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.getDomainAxis().setLowerMargin(0.0D);
    xyplot.getDomainAxis().setUpperMargin(0.0D);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    TickUnits tickunits = new TickUnits();
    tickunits.add(new NumberTickUnit(180D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(90D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(45D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(22.5D, new CompassFormat()));
    numberaxis.setStandardTickUnits(tickunits);
    xyplot.setRangeAxis(numberaxis);
    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    NumberAxis numberaxis1 = new NumberAxis("Force");
    numberaxis1.setRange(0.0D, 12D);
    xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128));
    xyplot.setDataset(1, createForceDataset(600));
    xyplot.setRenderer(1, xyarearenderer);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    return jfreechart;
}

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

private static JFreeChart createChart() {
    OHLCDataset ohlcdataset = createPriceDataset();
    String s = "Sun Microsystems (SUNW)";
    JFreeChart jfreechart = ChartFactory.createHighLowChart(s, "Date", "Price", ohlcdataset, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setLowerMargin(0.01D);//from w w w.j ava  2  s .com
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setLowerMargin(0.59999999999999998D);
    numberaxis.setAutoRangeIncludesZero(false);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    NumberAxis numberaxis1 = new NumberAxis("Volume");
    numberaxis1.setUpperMargin(1.0D);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createVolumeDataset());
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    XYBarRenderer xybarrenderer = new XYBarRenderer();
    xybarrenderer.setDrawBarOutline(false);
    xybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
    xyplot.setRenderer(1, xybarrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    xybarrenderer.setShadowVisible(false);
    xybarrenderer.setBarPainter(new StandardXYBarPainter());
    return jfreechart;
}

From source file:cn.edu.thss.iise.bpmdemo.charts.SWTMultipleAxisDemo1.java

/**
 * Creates the demo chart./*from   www.j  a v  a2  s .  c om*/
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    XYDataset dataset1 = createDataset("Series 1", 100.0, new Day(), 200);

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.BLACK);
    TextTitle subtitle = new TextTitle("Four datasets and four range axes.");
    chart.addSubtitle(subtitle);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);

    // AXIS 2
    NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    XYDataset dataset2 = createDataset("Series 2", 1000.0, new Day(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    // AXIS 3
    NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    // axis3.setPositiveArrowVisible(true);
    plot.setRangeAxis(2, axis3);

    XYDataset dataset3 = createDataset("Series 3", 10000.0, new Day(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);

    // AXIS 4
    NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);

    XYDataset dataset4 = createDataset("Series 4", 25.0, new Day(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);

    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);

    return chart;
}

From source file:org.jfree.chart.swt.demo.SWTMultipleAxisDemo1.java

/**
 * Creates the demo chart.//from   ww  w  .  j  a va 2  s.c  o  m
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.BLACK);
    TextTitle subtitle = new TextTitle("Four datasets and four range axes.");
    chart.addSubtitle(subtitle);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);

    // AXIS 2
    NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    // AXIS 3
    NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    //axis3.setPositiveArrowVisible(true);
    plot.setRangeAxis(2, axis3);

    XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);

    // AXIS 4
    NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);

    XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);

    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);

    return chart;
}

From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset,
        Paint p) {/*from  ww w .  j  a v  a  2 s .co m*/
    plot.setRangeAxis(i, axis);
    plot.setDataset(i, dataset);
    plot.mapDatasetToRangeAxis(i, i);

    XYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setSeriesPaint(0, p);
    axis.setLabelPaint(p);
    axis.setTickLabelPaint(p);
    return renderer;
}

From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkChartTemplate.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    plot.setDataset(0, this.getDataset());
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.setTextAntiAlias(true);//from   w w  w . ja va  2s  . c  om
    //    chart.removeLegend();
    return chart;
}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset(1, 1.0D);
    JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLineAndShapeRenderer Demo 2", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "This chart shows various combinations of the useFillPaint and useOutlinePaint flags.");
    texttitle.setFont(new Font("Dialog", 0, 10));
    jfreechart.addSubtitle(texttitle);//from   www  .  j  av  a 2 s .  c  om
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setSeriesShape(0, double1);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.gray);
    XYDataset xydataset1 = createDataset(2, 2D);
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer();
    xyplot.setDataset(1, xydataset1);
    xyplot.setRenderer(1, xylineandshaperenderer1);
    xylineandshaperenderer1.setSeriesShape(0, double1);
    xylineandshaperenderer1.setSeriesPaint(0, Color.red);
    xylineandshaperenderer1.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer1.setUseFillPaint(true);
    XYDataset xydataset2 = createDataset(3, 3D);
    XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer();
    xyplot.setDataset(2, xydataset2);
    xyplot.setRenderer(2, xylineandshaperenderer2);
    xylineandshaperenderer2.setSeriesShape(0, double1);
    xylineandshaperenderer2.setSeriesPaint(0, Color.red);
    xylineandshaperenderer2.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer2.setUseOutlinePaint(true);
    XYDataset xydataset3 = createDataset(4, 4D);
    XYLineAndShapeRenderer xylineandshaperenderer3 = new XYLineAndShapeRenderer();
    xyplot.setDataset(3, xydataset3);
    xyplot.setRenderer(3, xylineandshaperenderer3);
    xylineandshaperenderer3.setSeriesShape(0, double1);
    xylineandshaperenderer3.setSeriesPaint(0, Color.red);
    xylineandshaperenderer3.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer3.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer3.setUseOutlinePaint(true);
    xylineandshaperenderer3.setUseFillPaint(true);
    XYDataset xydataset4 = createDataset(5, 5D);
    XYLineAndShapeRenderer xylineandshaperenderer4 = new XYLineAndShapeRenderer();
    xyplot.setDataset(4, xydataset4);
    xyplot.setRenderer(4, xylineandshaperenderer4);
    xylineandshaperenderer4.setSeriesShape(0, double1);
    xylineandshaperenderer4.setSeriesPaint(0, Color.red);
    xylineandshaperenderer4.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer4.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer4.setUseOutlinePaint(true);
    xylineandshaperenderer4.setUseFillPaint(true);
    xylineandshaperenderer4.setDrawOutlines(false);
    return jfreechart;
}

From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset, Paint p,
        XYItemRenderer renderer) {//from   ww  w . j av a2  s .  c om
    plot.setRangeAxis(i, axis);
    plot.setDataset(i, dataset);
    plot.mapDatasetToRangeAxis(i, i);

    renderer.setSeriesPaint(0, p);
    axis.setLabelPaint(p);
    axis.setTickLabelPaint(p);
    return renderer;
}