Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesPaint

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesPaint.

Prototype

public void setSeriesPaint(int series, Paint paint) 

Source Link

Document

Sets the paint used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:FindHullWindowLogic.java

static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull) {
    panelWhenInside.removeAll();/*from   w w  w . j  a v a 2 s  .  c o  m*/
    panelWhenInside.setLayout(new java.awt.BorderLayout());
    XYSeries seriersAllPoints = new XYSeries("All points");
    addPointsToSeries(seriersAllPoints);

    int pairsNumber = 0;
    if (convexHull != null)
        pairsNumber = convexHull.size() - 1;
    XYSeries covnexHullDivideOnPiars[] = new XYSeries[pairsNumber];

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        covnexHullDivideOnPiars[i] = new XYSeries("Convex hull pair " + i);
    }

    if (convexHull != null) {
        divideOnPairsAndConvertConvexHullIntoSeries(covnexHullDivideOnPiars, convexHull);
    }

    // Add the seriersAllPoints to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriersAllPoints);

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        dataset.addSeries(covnexHullDivideOnPiars[i]);
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3));

    for (int i = 1; i <= covnexHullDivideOnPiars.length; i++) {
        renderer.setSeriesPaint(i, Color.red);
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();
}

From source file:com.imaging100x.tracker.TrackerUtils.java

/**
* Create a frame with a plot of the data given in XYSeries
*//*from   ww  w . j  a va  2 s. co  m*/
public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation,
        int yLocation) {
    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesLinesVisible(0, true);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);
    renderer.setUseFillPaint(true);

    ChartFrame graphFrame = new ChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.setPreferredSize(new Dimension(SIZE, SIZE));
    graphFrame.setResizable(true);
    graphFrame.pack();
    graphFrame.setLocation(xLocation, yLocation);
    graphFrame.setVisible(true);

    dataset.addChangeListener(new DatasetChangeListener() {

        public void datasetChanged(DatasetChangeEvent dce) {
            double xRange = data.getMaxX() - data.getMinX();
            double yRange = data.getMaxY() - data.getMinY();
            double xAvg = (data.getMaxX() + data.getMinX()) / 2;
            double yAvg = (data.getMaxY() + data.getMinY()) / 2;
            double range = xRange;
            if (yRange > range) {
                range = yRange;
            }
            double offset = 0.55 * range;
            plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset);
            plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset);
        }

    });

}

From source file:com.leonarduk.finance.chart.CandlestickChart.java

public static void displayCandlestickChart(final Stock stock) throws IOException {
    final TimeSeries series = TimeseriesUtils.getTimeSeries(stock, 1);

    /**//from ww w. jav a 2  s. co  m
     * Creating the OHLC dataset
     */
    final OHLCDataset ohlcDataset = CandlestickChart.createOHLCDataset(series);

    /**
     * Creating the additional dataset
     */
    final TimeSeriesCollection xyDataset = CandlestickChart.createAdditionalDataset(series);

    /**
     * Creating the chart
     */
    final JFreeChart chart = ChartFactory.createCandlestickChart(stock.getName() + " price", "Time",
            stock.getCurrency(), ohlcDataset, true);
    // Candlestick rendering
    final CandlestickRenderer renderer = new CandlestickRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    // Additional dataset
    final int index = 1;
    plot.setDataset(index, xyDataset);
    plot.mapDatasetToRangeAxis(index, 0);
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesPaint(index, Color.blue);
    plot.setRenderer(index, renderer2);
    // Misc
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setBackgroundPaint(Color.white);
    final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setAutoRangeIncludesZero(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    /**
     * Displaying the chart
     */
    ChartDisplay.displayChartInFrame(chart, 740, 300, "Candlestick Chart");
}

From source file:MainWindowLogic.java

static void drawXYChart(JPanel panelWhenInside, JTable pointsCollector) {
    panelWhenInside.removeAll();/*  w w  w  .  j av a  2  s.  c o  m*/
    panelWhenInside.setLayout(new java.awt.BorderLayout());

    //TODO 
    XYSeries seriersAllPoints = new XYSeries("All points");
    addPointsToSeries(seriersAllPoints, pointsCollector);

    // Add the seriersAllPoints to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriersAllPoints);

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();

}

From source file:org.cyberoam.iview.charts.XYLine.java

/**
 * This method generates JFreeChart instance for XYLine chart with iView customization.
 * @param reportID specifies that for which report Chart is being prepared.
 * @param rsw specifies data set which would be used for the Chart
 * @param requeest used for Hyperlink generation from URL.
 * @return jfreechart instance with iView Customization.
 *//*from www.java2s  .co m*/
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;
    try {
        ReportColumnBean reportColumnBean = null;
        GraphBean graphBean = null;
        DataLinkBean dataLinkBean = null;
        XYDataset dataset = null;
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        XYSeries series = new XYSeries(reportBean.getTitle());
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        String xColumnDBname = reportColumnBean.getDbColumnName();
        String xColumnName = reportColumnBean.getColumnName();
        //Wheather DataLink is Given For X Axis column
        if (reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnDBname = reportColumnBean.getDbColumnName();
        String yColumnName = reportColumnBean.getColumnName();
        //if DataLink is not Given For X Axis column then Check of Y Axis Column
        if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getZColumnId());
        String zColumnDbname = reportColumnBean.getDbColumnName();
        //Preparing DataSet
        String data = "";
        rsw.beforeFirst();
        while (rsw.next()) {
            data = rsw.getString(xColumnDBname);
            series.add(Long.parseLong((data).substring(data.length() - 2)),
                    new Long(rsw.getLong(yColumnDBname)).longValue());
        }
        seriesCollection.addSeries(series);

        dataset = seriesCollection;
        // create the chart...
        chart = ChartFactory.createXYLineChart("", // chart title
                "", // domain axis label
                "", seriesCollection, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );
        /*
         * Additional iView Customization.
         */
        //Set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        //Get a reference to the plot for further customisation...
        XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(new Color(245, 245, 245));
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setForegroundAlpha(0.7f);

        //Set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
            rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4));
        }
        rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        rangeAxis.setTickLabelsVisible(true);
        rangeAxis.setTickMarksVisible(false);
        rangeAxis.setAxisLineVisible(false);

        Axis domainAxis = plot.getDomainAxis();
        domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        domainAxis.setTickMarksVisible(false);
        domainAxis.setAxisLineVisible(false);

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setSeriesPaint(0, Color.DARK_GRAY);
        renderer.setSeriesStroke(0, new BasicStroke(1));
    } catch (Exception e) {
        e.printStackTrace();
    }

    return chart;
}

From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection tempChrData, boolean showlables) {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesVisibleInLegend(0, showlables);
    renderer.setSeriesVisibleInLegend(1, showlables);
    //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false);

    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);//w w  w  .j  av a2 s . co m
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setAutoRangeMinimumSize(0.0000005);
        rangeAxis.setLowerBound(1d);
        //rangeAxis.setAutoRangeIncludesZero(false);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    final Marker thresholdLine = new ValueMarker(0.0000005);
    thresholdLine.setPaint(Color.red);
    if (showlables) {
        thresholdLine.setLabel("P = 510??");
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(false);
    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    chrAxis.setAutoRangeIncludesZero(false);
    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

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);/*w  w  w.j a va  2s.  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:com.jolbox.benchmark.BenchmarkMain.java

/**
 * @param results//from   ww  w. j  a va 2s .c  o m
 * @param delay 
 * @param statementBenchmark 
 * @param noC3P0 
 */
private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int i = 0; i < ConnectionPoolType.values().length; i++) { //
        if (!ConnectionPoolType.values()[i].isEnabled()
                || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) {
            continue;
        }
        XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString());

        for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) {
            series.add(j, results[i][j]);
        }
        dataset.addSeries(series);
    }

    //         Generate the graph
    String title = "Multi-Thread test (" + delay + "ms delay)";
    if (statementBenchmark) {
        title += "\n(with PreparedStatements tests)";
    }
    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            "threads", // x-axis Label
            "time (ns)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.YELLOW);
    renderer.setSeriesPaint(2, Color.BLACK);
    renderer.setSeriesPaint(3, Color.DARK_GRAY);
    renderer.setSeriesPaint(4, Color.MAGENTA);
    renderer.setSeriesPaint(5, Color.RED);
    renderer.setSeriesPaint(6, Color.LIGHT_GRAY);
    //          renderer.setSeriesShapesVisible(1, true);   
    //          renderer.setSeriesShapesVisible(2, true);   

    try {
        String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay
                + "ms-delay";
        if (statementBenchmark) {
            fname += "-with-preparedstatements";
        }
        fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads;
        if (noC3P0) {
            fname += "-noC3P0";
        }
        fname += ".png";
        ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768);
        System.out.println("******* Saved chart to: " + fname);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }

}

From source file:com.jolbox.benchmark.BenchmarkLaunch.java

/**
 * @param results//w  ww  . ja  v a  2 s  .  c o  m
 * @param delay 
 * @param statementBenchmark 
 * @param noC3P0 
 * @throws IOException 
 */
private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0)
        throws IOException {
    String title = "Multi-Thread test (" + delay + "ms delay)";
    if (statementBenchmark) {
        title += "\n(with PreparedStatements tests)";
    }
    String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay
            + "ms-delay";
    if (statementBenchmark) {
        fname += "-with-preparedstatements";
    }
    fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads;
    if (noC3P0) {
        fname += "-noC3P0";
    }
    PrintWriter out = new PrintWriter(new FileWriter(fname + ".txt"));
    fname += ".png";

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int i = 0; i < ConnectionPoolType.values().length; i++) { //
        if (!ConnectionPoolType.values()[i].isEnabled()
                || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) {
            continue;
        }
        XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString());
        out.println(ConnectionPoolType.values()[i].toString());
        for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) {
            series.add(j, results[i][j]);
            out.println(j + "," + results[i][j]);
        }
        dataset.addSeries(series);
    }
    out.close();

    //         Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            "threads", // x-axis Label
            "time (ns)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.YELLOW);
    renderer.setSeriesPaint(2, Color.BLACK);
    renderer.setSeriesPaint(3, Color.DARK_GRAY);
    renderer.setSeriesPaint(4, Color.MAGENTA);
    renderer.setSeriesPaint(5, Color.RED);
    renderer.setSeriesPaint(6, Color.LIGHT_GRAY);
    //          renderer.setSeriesShapesVisible(1, true);   
    //          renderer.setSeriesShapesVisible(2, true);   

    try {
        ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768);
        System.out.println("******* Saved chart to: " + fname);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }

}

From source file:org.gwaspi.reports.PlinkReportLoader.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection seriesCol) {/*from ww  w  .  ja v a 2 s .  c o  m*/
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    subplot.setDomainGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainGridlinePaint(Color.blue);
    subplot.setRangeGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeGridlinePaint(Color.blue);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(true);
    chrAxis.setTickLabelsVisible(true);
    chrAxis.setTickMarksVisible(true);
    chrAxis.setTickUnit(new NumberTickUnit(10000));
    chrAxis.setAutoRangeIncludesZero(false);

    NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis();
    log10Axis.setTickMarkInsideLength(2.0f);
    log10Axis.setTickMarkOutsideLength(2.0f);
    log10Axis.setMinorTickCount(2);
    log10Axis.setMinorTickMarksVisible(true);
    log10Axis.setAxisLineVisible(true);
    log10Axis.setAutoRangeIncludesZero(false);

    XYItemRenderer lblRenderer = subplot.getRenderer();
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome);

    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesItemLabelsVisible(0, true);
    lblRenderer.setSeriesItemLabelsVisible(1, true);

    combinedPlot.add(subplot, 1);
}