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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy YIntervalRenderer 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.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java

private JFreeChart createChart(Schedule schedule) {
    YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection();
    Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>(
            schedule.getProjectList().size());
    YIntervalRenderer renderer = new YIntervalRenderer();
    int maximumEndDate = 0;
    int seriesIndex = 0;
    for (Project project : schedule.getProjectList()) {
        YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel());
        seriesCollection.addSeries(projectSeries);
        projectSeriesMap.put(project, projectSeries);
        renderer.setSeriesShape(seriesIndex, new Rectangle());
        renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f));
        seriesIndex++;/*from   ww w .j a v  a 2s  . c o m*/
    }
    for (Allocation allocation : schedule.getAllocationList()) {
        int startDate = allocation.getStartDate();
        int endDate = allocation.getEndDate();
        YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject());
        projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate);
        maximumEndDate = Math.max(maximumEndDate, endDate);
    }
    NumberAxis domainAxis = new NumberAxis("Job");
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5);
    domainAxis.setInverted(true);
    NumberAxis rangeAxis = new NumberAxis("Day (start to end date)");
    rangeAxis.setRange(-0.5, maximumEndDate + 0.5);
    XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}