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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer 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:jhplot.HChart.java

/**
 * Add a F1D function to the canvas. Call update() to draw all functions.
 * Use the methods setColor() etc. of F1D function to change the style
 *  If You set range during F1D initialization, it will be used.
 * If not, canvas range is used.//  w  w w  .  ja v  a  2 s .c  om
 * 
 * @param f1d
 *            F1D function
 * 
 */
public void add(F1D f1) {
    int Bin = f1.getPoints();

    if (f1.getMin() == f1.getMax()) {
        f1.eval(Min, Max, Bin);
    } else {
        f1.eval(f1.getMin(), f1.getMax(), Bin); // evaluate
    }

    XYSeriesCollection c = new XYSeriesCollection();
    XYSeries SerData = new XYSeries(f1.getName());
    for (int i = 0; i < Bin; i++)
        SerData.add(f1.getX(i), f1.getY(i));

    c.addSeries(SerData);
    xyplot[N1][N2].setDataset(indexdat[N1][N2], c);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setDrawSeriesLineAsPath(true);
    LinePars lpp = f1.getDrawOption();
    float width = (float) lpp.getPenWidth();
    int style = f1.getLineStyle();
    float dash = lpp.getDashLength();
    renderer.setSeriesStroke(0, getStrokes(style, width, dash));
    renderer.setSeriesPaint(0, f1.getColor());

    type[N1][N2].put(new Integer(indexdat[N1][N2]), "f");
    rdat[N1][N2].add(renderer);
    indexdat[N1][N2]++;

}