Example usage for org.jfree.data.xy XYSeriesCollection XYSeriesCollection

List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection XYSeriesCollection.

Prototype

public XYSeriesCollection() 

Source Link

Document

Constructs an empty dataset.

Usage

From source file:com.graphhopper.jsprit.analysis.toolbox.XYLineChartBuilder.java

/**
 * Builds and returns JFreeChart.//from  ww w.  ja  va  2s  . co  m
 *
 * @return
 */
public JFreeChart build() {
    XYSeriesCollection collection = new XYSeriesCollection();
    for (XYSeries s : seriesMap.values()) {
        collection.addSeries(s);
    }
    JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    return chart;
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java

public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info,
        List<NavigableMap<Double, Double>> modelPeaks) {
    super(null, true);

    setBackground(Color.white);// w  ww .ja v a  2  s . c o  m
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    NumberAxis xAxis = new NumberAxis("Retention Time");
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

    NumberAxis yAxis = new NumberAxis("Intensity");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setUpperMargin(0);
    yAxis.setLowerMargin(0);

    xyDataset = new XYSeriesCollection();
    colorDataset = new ArrayList<>();
    toolTips = new ArrayList<>();
    widths = new ArrayList<>();

    int seriesID = 0;

    for (int i = 0; i < clusters.size(); ++i) {
        List<NavigableMap<Double, Double>> cluster = clusters.get(i);
        double color = colors.get(i);

        for (int j = 0; j < cluster.size(); ++j) {
            XYSeries series = new XYSeries(seriesID++);

            for (Entry<Double, Double> e : cluster.get(j).entrySet())
                series.add(e.getKey(), e.getValue());

            xyDataset.addSeries(series);
            colorDataset.add(color);
            toolTips.add(info.get(i).get(j));
        }
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        @Override
        public Paint getItemPaint(int row, int col) {
            String type = xyDataset.getSeries(row).getDescription();

            Paint color;

            if (type.equals(PeakType.MODEL.name()))
                color = COLORS[row % COLORS.length];
            else
                color = new Color(0, 0, 0, 50);

            return color;
        }

        @Override
        public Stroke getSeriesStroke(int series) {
            XYSeries s = xyDataset.getSeries(series);
            String type = s.getDescription();

            float width;
            if (type.equals((PeakType.MODEL.name())))
                width = 2.0f;
            else
                width = 1.0f;

            return new BasicStroke(width);
        }
    };

    renderer.setDefaultShapesVisible(false);
    renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            try {
                return toolTips.get(series);
            } catch (NullPointerException | IndexOutOfBoundsException e) {
                return "";
            }
        }
    });

    XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
    chart.setBackgroundPaint(Color.white);

    super.setChart(chart);
}

From source file:utilities.GraphViewer.java

public GraphViewer() {

    super("Graph Viewer");
    setRootPaneCheckingEnabled(false);//  ww  w .j a va  2  s.co  m

    this.setLocation(0, 0);
    this.setVisible(false);
    dataset = new XYSeriesCollection();
    this.db = new Db();
    this.sensors = new LinkedList<JCheckBox>();
    this.sensors1 = new LinkedList<JCheckBox>();

    getContentPane().setLayout(new BorderLayout(0, 0));

    this.setName("Graph Viewer");
    setIconifiable(true);
    setClosable(true);
    setBounds(6, 95, 1000, 600);

    option = new JPanel();
    option.setBackground(new Color(240, 240, 255));
    option.setPreferredSize(new Dimension(200, 500));
    option.setLayout(new BorderLayout(10, 10));
    getContentPane().add(option, BorderLayout.WEST);

    parcourir = new JButton("Add Sensor");
    parcourir.setAlignmentX(Component.CENTER_ALIGNMENT);
    parcourir.addActionListener(this);
    option.add(parcourir, BorderLayout.NORTH);

    this.sensorsList = new JPanel();
    sensorsList.setLayout(new VerticalLayout());
    sensorsList.setBackground(Color.WHITE);

    scpane = new JScrollPane(sensorsList);
    scpane.setBorder(BorderFactory.createLineBorder(Color.black));
    scpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    option.add(scpane, BorderLayout.CENTER);

    paneGraphe = new JPanel();
    paneGraphe.setLayout(new BorderLayout(0, 0));
    graphe = graphe();
    paneGraphe.add(graphe, BorderLayout.CENTER);
    getContentPane().add(paneGraphe);

}

From source file:playground.dgrether.analysis.charts.DgTravelTimeCalculatorChart.java

private XYSeriesCollection createDataSet() {
    XYSeriesCollection dataset = new XYSeriesCollection();

    int numSlots = this.calculator.getNumSlots();
    int binSize = this.calculator.getTimeSlice();
    int maxtime = numSlots * binSize;

    double startSecond = startTime;
    double endSecond;
    if (maxtime < endTime) {
        endSecond = maxtime;/*from  ww w .j  a  v  a 2s  .  c o m*/
    } else {
        endSecond = endTime;
    }

    double tt;
    XYSeries series;
    for (Entry<List<Id<Link>>, XYSeries> e : this.linkIds.entrySet()) {
        series = e.getValue();
        dataset.addSeries(series);
        //      log.error("link: "+ e.getKey());
        for (double i = startSecond; i < endSecond; i++) {
            tt = 0;
            for (Id<Link> id : e.getKey()) {
                tt += this.calculator.getLinkTravelTime(id, i);
            }
            //        log.error("time: " + i + " tt " + tt);
            e.getValue().add(i, tt);
        }
    }

    return dataset;
}

From source file:sim.MarkersChart.java

public MarkersChart(int maxItemCount, String dirName, String timestamp) {
    params = new PlotParameters();
    params.title = "Simulation Marker's Chart - " + timestamp;
    params.xAxisLabel = "Number of Agents";
    params.yAxisLabel = "Interaction Step";
    params.type = PlotType.SCATTER;/*from  w  w w . j a  va 2 s  . c  o m*/
    params.height = 1080;
    params.width = 1920;

    params.path = System.getProperty("user.dir") + File.separator + "logs" + File.separator + dirName
            + File.separator + "chart." + timestamp + ".png";

    infectionComplete = new ChartSeries2DMeasure("Infection Complete");
    infectionComplete.getXYSeries().setMaximumItemCount(maxItemCount);

    leaderElectionComplete = new ChartSeries2DMeasure("Leader Believes Election Complete");
    leaderElectionComplete.getXYSeries().setMaximumItemCount(maxItemCount);

    allElectionComplete = new ChartSeries2DMeasure("All Agents Believe Election Complete");
    allElectionComplete.getXYSeries().setMaximumItemCount(maxItemCount);

    // Main chart
    XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(infectionComplete.getXYSeries());
    dataset.addSeries(leaderElectionComplete.getXYSeries());
    dataset.addSeries(allElectionComplete.getXYSeries());

    chart = ChartFactory.createScatterPlot(params.title, params.xAxisLabel, params.yAxisLabel, dataset,
            params.orientation, params.showLegend, false, false);
    chart.setTextAntiAlias(true);

    Logger.debug("Infection count chart INIT");
}

From source file:mineria.UI.java

public UI() {
    this.setLayout(new GridBagLayout());

    Label lblnodatos = new Label("NoDatos: ");
    Label label = new Label("BD: ");
    JTextField filename = new JTextField("/Users/eduardomartinez/Documents/mineria/representacion.txt");
    JTextField nodatos = new JTextField();
    nodatos.setText("500");

    JTextField funcion = new JTextField("6");
    JTextField individuos = new JTextField("200");
    JTextField enteros = new JTextField("1");
    JTextField decimales = new JTextField("40");
    JTextField variables = new JTextField("6");
    JTextField Pc = new JTextField("0.9");
    JTextField Pm = new JTextField("0.01");
    JTextField generaciones = new JTextField("100");
    JTextField minimiza = new JTextField("0");

    Label lblfuncion = new Label("funcion: ");
    Label lblindividuos = new Label("individuos: ");
    Label lblenteros = new Label("enteros: ");
    Label lbldecimales = new Label("decimales: ");
    Label lblvariables = new Label("variables: ");
    Label lblpc = new Label("Pc: ");
    Label lblpm = new Label("Pm: ");
    Label lblgeneraciones = new Label("generaciones: ");
    Label lblminimiza = new Label("[0 Min/1 Max] : ");

    /*//w w  w.j  a  v  a2 s . c om
    FN=funcion;
    N =individuos;
    E =bits_enteros;
    D =bits_decimales;
    V =variables;
    Pc=porcentaje_cruza;
    Pm=porcentaje_muta;
    G =generaciones;
    MM=minimiza;
    */

    JButton openBtn = new JButton("Open BD");
    JButton ejecutarEGA = new JButton("Ejecutar EGA");
    JTextField resultado = new JTextField();
    Label fitness = new Label("fitness: ");

    XYSeriesCollection datosSerie = new XYSeriesCollection();

    AGF agf = new AGF(2);
    EGA ega = new EGA();

    JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot", // chart title
            "X", // x axis label
            "Y", // y axis label
            datosSerie, // data  ***-----PROBLEM------***
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // create and display a frame...
    ChartPanel panelChart = new ChartPanel(chart);

    //leer BD
    openBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            //datosSerie.removeAllSeries();
            if (filename.getText().length() > 0) {
                agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText()));

                createDataset(datosSerie, agf.data, "Datos");
                chart.fireChartChanged();
            } else {
                JFileChooser openFile = new JFileChooser();
                int rVal = openFile.showOpenDialog(null);
                if (rVal == JFileChooser.APPROVE_OPTION) {
                    filename.setText(openFile.getSelectedFile().getAbsolutePath());
                    agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText()));
                    //createDataset(datosSerie, agf.data, "Datos");
                    //chart.fireChartChanged();
                }
                if (rVal == JFileChooser.CANCEL_OPTION) {
                    filename.setText("");
                    //dir.setText("");
                }
            }
        }
    });

    ejecutarEGA.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            //datosSerie.removeAllSeries();
            if (datosSerie.getSeriesCount() > 1)
                datosSerie.removeSeries(1);

            int fn = Integer.parseInt(funcion.getText());
            int n = Integer.parseInt(individuos.getText());
            int e = Integer.parseInt(enteros.getText());
            int d = Integer.parseInt(decimales.getText());
            int v = Integer.parseInt(variables.getText());
            double pc = Double.parseDouble(Pc.getText());
            double pm = Double.parseDouble(Pm.getText());
            int g = Integer.parseInt(generaciones.getText());
            int mm = Integer.parseInt(minimiza.getText());

            ega.setParams(fn, n, e, d, v, pc, pm, g, mm);

            Resultado res = ega.ejecutarAlgoritmoGenetico(agf);

            resultado.setText(String.valueOf(res.getFitnessSemental()));

            res.creaArchivo();
            createDataset(datosSerie, res.getFenotipoSemental(), "Centros");

            Shape cross = ShapeUtilities.createDiagonalCross(5, 1);
            XYPlot xyPlot = (XYPlot) chart.getPlot();
            xyPlot.setDomainCrosshairVisible(true);
            xyPlot.setRangeCrosshairVisible(true);
            XYItemRenderer renderer = xyPlot.getRenderer();
            renderer.setSeriesShape(1, cross);
            renderer.setSeriesPaint(1, Color.blue);

            chart.fireChartChanged();

        }
    });
    //ejecutar AG

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblnodatos, gbc);

    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(nodatos, gbc);

    gbc.gridx = 2;
    gbc.gridy = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(filename, gbc);

    gbc.gridx = 3;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(openBtn, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(fitness, gbc);

    gbc.gridx = 3;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(resultado, gbc);

    gbc.gridx = 2;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(ejecutarEGA, gbc);

    //-----------------PARAMETROS
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblfuncion, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(funcion, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblindividuos, gbc);

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(individuos, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblenteros, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(enteros, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lbldecimales, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(decimales, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblvariables, gbc);

    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(variables, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblpc, gbc);

    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(Pc, gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblpm, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(Pm, gbc);

    gbc.gridx = 0;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblgeneraciones, gbc);

    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(generaciones, gbc);

    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblminimiza, gbc);

    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(minimiza, gbc);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 9;
    gbc.gridheight = 2;
    gbc.gridwidth = 4;
    this.add(panelChart, gbc);

    this.setTitle("File Chooser");

    this.pack();
}

From source file:flow.visibility.pcap.FlowProcess.java

/** function to create internal frame contain flow summary chart */

public static JInternalFrame FlowStatistic() {

    final StringBuilder errbuf = new StringBuilder(); // For any error msgs  
    final String file = "tmp-capture-file.pcap";

    //System.out.printf("Opening file for reading: %s%n", file);  

    /*************************************************************************** 
     * Second we open up the selected file using openOffline call 
     **************************************************************************/
    Pcap pcap = Pcap.openOffline(file, errbuf);

    if (pcap == null) {
        System.err.printf("Error while opening device for capture: " + errbuf.toString());
    }//from w w w  . ja v a2  s  .c om

    Pcap pcap1 = Pcap.openOffline(file, errbuf);
    FlowMap map = new FlowMap();
    pcap1.loop(Pcap.LOOP_INFINITE, map, null);

    //System.out.printf(map.toString());
    //System.out.printf(map.toString2());

    /** Splitting the packets statistics strings from FlowMap function */

    String packet = map.toString2();
    String[] NumberPacket = packet.split(",");

    final XYSeries Flow = new XYSeries("Flow");

    for (int i = 0; i < NumberPacket.length - 1; i = i + 1) {

        //System.out.printf(NumberPacket[i+1] + "\n");
        double NoPacket = Double.valueOf(NumberPacket[i + 1]);
        Flow.add(i, NoPacket);

    }

    /** Create dataset for chart */

    final XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(Flow);

    /** Create the internal frame contain flow summary chart */

    JInternalFrame FlowStatistic = new JInternalFrame("Flow Statistic", true, true, true, true);
    FlowStatistic.setBounds(0, 0, 600, 330);

    ChartPanel chartPanel = new ChartPanel(createChart(dataset));
    chartPanel.setMouseZoomable(true, false);

    FlowStatistic.add(chartPanel);
    FlowStatistic.setVisible(true);
    FlowStatistic.revalidate();
    pcap1.close();

    return FlowStatistic;

}

From source file:org.jfree.data.xy.XYSeriesCollectionTest.java

/**
 * Some checks for the constructor.//from   w  ww.  j  ava 2 s.  c  o m
 */
@Test
public void testConstructor() {
    XYSeriesCollection xysc = new XYSeriesCollection();
    assertEquals(0, xysc.getSeriesCount());
    assertEquals(1.0, xysc.getIntervalWidth(), EPSILON);
    assertEquals(0.5, xysc.getIntervalPositionFactor(), EPSILON);
}

From source file:org.owasp.benchmark.score.report.ScatterHome.java

private JFreeChart display(String title, int height, Set<Report> toolResults) {
    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //averages//from  w w w.  java  2  s .  c  o  m
    ArrayList<Double> averageCommercialFalseRates = new ArrayList<Double>();
    ArrayList<Double> averageCommercialTrueRates = new ArrayList<Double>();

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    for (Report toolReport : toolResults) {
        if (!toolReport.isCommercial()) {
            OverallResults overallResults = toolReport.getOverallResults();
            series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100);
            if (toolReport.isCommercial()) {
                averageCommercialFalseRates.add(overallResults.getFalsePositiveRate());
                averageCommercialTrueRates.add(overallResults.getTruePositiveRate());
            }
        }
    }

    int commercialToolCount = 0;
    for (Report toolReport : toolResults) {
        if (toolReport.isCommercial()) {
            commercialToolCount++;
            OverallResults overallResults = toolReport.getOverallResults();
            if (!BenchmarkScore.showAveOnlyMode) {
                series.add(overallResults.getFalsePositiveRate() * 100,
                        overallResults.getTruePositiveRate() * 100);
            }
            if (toolReport.isCommercial()) {
                averageCommercialFalseRates.add(overallResults.getFalsePositiveRate());
                averageCommercialTrueRates.add(overallResults.getTruePositiveRate());
            }
        }
    }

    for (double d : averageCommercialFalseRates) {
        afr += d;
    }
    afr = afr / averageCommercialFalseRates.size();

    for (double d : averageCommercialTrueRates) {
        atr += d;
    }
    atr = atr / averageCommercialTrueRates.size();

    if (commercialToolCount > 1 || (BenchmarkScore.showAveOnlyMode && commercialToolCount == 1)) {
        series.add(afr * 100, atr * 100);
    }

    dataset.addSeries(series);

    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();
    initializePlot(xyplot);

    makeDataLabels(toolResults, xyplot);
    makeLegend(toolResults, 103, 100.5, dataset, xyplot);

    for (XYDataItem item : (List<XYDataItem>) series.getItems()) {
        double x = item.getX().doubleValue();
        double y = item.getY().doubleValue();
        double z = (x + y) / 2;
        XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue);
        xyplot.addAnnotation(score);
    }

    ChartPanel cp = new ChartPanel(chart, height, height, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    //      f.setVisible(true);
    return chart;
}

From source file:com.bdb.weather.display.windrose.WindRosePlot.java

/**
 * Load the wind rose data into the dataset.
 * /* www .j  av  a  2 s  .  c o  m*/
 * @param d The wind rose data
 */
public void setDataset(WindRoseData d) {
    data = d;
    if (d == null) {
        setDataset((XYSeriesCollection) null);
        return;
    }

    int numSlices = d.getNumSlices();
    double arcLength = (360.0 / numSlices) / 2.0;
    double halfArcLength = arcLength / 2.0;

    XYSeriesCollection dataset = new XYSeriesCollection();

    logger.log(Level.FINEST, "Creating Wind Rose dataset with {0} slices. arcLength = {1}",
            new Object[] { numSlices, arcLength });

    //
    // First go through the wind direction slices. Each weather station can have a different number of
    // direction slices. The minimum is probably 4 and the maximum is probably 360.
    //
    int seriesNumber = 0;
    for (int i = 0; i < numSlices; i++) {
        WindSlice slice = d.getSlice(i);

        //
        // The length of the pie slice is determined by the percentage of the wind that was blowing within
        // the slice. Calm winds entries are ignored.
        //
        double percent = slice.getPercentageOfWind();

        double lastLength = 0.0;

        logger.log(Level.FINER, "Slice {0} has {1} speed bins", new Object[] { i, slice.getNumSpeedBins() });

        //
        // Each slice is then divided by speed bins. Each bin is represented by a color and the length
        // of each slice segment is determined by the percentage of time the wind was blowing within the
        // speed bin.
        //
        for (int j = 0; j < slice.getNumSpeedBins(); j++) {
            Heading heading = Heading.headingForSlice(i, numSlices);
            XYSeries series = new XYSeries(heading.toString() + j, false);

            double headingValue = heading.get();
            double binPercentage = slice.speedBinPercentage(j);

            double length = lastLength;

            if (binPercentage != 0.0)
                length += percent * (binPercentage / 100.0);

            double left = headingValue - halfArcLength;
            double right = headingValue + halfArcLength;

            logger.log(Level.FINEST, "Adding series with data: {0},{1},{2}:{3}",
                    new Object[] { left, right, length, slice.speedBinPercentage(j) });

            //
            // Each slices speed segment is drawn as a separate series with its own color
            //
            series.add(left, lastLength);
            series.add(right, lastLength);

            series.add(right, length);
            series.add(left, length);

            dataset.addSeries(series);

            renderer.setSeriesPaint(seriesNumber, binColor[j]);
            renderer.setSeriesFilled(seriesNumber++, true);

            lastLength = length;
        }

    }

    setDataset(dataset);
}