Example usage for org.jfree.chart StandardLegend setDisplaySeriesLines

List of usage examples for org.jfree.chart StandardLegend setDisplaySeriesLines

Introduction

In this page you can find the example usage for org.jfree.chart StandardLegend setDisplaySeriesLines.

Prototype

public void setDisplaySeriesLines(boolean flag) 

Source Link

Document

Sets a flag that controls whether or not the legend displays the series line stroke.

Usage

From source file:hr.restart.util.chart.ChartXYZ.java

/**
  * Creates a LINE CHART./*  w w w.  j  a  v a2  s. c om*/
  * 
  * @param dataset The org.jfree.data.CategoryDataset
  * @param title The title
  * @return org.jfree.chart.JFreeChart
  */
final private JFreeChart createLineChart(final CategoryDataset dataset, String title) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart(title, // chart title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    //print the subtitles
    java.util.List subs = getSubtitles();
    if (subs != null)
        for (int i = 0; i < subs.size(); i++) {
            chart.addSubtitle(new TextTitle(subs.get(i).toString()));
        }

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    final StandardLegend legend = (StandardLegend) chart.getLegend();
    legend.setDisplaySeriesShapes(true);
    legend.setShapeScaleX(1.5);
    legend.setShapeScaleY(1.5);
    legend.setDisplaySeriesLines(true);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //plot.setBackgroundPaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setDrawShapes(true);
    adjustLineRenderer(renderer);

    //        renderer.setSeriesStroke(
    //            0, new BasicStroke(
    //                2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                1.0f, new float[] {10.0f, 6.0f}, 0.0f
    //            )
    //        );
    //        renderer.setSeriesStroke(
    //            1, new BasicStroke(
    //                2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                1.0f, new float[] {6.0f, 6.0f}, 0.0f
    //            )
    //        );
    //        renderer.setSeriesStroke(
    //            2, new BasicStroke(
    //                2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                1.0f, new float[] {2.0f, 6.0f}, 0.0f
    //            )
    //        );
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
}