v800_trainer.XYGraphik.java Source code

Java tutorial

Introduction

Here is the source code for v800_trainer.XYGraphik.java

Source

package v800_trainer;

/*
 * Graphik.java
    
*
* SourceFile is part of Chainwheel
    
* All functions for xy graphic
*/

/**
 *
 * @author  volker hochholzer
 * 
 * Chainwheel and all dependend source files is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
Chainwheel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
    
    
  * Created on 29. Dezember 2000, 20:56
  */

import java.awt.geom.Rectangle2D;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.data.time.Second;

import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.RectangleInsets;

import java.awt.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import org.jfree.chart.axis.ValueAxis;

public class XYGraphik extends javax.swing.JPanel {

    /** Creates new form Graphik */
    public void XYGraphik() {
        initComponents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the FormEditor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents

        setLayout(null);

    }//GEN-END:initComponents

    public JPanel StartGraphik(JCicloTronic JTronicHandle) {

        int num = 0;
        int num2 = 0, num0, num02; //fr Streckendifferenz
        int selected;
        int single;
        int i;
        int j;
        int Stunden;
        int Minuten;
        int Sekunden;
        int Tagadder = 0;
        int Linecount = 0;
        Second xTime[];
        double xWerte[];
        double xWerte2[];//fr Streckendifferenz
        double y1Werte[];
        double y2Werte[];
        double y3Werte[];
        double y4Werte[];
        double y5Werte[];
        double y6Werte[];
        double y7Werte[];
        double y8Werte[];
        double y8bWerte[];
        double y9Werte[];
        double y10Werte[];

        JFreeChart chart;

        Rectangle2D.Double Legendenpunkt = new Rectangle2D.Double();

        selected = JTronicHandle.Auswahl_Graphik.getSelectedIndex();

        if (selected == 0) {
            single = 1;
        } else {
            single = 0;
        }

        //Defaultchart erstellen
        if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) {

            XYSeries dataset = new XYSeries("");

            dataset.add(1, 1);
            XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

            chart = ChartFactory.createXYLineChart("Multiple Axis Demo 1", "Strecke", "", dataset1,
                    PlotOrientation.HORIZONTAL, true, true, false);

        } else {
            TimeSeries dataset = new TimeSeries("");

            dataset.add(new Second(1, 1, 1, 1, 1, 1900), 1);

            TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

            chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Zeit", "", dataset1, true, true,
                    false);
        }
        ;
        //Tooltips fr Zeitachse einstellen
        //    XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})",
        //            (DateFormat) new SimpleDateFormat("kk:mm.ss"),
        //            NumberFormat.getInstance());

        //  chart.setAntiAlias(true);
        chart.setNotify(false);

        if (single == 0) {
            chart.setTitle(JTronicHandle.Statistikhandle.TourData[JTronicHandle.Auswahl_Graphik
                    .getSelectedIndex()].DataProperty.getProperty("Titel", ""));
            chart.addSubtitle(new TextTitle(JTronicHandle.Auswahl_Graphik.getItemAt(selected).toString()));
        } else {
            chart.setTitle("Mehrfache Daten");
        }

        chart.setBackgroundPaint(Color.white);

        JTronicHandle.applyChartTheme(chart);

        XYPlot plot = chart.getXYPlot();

        plot.setOrientation(PlotOrientation.VERTICAL);
        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);
        plot.setRangeCrosshairLockedOnData(false);
        plot.setDomainCrosshairLockedOnData(false);

        int Anzahl_Kurven = Integer.parseInt(JTronicHandle.Properties.getProperty("AnzahlKurven", "5")) + 1;

        if (Anzahl_Kurven > JTronicHandle.Auswahl_Graphik.getItemCount()) {
            Anzahl_Kurven = JTronicHandle.Auswahl_Graphik.getItemCount();
        }

        try {

            for (j = 0; j < (Anzahl_Kurven - 2) * single + 1; j++) {
                if (single == 1) {
                    selected = j + 1;
                }
                num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
                num2 = JTronicHandle.Statistikhandle.TourData[selected].ZahlStreckenPunkte;
                num0 = JTronicHandle.Statistikhandle.TourData[1].ZahlStreckenPunkte;
                num02 = JTronicHandle.Statistikhandle.TourData[1].Datenpunkte;
                xTime = new Second[num];
                xWerte = new double[num];
                y1Werte = new double[num];
                y2Werte = new double[num];
                y3Werte = new double[num];
                y4Werte = new double[num];
                y5Werte = new double[num];
                y6Werte = new double[num];
                y7Werte = new double[num];
                y8Werte = new double[num];
                y8bWerte = new double[num];
                xWerte2 = new double[num2];
                y9Werte = new double[num2];
                y10Werte = new double[num];

                for (i = 0; i < num; i++) {
                    xWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i];
                    y1Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Geschw_gesZeit[i];
                    y2Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hoehe_gesZeit[i];
                    y3Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i];
                    y4Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Temperatur_gesZeit[i];
                    y5Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigp_gesZeit[i];
                    y6Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigm_gesZeit[i];
                    y7Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].av_Geschw_gesZeit[i];
                    y8Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Cadence_gesZeit[i];
                    y8bWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i];
                }

                if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) {
                    int p = 0;
                    if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) {
                        for (i = 0; i < num2; i++) {
                            xWerte2[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Streckenskala[i];
                            if (i < num0) {
                                y9Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].ZeitberStrecke[i]
                                        - JTronicHandle.Statistikhandle.TourData[1].ZeitberStrecke[i];
                            } else {
                                y9Werte[i] = y9Werte[i - 1];
                            }
                        }
                    } else {
                        for (i = 0; i < num; i++) {
                            p = 0;
                            while (p < num02 - 1
                                    && (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] >= JTronicHandle.Statistikhandle.TourData[1].gesZeit[p])) {
                                p++;
                            }
                            ;
                            if (i < num02) {
                                y10Werte[i] = (double) (JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i]
                                        - JTronicHandle.Statistikhandle.TourData[1].Strecke_gesZeit[p]) * 100.0;
                            } else {
                                y10Werte[i] = y10Werte[i - 1];
                            }
                        }
                    }
                }

                //Zeitbasis laden
                for (i = 0; i < num; i++) {
                    Tagadder = 0;
                    Stunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] / 3600);
                    Minuten = (int) ((JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600)
                            / 60);
                    Sekunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600
                            - Minuten * 60);
                    if (single == 0) {
                        Minuten = Minuten + JTronicHandle.Statistikhandle.TourData[selected].StartMinuten;
                        if (Minuten >= 60) {
                            Minuten -= 60;
                            Stunden++;
                        }
                        ;
                        Stunden = Stunden + JTronicHandle.Statistikhandle.TourData[selected].StartStunden;
                    }
                    ;
                    while (Stunden >= 24) {
                        Stunden -= 24;
                        Tagadder += 1;
                    }
                    ;

                    try {
                        if (single == 0) {
                            xTime[i] = new Second(Sekunden, Minuten, Stunden,
                                    JTronicHandle.Statistikhandle.TourData[selected].Tag + Tagadder,
                                    JTronicHandle.Statistikhandle.TourData[selected].Monat,
                                    JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        } else {
                            xTime[i] = new Second(Sekunden, Minuten, Stunden, 1 + Tagadder, 1, 1900);
                        }

                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(null, "StartGraphik\n" + e + "Zeile " + i + " Zeitfehler "
                                + Stunden + " " + Minuten + " " + Sekunden, "Achtung!", JOptionPane.ERROR_MESSAGE);
                    }
                }

                if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { //Streckenachse

                    if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag
                                        + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y1Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //          renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Hhe.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Hhe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);

                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y2Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);
                        NumberAxis axis2 = new NumberAxis("Hhe [m]");
                        axis2.setLabelFont(plot.getRangeAxis().getLabelFont());
                        axis2.setTickLabelFont(plot.getRangeAxis().getTickLabelFont());
                        axis2.setAutoRangeIncludesZero(true);
                        axis2.setLabelPaint(Color.BLACK);
                        axis2.setTickLabelPaint(Color.BLACK);
                        axis2.setAxisLinePaint(Color.BLACK);
                        plot.setRangeAxis(1, axis2);
                        plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 1);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //               renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }
                    ;

                    if (JTronicHandle.Graphik_check_HF.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y3Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Temp.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y4Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Steigung [%] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y5Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //          renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y6Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //              renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y7Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //              renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Cadence.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Cadence [n/min]  " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y8Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //               renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) {

                        XYSeries dataset = new XYSeries(
                                "Schrittlnge [cm]  " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xWerte[i], y8bWerte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //                  renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) {

                        XYSeries dataset = new XYSeries(
                                "Zeitabstand [s] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - "
                                        + JTronicHandle.Statistikhandle.TourData[1].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[1].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[1].Jahr);
                        for (i = 0; i < num2; i++) {
                            dataset.add(xWerte2[i], y9Werte[i]);
                        }

                        XYSeriesCollection dataset1 = new XYSeriesCollection(dataset);

                        NumberAxis axis3 = new NumberAxis("Abstand");
                        axis3.setLabelFont(plot.getRangeAxis().getLabelFont());
                        axis3.setTickLabelFont(plot.getRangeAxis().getTickLabelFont());

                        axis3.setAutoRangeIncludesZero(true);
                        axis3.setLabelPaint(Color.BLACK);
                        axis3.setTickLabelPaint(Color.BLACK);
                        plot.setRangeAxis(2, axis3);
                        plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 2);
                        XYItemRenderer renderer = new StandardXYItemRenderer();
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //             renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                } else { //Zeitachse

                    if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag
                                        + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y1Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        ValueAxis axis = plot.getRangeAxis();

                        axis.setLabelPaint(Color.BLACK);
                        axis.setTickLabelPaint(Color.BLACK);
                        plot.setRangeAxis(0, axis);
                        plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);

                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));

                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Hhe.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Hoehe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y2Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);
                        NumberAxis axis2 = (NumberAxis) plot.getRangeAxis().clone();
                        axis2.setLabel("Hhe [m]");

                        axis2.setAutoRangeIncludesZero(true);

                        axis2.setLabelPaint(Color.BLACK);
                        axis2.setTickLabelPaint(Color.BLACK);
                        axis2.setAxisLinePaint(Color.BLACK);
                        plot.setRangeAxis(1, axis2);
                        plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 1);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_HF.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y3Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Temp.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y4Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //          renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) {

                        TimeSeries dataset = new TimeSeries("Steigung [%] ");
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y5Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //           renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y6Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //           renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y7Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //              renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Cadence.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Cadence [n/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y8Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //          renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) {

                        TimeSeries dataset = new TimeSeries(
                                "Schrittlnge [cm] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y8bWerte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 0);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                    if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) {

                        TimeSeries dataset = new TimeSeries(
                                "Streckenabstand [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - "
                                        + JTronicHandle.Statistikhandle.TourData[1].Tag + "."
                                        + JTronicHandle.Statistikhandle.TourData[1].Monat + "."
                                        + JTronicHandle.Statistikhandle.TourData[1].Jahr);
                        for (i = 0; i < num; i++) {
                            dataset.add(xTime[i], y10Werte[i]);
                        }

                        TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

                        ValueAxis axis3 = (ValueAxis) plot.getRangeAxis().clone();

                        axis3.setLabel("Abstand");
                        axis3.setLabelPaint(Color.BLACK);
                        axis3.setTickLabelPaint(Color.BLACK);
                        plot.setRangeAxis(2, axis3);
                        plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT);

                        plot.setDataset(Linecount, dataset1);
                        plot.mapDatasetToRangeAxis(Linecount, 2);
                        XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip);
                        renderer.setSeriesPaint(0, getColour(Linecount));
                        //            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                        plot.setRenderer(Linecount, renderer);

                        Linecount++;
                    }

                }

            }
            chart.setNotify(true);
            ChartPanel Panel = new ChartPanel(chart);

            return Panel;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "StartGraphik\nSchluss_Fehler: " + e, "Achtung!",
                    JOptionPane.ERROR_MESSAGE);
        }

        return new ChartPanel(chart);
    }

    private static Paint getColour(int Farbe) {

        Paint Colour = Color.BLACK;
        Farbe = Farbe % 8;
        switch (Farbe) {
        case 0:
            Colour = Color.BLACK;
            break;
        case 1:
            Colour = Color.BLUE;
            break;
        case 2:
            Colour = Color.RED;
            break;
        case 3:
            Colour = Color.GREEN;
            break;
        case 4:
            Colour = Color.MAGENTA;
            break;
        case 5:
            Colour = Color.ORANGE;
            break;
        //            case 6: Colour = Color.PINK; break;
        //            case 7: Colour = Color.CYAN; break;
        case 6:
            Colour = Color.YELLOW;
            break;
        case 7:
            Colour = Color.WHITE;
            break;

        }
        ;
        return Colour;
    }

}

// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables