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:democsv.XYLineChart_AWT.java

public XYLineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);//from  ww  w  . j  a  v a 2  s  . c  o m
    setContentPane(chartPanel);
}

From source file:com.mycompany.istudy.principalservices.GraphicalView.java

/**
 * Overwrites the method of createXYLineChart from ChartFactory interface
 * and creates a XYLine Chart.//from ww  w.  j  a  va  2s  . com
 * @param applicationTitle
 * @param chartTitle
 * @param investedHoursPerWeek
 * @param hoursToBeInvested 
 */
public GraphicalView(String applicationTitle, String chartTitle, Map<Double, Double> investedHoursPerWeek,
        Map<Double, Double> hoursToBeInvested) {
    super(applicationTitle);
    xylineChart = ChartFactory.createXYLineChart(chartTitle, "Calender Weeks", "Invested Study-hours",
            createDataset(investedHoursPerWeek, hoursToBeInvested), PlotOrientation.VERTICAL, true, true,
            false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);
}

From source file:graficarfreechart.GraficarFreeChart.java

public GraficarFreeChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);/*from  w  w  w  .j a  v  a  2  s  .c om*/
    setContentPane(chartPanel);
}

From source file:cs.register.geraGrafico.java

public geraGrafico(String title, int type, List<partida> L) {
    super(title);
    JFreeChart chart = null;//from w  ww.  j  a va2  s . co m
    switch (type) {
    case 0:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakill(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 1:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakda(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 2:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datawld(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 3:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datasocore(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 4:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datarank(L), PlotOrientation.VERTICAL, true,
                true, false);

    }
    graf = new ChartPanel(chart);
    graf.setPreferredSize(new java.awt.Dimension(560, 367));
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer rendrer = new XYLineAndShapeRenderer();
    rendrer.setSeriesPaint(0, Color.GREEN);
    rendrer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(rendrer);
    setContentPane(graf);

}

From source file:de.atomfrede.tools.evalutation.tools.plot.TimePlot.java

@Override
protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) {
    XYDatasetWrapper mainDataset = datasetWrappers[0];

    JFreeChart chart = ChartFactory.createTimeSeriesChart(mainDataset.getSeriesName(), "Time",
            mainDataset.getSeriesName(), mainDataset.getDataset(), true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    // all adjustments for first/main dataset
    plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum());
    plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum());
    // some additional "design" stuff for the plot
    plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor());
    plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke()));

    for (int i = 1; i < datasetWrappers.length; i++) {
        XYDatasetWrapper wrapper = datasetWrappers[i];
        plot.setDataset(i, wrapper.getDataset());
        chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName());

        NumberAxis axis = new NumberAxis(wrapper.getSeriesName());
        plot.setRangeAxis(i, axis);/*from  www  .j a v  a 2s. c o  m*/
        plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);

        plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0);
        plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0);
        // map the second dataset to the second axis
        plot.mapDatasetToRangeAxis(i, i);

        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setBaseShapesVisible(false);
        renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke()));
        plot.setRenderer(i, renderer);
        plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor());
    }
    // change the background and gridline colors
    plot.setBackgroundPaint(Color.white);
    plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // format the date axis
    DateAxis axis = (DateAxis) plot.getDomainAxis();

    axis.setDateFormatOverride(new SimpleDateFormat("dd.MM HH:mm"));
    axis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1));
    axis.setVerticalTickLabels(true);
    return chart;
}

From source file:de.atomfrede.tools.evalutation.tools.plot.custom.CustomSimplePlot.java

@Override
protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) {
    XYDatasetWrapper mainDataset = datasetWrappers[0];

    JFreeChart chart = ChartFactory.createXYLineChart(mainDataset.getSeriesName(), "Index",
            mainDataset.getSeriesName(), mainDataset.getDataset(), PlotOrientation.VERTICAL, true, false,
            false);/* ww  w  .  j  a  v a 2s  .com*/

    XYPlot plot = (XYPlot) chart.getPlot();
    // all adjustments for first/main dataset
    plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum());
    plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum());
    // some additional "design" stuff for the plot
    plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor());
    plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke()));

    for (int i = 1; i < datasetWrappers.length; i++) {
        XYDatasetWrapper wrapper = datasetWrappers[i];
        plot.setDataset(i, wrapper.getDataset());
        chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName());

        NumberAxis axis = new NumberAxis(wrapper.getSeriesName());
        plot.setRangeAxis(i, axis);
        plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);

        plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0);
        plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0);
        // map the second dataset to the second axis
        plot.mapDatasetToRangeAxis(i, i);

        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setBaseShapesVisible(false);
        renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke()));
        plot.setRenderer(i, renderer);
        plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor());
    }
    // change the background and gridline colors
    plot.setBackgroundPaint(Color.white);
    plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    return chart;
}

From source file:com.spotify.heroic.http.render.RenderUtils.java

public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title,
        Map<String, String> highlight, Double threshold, int height) {
    final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true);
    final DeviationRenderer intervalRenderer = new DeviationRenderer();

    final XYSeriesCollection regularData = new XYSeriesCollection();
    final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection();

    int lineAndShapeCount = 0;
    int intervalCount = 0;

    for (final ShardedResultGroup resultGroup : groups) {
        final MetricCollection group = resultGroup.getMetrics();

        if (group.getType() == MetricType.POINT) {
            final XYSeries series = new XYSeries(resultGroup.getMetrics().toString());

            final List<Point> data = group.getDataAs(Point.class);

            for (final Point d : data) {
                series.add(d.getTimestamp(), d.getValue());
            }//from  w  w  w .j a  v a  2 s . co  m

            lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE);
            lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false);
            lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f));
            regularData.addSeries(series);
            ++lineAndShapeCount;
        }

        if (group.getType() == MetricType.SPREAD) {
            final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString());

            final List<Spread> data = group.getDataAs(Spread.class);

            for (final Spread d : data) {
                series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax());
            }

            intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN);
            intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f));
            intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200));
            intervalRenderer.setSeriesShapesVisible(intervalCount, false);
            intervalData.addSeries(series);
            ++intervalCount;
        }
    }

    final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer,
            intervalRenderer);

    chart.setAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);

    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    if (threshold != null) {
        final ValueMarker marker = new ValueMarker(threshold, Color.RED,
                new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f);
        plot.addRangeMarker(marker);
    }

    plot.setRenderer(lineAndShapeRenderer);

    // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits());

    return chart;
}

From source file:network.Draw.java

@Override
public void run() {
    JFrame frame = new JFrame();
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override//from   w ww . j a  va 2  s  .c  o m
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            isRun = false;
        }
    });

    while (isRun) {
        JFreeChart xylineChart;
        if (method == 0) {
            System.out.println("hi");
            xylineChart = ChartFactory.createXYLineChart("Tempreture", "Time", "Tempreture", createDataset(0),
                    PlotOrientation.VERTICAL, true, true, false);
        } else {
            System.out.println("hi");
            xylineChart = ChartFactory.createXYLineChart("Tempreture", "Time", "Tempreture", createDataset(1),
                    PlotOrientation.VERTICAL, true, true, false);
        }
        final XYPlot plot = xylineChart.getXYPlot();
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesStroke(0, new BasicStroke(1.0f));
        plot.setRenderer(renderer);

        frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        frame.setSize(700, 500);
        frame.getContentPane().removeAll();

        ChartPanel chartPanel = new ChartPanel(xylineChart);
        frame.add(chartPanel);
        frame.setVisible(true);
        try {
            Thread.sleep(10000);
        } catch (InterruptedException ex) {
            System.out.println(ex);
        }
    }
}

From source file:org.azrul.langmera.LineChart.java

/**
 * Creates a chart./*ww w .j  a v a  2 s  .c  o m*/
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), // chart title
            "Number of messages", // x axis label
            "Value of actions", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 10.0f, 6.0f }, 0.0f));
    }

    return chart;

}

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true,
            false);//  w w w.  j a  v  a2  s.c  o  m
    final XYPlot plot = result.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    ValueAxis domain = plot.getDomainAxis();
    domain.setAutoRange(true);
    ValueAxis range = plot.getRangeAxis();
    range.setRange(0, MINMAX);
    range.setAutoRangeMinimumSize(20);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    for (int i = 0; i < SERIES; i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f));
    }

    return result;
}