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

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

Introduction

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

Prototype

public void setSeriesStroke(int series, Stroke stroke) 

Source Link

Document

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

Usage

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

public static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Normal Distribution Demo 2", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainZeroBaselineVisible(true);
    xyplot.setRangeZeroBaselineVisible(true);
    xyplot.setDomainPannable(true);/*from w  w  w .j a v  a2s. com*/
    xyplot.setRangePannable(true);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setDrawSeriesLineAsPath(true);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.5F));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F }, 0.0F));
    xylineandshaperenderer.setSeriesStroke(2,
            new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F, 3F, 3F }, 0.0F));
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 4F, 4F }, 0.0F));
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(" = -2.0, \262 = 0.5", -2D,
            0.56399999999999995D, 3.9269908169872414D);
    xypointerannotation.setLabelOffset(4D);
    xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
    xypointerannotation.setBackgroundPaint(Color.yellow);
    xyplot.addAnnotation(xypointerannotation);
    XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation(" = 0.0, \262 = 0.2",
            0.22500000000000001D, 0.80000000000000004D, 0.0D);
    xypointerannotation1.setLabelOffset(4D);
    xypointerannotation1.setTextAnchor(TextAnchor.CENTER_LEFT);
    xypointerannotation1.setBackgroundPaint(new Color(0, 0, 255, 63));
    xyplot.addAnnotation(xypointerannotation1);
    XYPointerAnnotation xypointerannotation2 = new XYPointerAnnotation(" = 0.0, \262 = 1.0", 0.75D,
            0.29999999999999999D, 5.497787143782138D);
    xypointerannotation2.setLabelOffset(4D);
    xypointerannotation2.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    xypointerannotation2.setBackgroundPaint(new Color(255, 0, 0, 63));
    xyplot.addAnnotation(xypointerannotation2);
    XYPointerAnnotation xypointerannotation3 = new XYPointerAnnotation(" = 0.0, \262 = 5.0", 3D,
            0.074999999999999997D, 4.7123889803846897D);
    xypointerannotation3.setLabelOffset(4D);
    xypointerannotation3.setTextAnchor(TextAnchor.BOTTOM_CENTER);
    xypointerannotation3.setBackgroundPaint(new Color(0, 255, 0, 63));
    xyplot.addAnnotation(xypointerannotation3);
    return jfreechart;
}

From source file:org.encog.workbench.dialogs.activation.EquationPanel.java

/**
 * Creates a line chart using the data from the supplied dataset.
 *
 * @param dataset  the dataset./*from  www.j  av  a  2 s.c  o m*/
 *
 * @return The chart.
 */
public static JFreeChart createChart(XYDataset dataset, ActivationFunction activation, boolean normal) {

    String title;

    if (normal) {
        title = activation.getClass().getSimpleName();
    } else {
        if (activation.hasDerivative()) {
            title = "Derv of " + activation.getClass().getSimpleName();
        } else {
            title = "NO Derv of " + activation.getClass().getSimpleName();
        }
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, "input (x)", "output (y)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

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

    if (normal) {

        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainPannable(true);
        plot.setRangePannable(true);
        ValueAxis xAxis = plot.getDomainAxis();
        xAxis.setLowerMargin(0.0);
        xAxis.setUpperMargin(0.0);
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        r.setDrawSeriesLineAsPath(true);
        r.setSeriesStroke(0, new BasicStroke(1.5f));
        r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f }, 0.0f));
        r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f));
        r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 4.0f, 4.0f }, 0.0f));
    }

    return chart;
}

From source file:MainWindowLogic.java

static void drawXYChart(JPanel panelWhenInside, JTable pointsCollector) {
    panelWhenInside.removeAll();//from   w  w w  . j a v  a2  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:com.che.software.testato.util.jfreechart.LineChartGraphistUtil.java

/**
 * Colorized and transforms a given JFreeChart.
 * /*from  w  w w  .  j ava 2  s. com*/
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @param lineChart the given chart.
 * @param maxAbscissaValue the max abscissa value of the chart.
 * @param xValues the x axis values list.
 * @param yValues the y axis values list.
 * @param xExcludedValues the x axis excluded values.
 * @param yExcludedValues the y axis excluded values.
 * @return the transformed chart.
 * @since August, 2011.
 */
public static JFreeChart getColorizedChartFromChart(JFreeChart lineChart, double maxAbscissaValue,
        List<MatrixResult> xValues, List<MatrixResult> yValues, List<MatrixResult> xExcludedValues,
        List<MatrixResult> yExcludedValues) {
    LOGGER.debug("getColorizedChartFromChart().");
    lineChart.setBackgroundPaint(Color.WHITE);
    XYPlot plot = (XYPlot) lineChart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesStroke(2, new BasicStroke(2));
    renderer.setSeriesStroke(3, new BasicStroke(2));
    renderer.setSeriesShapesVisible(2, false);
    renderer.setSeriesShapesVisible(3, false);
    renderer.setSeriesPaint(0,
            ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1], ColorUtil.BLUE_COLOR[2]));
    renderer.setSeriesPaint(1, ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
            ColorUtil.ORANGE_COLOR[2]));
    renderer.setSeriesPaint(2, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    renderer.setSeriesPaint(3, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.setRenderer(renderer);
    XYTextAnnotation low = new XYTextAnnotation(
            LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_LOW_NAME), (0.5 * maxAbscissaValue) - 1,
            maxAbscissaValue + 1),
            medium = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_MEDIUM_NAME),
                    (1.5 * maxAbscissaValue) - 2, maxAbscissaValue + 1),
            high = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_HIGH_NAME),
                    1.5 * maxAbscissaValue, maxAbscissaValue - 2);
    low.setFont(ColorUtil.TITLE_FONT);
    medium.setFont(ColorUtil.TITLE_FONT);
    high.setFont(ColorUtil.TITLE_FONT);
    low.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    medium.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    high.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.addAnnotation(low);
    plot.addAnnotation(medium);
    plot.addAnnotation(high);
    for (int i = 0; i < xValues.size(); i++) {
        XYTextAnnotation itemLabel = new XYTextAnnotation(xValues.get(i).getScriptLabel(),
                (yValues.get(i).getPercentage() * 100), (xValues.get(i).getPercentage() * 100) + 0.5);
        itemLabel.setFont(ColorUtil.DEFAULT_FONT);
        itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1],
                ColorUtil.BLUE_COLOR[2]));
        plot.addAnnotation(itemLabel);
    }
    if (null != xExcludedValues) {
        for (int j = 0; j < xExcludedValues.size(); j++) {
            XYTextAnnotation itemLabel = new XYTextAnnotation(xExcludedValues.get(j).getScriptLabel(),
                    (yExcludedValues.get(j).getPercentage() * 100),
                    (xExcludedValues.get(j).getPercentage() * 100) + 0.5);
            itemLabel.setFont(ColorUtil.DEFAULT_FONT);
            itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
                    ColorUtil.ORANGE_COLOR[2]));
            plot.addAnnotation(itemLabel);
        }
    }
    return lineChart;
}

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  w w w  .  j  av  a  2 s .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.jfree.graphics2d.demo.SVGChartWithAnnotationsDemo1.java

/**
 * Creates a sample chart.// w  w w. j a va2s  . c o m
 *
 * @param dataset  a dataset for the chart.
 *
 * @return A sample chart.
 */
private static JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million",
            dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    xAxis.setLowerMargin(0.2);
    xAxis.setUpperMargin(0.2);
    xAxis.setStandardTickUnits(createStandardDateTickUnits());

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLowerMargin(0.2);
    yAxis.setUpperMargin(0.2);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseLinesVisible(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
    renderer.setSeriesShape(1, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5.0f,
            new float[] { 10.0f, 5.0f }, 0.0f));
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesFillPaint(1, Color.white);
    renderer.setUseFillPaint(true);

    renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);

    renderer.addAnnotation(new XYDrawableAnnotation(new Month(4, 2005).getFirstMillisecond(), 600, 180, 100,
            3.0, createPieChart()));
    renderer.addAnnotation(new XYDrawableAnnotation(new Month(9, 2007).getFirstMillisecond(), 1250, 120, 100,
            2.0, createBarChart()));
    plot.setRenderer(renderer);
    return chart;
}

From source file:io.sanfran.wikiTrends.extraction.plots.PlotTimeSeries.java

private static JFreeChart createChart(XYDataset dataset, String title) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "Date", // x-axis label
            "Page visits", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*w  w w.j  a v  a 2s.  co m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    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);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false); // if you want visible dots -> true
        renderer.setBaseShapesFilled(false); // if you want visible dots -> true

        if (seriesWidth != null) {
            for (int i = 0; i < seriesWidth.size(); i++) {
                renderer.setSeriesStroke(i, new BasicStroke(seriesWidth.get(i)));
            }
        }
        if (seriesColor != null) {
            for (int i = 0; i < seriesColor.size(); i++) {
                renderer.setSeriesPaint(i, seriesColor.get(i));
            }
        }

    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));

    return chart;

}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million",
            xydataset, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);//www.  java  2s. c  o  m
    xyplot.setRangePannable(true);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setLowerMargin(0.20000000000000001D);
    dateaxis.setUpperMargin(0.20000000000000001D);
    dateaxis.setStandardTickUnits(createStandardDateTickUnits());
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setLowerMargin(0.20000000000000001D);
    numberaxis.setUpperMargin(0.20000000000000001D);
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseLinesVisible(true);
    xylineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    xylineandshaperenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1, 5F, new float[] { 10F, 5F }, 0.0F));
    xylineandshaperenderer.setSeriesFillPaint(0, Color.white);
    xylineandshaperenderer.setSeriesFillPaint(1, Color.white);
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xylineandshaperenderer.setDefaultEntityRadius(6);
    xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(4, 2005)).getFirstMillisecond(),
            600D, 180D, 100D, 3D, createPieChart()));
    xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(9, 2007)).getFirstMillisecond(),
            1250D, 120D, 100D, 2D, createBarChart()));
    xyplot.setRenderer(xylineandshaperenderer);
    return jfreechart;
}

From source file:FindHullWindowLogic.java

static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull) {
    panelWhenInside.removeAll();/* w  ww.  j  a  v a 2  s  . c om*/
    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:simulador.controle.GraficoCategorias.java

private static void renderizarGrafico(JFreeChart grafico) {

    if (DEBUG) {/*from  ww  w  . j  a  v a  2  s.c  o m*/
        System.out.println("GraficoRadiais.renderizarGrafico");
    }

    XYLineAndShapeRenderer renderizador = new XYLineAndShapeRenderer();
    int qtdSeries, aux;

    qtdSeries = grafico.getXYPlot().getDataset().getSeriesCount();
    //aux = (Color.WHITE.getRGB() - Color.BLACK.getRGB())/qtdSeries;   
    aux = 360 / qtdSeries;

    //System.out.println("aux = "+aux);
    for (int i = 0; i < qtdSeries; i++) {
        renderizador.setSeriesPaint(i, new Color(Color.HSBtoRGB((aux * i) / 360.0f, 1.0f, 1.0f)));
        renderizador.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    //renderizador.setSeriesLinesVisible(0, false);

    grafico.getXYPlot().setRenderer(renderizador);

}