Example usage for org.jfree.chart.plot XYPlot setRangeCrosshairLockedOnData

List of usage examples for org.jfree.chart.plot XYPlot setRangeCrosshairLockedOnData

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRangeCrosshairLockedOnData.

Prototype

public void setRangeCrosshairLockedOnData(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the range crosshair should "lock-on" to actual data values.

Usage

From source file:com.android.ddmuilib.log.event.EventDisplay.java

Control createCompositeChart(final Composite parent, EventLogParser logParser, String title) {
    mChart = ChartFactory.createTimeSeriesChart(null, null /* timeAxisLabel */, null /* valueAxisLabel */,
            null, /* dataset. set below */
            true /* legend */, false /* tooltips */, false /* urls */);

    // get the font to make a proper title. We need to convert the swt font,
    // into an awt font.
    Font f = parent.getFont();/*from   ww w  .ja  v  a2s  .co m*/
    FontData[] fData = f.getFontData();

    // event though on Mac OS there could be more than one fontData, we'll only use
    // the first one.
    FontData firstFontData = fData[0];

    java.awt.Font awtFont = SWTUtils.toAwtFont(parent.getDisplay(), firstFontData, true /* ensureSameSize */);

    mChart.setTitle(new TextTitle(title, awtFont));

    final XYPlot xyPlot = mChart.getXYPlot();
    xyPlot.setRangeCrosshairVisible(true);
    xyPlot.setRangeCrosshairLockedOnData(true);
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setDomainCrosshairLockedOnData(true);

    mChart.addChangeListener(new ChartChangeListener() {
        @Override
        public void chartChanged(ChartChangeEvent event) {
            ChartChangeEventType type = event.getType();
            if (type == ChartChangeEventType.GENERAL) {
                // because the value we need (rangeCrosshair and domainCrosshair) are
                // updated on the draw, but the notification happens before the draw,
                // we process the click in a future runnable!
                parent.getDisplay().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        processClick(xyPlot);
                    }
                });
            }
        }
    });

    mChartComposite = new ChartComposite(parent, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH,
            ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number
            3000, // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            true, // zoom
            true); // tooltips

    mChartComposite.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            mValueTypeDataSetMap.clear();
            mDataSetCount = 0;
            mOccurrenceDataSet = null;
            mChart = null;
            mChartComposite = null;
            mValueDescriptorSeriesMap.clear();
            mOcurrenceDescriptorSeriesMap.clear();
        }
    });

    return mChartComposite;

}

From source file:org.trade.ui.chart.CandlestickChart.java

/**
 * Method createChart.//from   www  .j a v a 2s .c o m
 * 
 * @param strategyData
 *            StrategyData
 * @param title
 *            String
 * @return JFreeChart
 */
private JFreeChart createChart(StrategyData strategyData, String title, Tradingday tradingday) {

    DateAxis dateAxis = new DateAxis("Date");
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM hh:mm"));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    NumberAxis priceAxis = new NumberAxis("Price");
    priceAxis.setAutoRange(true);
    priceAxis.setAutoRangeIncludesZero(false);
    XYPlot pricePlot = new XYPlot(strategyData.getCandleDataset(), dateAxis, priceAxis,
            strategyData.getCandleDataset().getRenderer());
    pricePlot.setOrientation(PlotOrientation.VERTICAL);
    pricePlot.setDomainPannable(true);
    pricePlot.setRangePannable(true);
    pricePlot.setDomainCrosshairVisible(true);
    pricePlot.setDomainCrosshairLockedOnData(true);
    pricePlot.setRangeCrosshairVisible(true);
    pricePlot.setRangeCrosshairLockedOnData(true);
    pricePlot.setRangeGridlinePaint(new Color(204, 204, 204));
    pricePlot.setDomainGridlinePaint(new Color(204, 204, 204));
    pricePlot.setBackgroundPaint(Color.white);

    /*
     * Calculate the number of 15min segments in this trading day. i.e.
     * 6.5hrs/15min = 26 and there are a total of 96 = one day
     */

    int segments15min = (int) (tradingday.getClose().getTime() - tradingday.getOpen().getTime())
            / (1000 * 60 * 15);

    SegmentedTimeline segmentedTimeline = new SegmentedTimeline(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE,
            segments15min, (96 - segments15min));

    Date startDate = tradingday.getOpen();
    Date endDate = tradingday.getClose();

    if (!strategyData.getCandleDataset().getSeries(0).isEmpty()) {
        startDate = ((CandleItem) strategyData.getCandleDataset().getSeries(0).getDataItem(0)).getPeriod()
                .getStart();
        startDate = TradingCalendar.getSpecificTime(tradingday.getOpen(), startDate);
        endDate = ((CandleItem) strategyData.getCandleDataset().getSeries(0)
                .getDataItem(strategyData.getCandleDataset().getSeries(0).getItemCount() - 1)).getPeriod()
                        .getStart();
        endDate = TradingCalendar.getSpecificTime(tradingday.getClose(), endDate);
    }

    segmentedTimeline.setStartTime(startDate.getTime());
    segmentedTimeline.addExceptions(getNonTradingPeriods(startDate, endDate, tradingday.getOpen(),
            tradingday.getClose(), segmentedTimeline));
    dateAxis.setTimeline(segmentedTimeline);

    // Build Combined Plot
    CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(dateAxis);
    mainPlot.add(pricePlot, 4);

    int axixIndex = 0;
    int datasetIndex = 0;

    /*
     * Change the List of indicators so that the candle dataset is the first
     * one in the list. The main chart must be plotted first.
     */
    List<IndicatorDataset> indicators = new ArrayList<IndicatorDataset>(0);
    for (IndicatorDataset item : strategyData.getIndicators()) {
        if (IndicatorSeries.CandleSeries.equals(item.getType(0))) {
            indicators.add(item);
        }
    }
    for (IndicatorDataset item : strategyData.getIndicators()) {
        if (!IndicatorSeries.CandleSeries.equals(item.getType(0))) {
            indicators.add(item);
        }
    }
    for (int i = 0; i < indicators.size(); i++) {
        IndicatorDataset indicator = indicators.get(i);
        if (indicator.getDisplaySeries(0)) {

            if (indicator.getSubChart(0)) {
                String axisName = "Price";
                if (IndicatorSeries.CandleSeries.equals(indicator.getType(0))) {
                    axisName = ((CandleSeries) indicator.getSeries(0)).getSymbol();
                } else {
                    org.trade.dictionary.valuetype.IndicatorSeries code = org.trade.dictionary.valuetype.IndicatorSeries
                            .newInstance(indicator.getType(0));
                    axisName = code.getDisplayName();
                }
                NumberAxis subPlotAxis = new NumberAxis(axisName);
                subPlotAxis.setAutoRange(true);
                subPlotAxis.setAutoRangeIncludesZero(false);

                XYPlot subPlot = new XYPlot((XYDataset) indicator, dateAxis, subPlotAxis,
                        indicator.getRenderer());

                subPlot.setOrientation(PlotOrientation.VERTICAL);
                subPlot.setDomainPannable(true);
                subPlot.setRangePannable(true);
                subPlot.setDomainCrosshairVisible(true);
                subPlot.setDomainCrosshairLockedOnData(true);
                subPlot.setRangeCrosshairVisible(true);
                subPlot.setRangeCrosshairLockedOnData(true);
                subPlot.setRangeGridlinePaint(new Color(204, 204, 204));
                subPlot.setDomainGridlinePaint(new Color(204, 204, 204));
                subPlot.setBackgroundPaint(Color.white);
                XYItemRenderer renderer = subPlot.getRendererForDataset((XYDataset) indicator);
                for (int seriesIndex = 0; seriesIndex < ((XYDataset) indicator)
                        .getSeriesCount(); seriesIndex++) {
                    renderer.setSeriesPaint(seriesIndex, indicator.getSeriesColor(seriesIndex));
                }
                mainPlot.add(subPlot, 1);

            } else {
                datasetIndex++;
                pricePlot.setDataset(datasetIndex, (XYDataset) indicator);
                if (IndicatorSeries.CandleSeries.equals(indicator.getType(0))) {
                    // add secondary axis
                    axixIndex++;

                    final NumberAxis axis2 = new NumberAxis(
                            ((CandleSeries) indicator.getSeries(0)).getSymbol());
                    axis2.setAutoRange(true);
                    axis2.setAutoRangeIncludesZero(false);
                    pricePlot.setRangeAxis(datasetIndex, axis2);
                    pricePlot.setRangeAxisLocation(i + 1, AxisLocation.BOTTOM_OR_RIGHT);
                    pricePlot.mapDatasetToRangeAxis(datasetIndex, axixIndex);
                    pricePlot.setRenderer(datasetIndex, new StandardXYItemRenderer());
                } else {
                    pricePlot.setRenderer(datasetIndex, indicator.getRenderer());
                }
                XYItemRenderer renderer = pricePlot.getRendererForDataset((XYDataset) indicator);

                for (int seriesIndex = 0; seriesIndex < ((XYDataset) indicator)
                        .getSeriesCount(); seriesIndex++) {
                    renderer.setSeriesPaint(seriesIndex, indicator.getSeriesColor(seriesIndex));
                }
            }
        }
    }
    JFreeChart jfreechart = new JFreeChart(title, null, mainPlot, true);
    jfreechart.setAntiAlias(false);
    return jfreechart;
}

From source file:org.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

private void updateChart(SimpleFeatureCollection features, String propertyName, String morani) {
    // 1. Create a single plot containing both the scatter and line
    XYPlot plot = new XYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainPannable(false);/*w  w w. j ava2s  .c o m*/
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setDomainCrosshairPaint(java.awt.Color.CYAN);
    plot.setRangeCrosshairPaint(java.awt.Color.CYAN);

    plot.setDomainGridlinePaint(java.awt.Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(java.awt.Color.LIGHT_GRAY);

    // 2. Setup Scatter plot
    // Create the scatter data, renderer, and axis
    int fontStyle = java.awt.Font.BOLD;
    FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0];

    NumberAxis xPlotAxis = new NumberAxis(propertyName); // ZScore
    xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));

    NumberAxis yPlotAxis = new NumberAxis("lagged " + propertyName); //$NON-NLS-1$
    yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));

    XYToolTipGenerator plotToolTip = new StandardXYToolTipGenerator();

    XYItemRenderer plotRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
    plotRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
    plotRenderer.setSeriesPaint(0, java.awt.Color.BLUE); // dot
    plotRenderer.setBaseToolTipGenerator(plotToolTip);

    // Set the scatter data, renderer, and axis into plot
    plot.setDataset(0, getScatterPlotData(features));
    plot.setRenderer(0, plotRenderer);
    plot.setDomainAxis(0, xPlotAxis);
    plot.setRangeAxis(0, yPlotAxis);

    // Map the scatter to the first Domain and first Range
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    // 3. Setup line
    // Create the line data, renderer, and axis
    XYItemRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); // Lines only
    lineRenderer.setSeriesPaint(0, java.awt.Color.GRAY); // dot

    // Set the line data, renderer, and axis into plot
    NumberAxis xLineAxis = new NumberAxis(EMPTY);
    xLineAxis.setTickMarksVisible(false);
    xLineAxis.setTickLabelsVisible(false);
    NumberAxis yLineAxis = new NumberAxis(EMPTY);
    yLineAxis.setTickMarksVisible(false);
    yLineAxis.setTickLabelsVisible(false);

    plot.setDataset(1, getLinePlotData(crossCenter));
    plot.setRenderer(1, lineRenderer);
    plot.setDomainAxis(1, xLineAxis);
    plot.setRangeAxis(1, yLineAxis);

    // Map the line to the second Domain and second Range
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    // 4. Setup Selection
    NumberAxis xSelectionAxis = new NumberAxis(EMPTY);
    xSelectionAxis.setTickMarksVisible(false);
    xSelectionAxis.setTickLabelsVisible(false);
    NumberAxis ySelectionAxis = new NumberAxis(EMPTY);
    ySelectionAxis.setTickMarksVisible(false);
    ySelectionAxis.setTickLabelsVisible(false);

    XYItemRenderer selectionRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
    selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6));
    selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot

    plot.setDataset(2, new XYSeriesCollection(new XYSeries(EMPTY)));
    plot.setRenderer(2, selectionRenderer);
    plot.setDomainAxis(2, xSelectionAxis);
    plot.setRangeAxis(2, ySelectionAxis);

    // Map the scatter to the second Domain and second Range
    plot.mapDatasetToDomainAxis(2, 0);
    plot.mapDatasetToRangeAxis(2, 0);

    // 5. Finally, Create the chart with the plot and a legend
    String title = "Moran's I = " + morani; //$NON-NLS-1$
    java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite.setChart(chart);
    chartComposite.forceRedraw();
}

From source file:fi.smaa.jsmaa.gui.views.CriterionView.java

private JPanel buildValueFunctionChartPanel(ScaleCriterion criterion) {
    UtilityFunctionDataset dataset = new UtilityFunctionDataset(criterion);

    JFreeChart chart = ChartFactory.createXYLineChart("", "x", "v(x)", dataset, PlotOrientation.VERTICAL, false,
            true, true);//from w ww . j ava  2s . c o m

    final XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(0, renderer);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

    ValueAxis rAxis = plot.getRangeAxis();
    rAxis.setAutoRange(false);
    rAxis.setRange(new Range(-0.03, 1.03));
    ValueAxis dAxis = plot.getDomainAxis();
    dAxis.setLowerMargin(0.03);
    dAxis.setUpperMargin(0.03);

    ChartPanel chartPanel = new ChartPanel(chart, false, true, true, false, true);
    chartPanel.addChartMouseListener(new ValueFunctionMouseListener(chartPanel, criterion, parent));

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setToolTipText("Click to add/remove partial value function points");
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setMouseZoomable(false);

    plot.setDomainCrosshairLockedOnData(false);
    plot.setRangeCrosshairLockedOnData(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    FormLayout layout = new FormLayout("left:pref", "p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();
    builder.add(chartPanel, cc.xy(1, 1));
    builder.add(new ValueFunctionPointsPanel(criterion), cc.xy(1, 3));

    return builder.getPanel();
}

From source file:v800_trainer.JUebersicht.java

public JPanel Update_Uebersicht(JCicloTronic JTronicHandle) {

    int i;/*from  w  ww.  j a v a 2 s.c om*/
    Day xTime[];
    Today = new GregorianCalendar();
    double y1Werte[];
    double y2Werte[];
    double y3Werte[];
    double y4Werte[];
    double y5Werte[];
    double y6Werte[];
    double y7Werte[];
    double y8Werte[];
    double y9Werte[];
    double y10Werte[];
    double SummeZeit = 0;
    double Summekm = 0;
    double Summehm = 0;
    double SummeZeit12Mon = 0;
    double Summekm12Mon = 0;
    double Summehm12Mon = 0;
    int AnzahlJahre = 0;
    int Selektiert = 0;
    int SelektiertVergl = 0;
    int Jahr;
    int Linecount = 0;
    boolean Vergleich = false;
    XYItemRenderer renderer;
    XYBarRenderer rendererb;

    JFreeChart chart;

    AnzahlJahre = JTronicHandle.Auswahl_bersicht.getItemCount();
    Selektiert = JTronicHandle.Auswahl_bersicht.getSelectedIndex();
    SelektiertVergl = JTronicHandle.JahrVergleich.getSelectedIndex();
    if (SelektiertVergl == 0 || Selektiert == SelektiertVergl - 1)
        Vergleich = false;
    else
        Vergleich = true;

    xTime = new Day[366];

    y1Werte = new double[366];
    y2Werte = new double[366];
    y3Werte = new double[366];
    y4Werte = new double[366];
    y5Werte = new double[366];
    y6Werte = new double[366];
    y7Werte = new double[366];
    y8Werte = new double[366];
    y9Werte = new double[366];
    y10Werte = new double[366];
    TimeSeries dataset;

    dataset = new TimeSeries("dummy");

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

    TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

    chart = ChartFactory.createTimeSeriesChart(
            "Jahresbersicht " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString(), "Zeit", "",
            dataset1, true, true, true);

    XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            (DateFormat) new SimpleDateFormat("dd.MM"), NumberFormat.getInstance());

    if (SelektiertVergl != 0)
        chart.addSubtitle(new TextTitle(
                "Vergleich mit Jahr " + JTronicHandle.JahrVergleich.getSelectedItem().toString()));
    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.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairLockedOnData(false);
    plot.setDomainCrosshairLockedOnData(false);
    if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        DateAxis MyAxis = new DateAxis();
        MyAxis = (DateAxis) plot.getDomainAxis();
        MyAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
        MyAxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

        plot.setDomainGridlinesVisible(false);

    }

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.getRangeAxis().setFixedDimension(15.0);

    plot.getDomainAxis().setTickLabelInsets(new RectangleInsets(2.0, 1.0, 2.0, 1.0));

    Jahr = Integer.parseInt(JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());

    for (i = 0; i < 366; i++) {
        SummeZeit12Mon += (double) Zeit[Selektiert + 1][i];
        Summekm12Mon += (double) kmJahr[Selektiert + 1][i];
        Summehm12Mon += (double) HmJahr[Selektiert + 1][i];

    }

    y4Werte[0] = SummeZeit12Mon;
    y5Werte[0] = Summekm12Mon;
    y6Werte[0] = Summehm12Mon;

    xTime[0] = new Day(31, 12, Jahr - 1);
    for (i = 1; i < 366; i++) {
        try {
            xTime[i] = new Day(xTime[i - 1].next().getStart());

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                    JOptionPane.ERROR_MESSAGE);
        }

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            SummeZeit += (double) Zeit[Selektiert][i];
            Summekm += (double) kmJahr[Selektiert][i];
            Summehm += (double) HmJahr[Selektiert][i];
            y1Werte[i] = SummeZeit;
            y2Werte[i] = Summekm;
            y3Werte[i] = Summehm;

            y4Werte[i] = y4Werte[i - 1] - (double) Zeit[Selektiert + 1][i] + (double) Zeit[Selektiert][i];
            y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[Selektiert + 1][i] + (double) kmJahr[Selektiert][i];
            y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[Selektiert + 1][i] + (double) HmJahr[Selektiert][i];

        } else {
            Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear());
            try {
                Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                        JOptionPane.ERROR_MESSAGE);

            }
            int j = (int) Kalender.get(Kalender.DAY_OF_YEAR);
            for (int m = 0; m < 6; m++) {
                y1Werte[j + m + 1] += (double) Zeit[Selektiert][i];
                y2Werte[j + m + 11] += (double) kmJahr[Selektiert][i];
                y3Werte[j + m + 21] += (double) HmJahr[Selektiert][i];

            }
        }

    }

    dataset = new TimeSeries("Trainingszeit " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y1Werte[i]);
    }

    dataset1 = new TimeSeriesCollection(dataset);
    NumberAxis axis = new NumberAxis();
    try {
        axis = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    axis.setLabel("Stunden");
    axis.setAutoRangeIncludesZero(true);
    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);

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    dataset = new TimeSeries(
            "Trainingskilometer " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y2Werte[i]);

    }

    TimeSeriesCollection dataset2 = new TimeSeriesCollection(dataset);

    NumberAxis axis2 = new NumberAxis();
    try {
        axis2 = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    ;
    axis2.setLabel("Kilometer");
    axis2.setAutoRangeIncludesZero(true);
    axis2.setLabelPaint(Color.BLACK);
    axis2.setTickLabelPaint(Color.BLACK);

    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    plot.setDataset(Linecount, dataset2);
    plot.mapDatasetToRangeAxis(Linecount, 1);

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    dataset = new TimeSeries(
            "Trainingshhenmeter " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y3Werte[i]);

    }

    TimeSeriesCollection dataset3 = new TimeSeriesCollection(dataset);

    NumberAxis axis3 = new NumberAxis("Hhenmeter");
    try {
        axis3 = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    ;
    axis3.setLabel("Hhenmeter");
    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, dataset3);
    plot.mapDatasetToRangeAxis(Linecount, 2);

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    if (Vergleich == true) {
        SummeZeit = 0;
        Summekm = 0;
        Summehm = 0;

        SummeZeit12Mon = 0;
        Summekm12Mon = 0;
        Summehm12Mon = 0;

        for (i = 0; i < 366; i++) {
            SummeZeit12Mon += (double) Zeit[SelektiertVergl - 1][i];
            Summekm12Mon += (double) kmJahr[SelektiertVergl - 1][i];
            Summehm12Mon += (double) HmJahr[SelektiertVergl - 1][i];
        }

        y4Werte[0] = SummeZeit12Mon;
        y5Werte[0] = Summekm12Mon;
        y6Werte[0] = Summehm12Mon;

        for (i = 1; i < 366; i++) {
            try {

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                        JOptionPane.ERROR_MESSAGE);
            }
            ;
            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                SummeZeit += (double) Zeit[SelektiertVergl - 1][i];
                Summekm += (double) kmJahr[SelektiertVergl - 1][i];
                Summehm += (double) HmJahr[SelektiertVergl - 1][i];
                y7Werte[i] = SummeZeit;
                y8Werte[i] = Summekm;
                y9Werte[i] = Summehm;

                y4Werte[i] = y4Werte[i - 1] - (double) Zeit[SelektiertVergl - 1][i]
                        + (double) Zeit[Selektiert][i];
                y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[SelektiertVergl - 1][i]
                        + (double) kmJahr[Selektiert][i];
                y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[SelektiertVergl - 1][i]
                        + (double) HmJahr[Selektiert][i];
            } else {
                Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear());
                try {
                    Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1);

                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                            JOptionPane.ERROR_MESSAGE);

                }
                int j = (int) Kalender.get(Kalender.DAY_OF_YEAR);
                for (int m = 0; m < 5; m++) {
                    y7Werte[j + m + 4] += (double) Zeit[SelektiertVergl - 1][i];
                    y8Werte[j + m + 14] += (double) kmJahr[SelektiertVergl - 1][i];
                    y9Werte[j + m + 24] += (double) HmJahr[SelektiertVergl - 1][i];

                }

            }

        }

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            dataset = new TimeSeries("Trainingszeit ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y4Werte[i]);
            }

            TimeSeriesCollection dataset4 = new TimeSeriesCollection(dataset);

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

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

            Linecount++;

            dataset = new TimeSeries("Trainingskilometer ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y5Werte[i]);
            }

            TimeSeriesCollection dataset5 = new TimeSeriesCollection(dataset);

            plot.setDataset(Linecount, dataset5);
            plot.mapDatasetToRangeAxis(Linecount, 1);

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setGradientPaintTransformer(null);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

            Linecount++;

            dataset = new TimeSeries("Trainingshhenmeter ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y6Werte[i]);
            }

            TimeSeriesCollection dataset6 = new TimeSeriesCollection(dataset);

            plot.setDataset(Linecount, dataset6);
            plot.mapDatasetToRangeAxis(Linecount, 2);

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setGradientPaintTransformer(null);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

        }
        Linecount++;

        dataset = new TimeSeries("Trainingszeit " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y7Werte[i]);
        }

        TimeSeriesCollection dataset7 = new TimeSeriesCollection(dataset);

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

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }
        Linecount++;

        dataset = new TimeSeries(
                "Trainingskilometer " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y8Werte[i]);
        }

        TimeSeriesCollection dataset8 = new TimeSeriesCollection(dataset);

        plot.setDataset(Linecount, dataset8);
        plot.mapDatasetToRangeAxis(Linecount, 1);

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }

        Linecount++;

        dataset = new TimeSeries(
                "Trainingshhenmeter " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y9Werte[i]);
        }

        TimeSeriesCollection dataset9 = new TimeSeriesCollection(dataset);

        plot.setDataset(Linecount, dataset9);
        plot.mapDatasetToRangeAxis(Linecount, 2);

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }

    }

    if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {

        double max = axis.getRange().getUpperBound();
        for (i = 0; i < 12; i++) {
            try {
                Kalender = new GregorianCalendar(Integer.parseInt(DataProperty.getProperty("Jahr", "0")), i, 1);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "JUebersicht\nException GregorianCalender  " + e,
                        "Achtung!", JOptionPane.ERROR_MESSAGE);
            }

            y10Werte[Kalender.get(Kalender.DAY_OF_YEAR)] = max;
            y10Werte[Kalender.get(Kalender.DAY_OF_YEAR) + 1] = 0;
        }
        dataset = new TimeSeries("");

        for (i = 0; i < 366; i++) {

            dataset.add(xTime[i], y10Werte[i]);

        }
        TimeSeriesCollection dataset10 = new TimeSeriesCollection(dataset);
        plot.setDataset(Linecount + 1, dataset10);
        plot.mapDatasetToRangeAxis(Linecount + 1, 0);

        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, Color.white);

        plot.setRenderer(Linecount + 1, renderer);
        plot.getDomainAxis().setAutoRange(false);
        axis.setRange(0, max);

    }

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        axis2.setRange(0, axis2.getRange().getUpperBound() * 1.5);
        axis3.setRange(0, axis3.getRange().getUpperBound() * 2);
        plot.setDomainCrosshairValue(
                (double) new GregorianCalendar(Jahr, Today.get(Today.MONTH), Today.get(Today.DAY_OF_MONTH))
                        .getTimeInMillis());

    }

    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);
    Panel.setDismissDelay(100000);

    return Panel;

}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java

/***********************************************************************************************
 * Customise the XYPlot of a new chart, e.g. for fixed range axes.
 * Remember that a GPS Scatter Plot has no ChannelSelector.
 *
 * @param datasettype//  w ww  .  j a  va 2s .  co  m
 * @param primarydataset
 * @param secondarydatasets
 * @param updatetype
 * @param displaylimit
 * @param channelselector
 * @param debug
 *
 * @return JFreeChart
 */

public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
        final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "GpsScatterPlotUIComponent.createCustomisedChart() ";
    final JFreeChart jFreeChart;
    final XYPlot plot;
    final Stroke strokeCrosshair;
    final XYDotRenderer renderer;
    final ValueAxis axisRange;
    final NumberAxis axisDomain;

    // See ChartHelper for other calls to ChartFactory
    // Note that no ChannelSector means no way to control the legend, so turn it off
    jFreeChart = ChartFactory.createScatterPlot(MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA,
            MSG_WAITING_FOR_DATA, primarydataset, PlotOrientation.VERTICAL, false, //channelselector.hasLegend(),
            true, false);

    jFreeChart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor());

    // Experimental chart configuration
    jFreeChart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f));

    plot = (XYPlot) jFreeChart.getPlot();

    plot.setBackgroundPaint(ChartHelper.COLOR_PLOT);
    plot.setDomainGridlinePaint(ChartHelper.COLOR_GRIDLINES);
    plot.setRangeGridlinePaint(ChartHelper.COLOR_GRIDLINES);
    plot.setAxisOffset(ChartHelper.PLOT_RECTANGLE_INSETS);

    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(false);

    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairLockedOnData(true);

    // Make the Crosshair more visible by changing the width from the default
    strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke
            BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke
            BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet
            0.0f, // The limit to trim the miter join
            new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern
            0.0f); // The offset to start the dashing pattern
    plot.setDomainCrosshairStroke(strokeCrosshair);
    plot.setRangeCrosshairStroke(strokeCrosshair);

    renderer = new XYDotRenderer();
    renderer.setDotWidth(2);
    renderer.setDotHeight(2);
    plot.setRenderer(renderer);

    axisDomain = (NumberAxis) plot.getDomainAxis();
    axisRange = plot.getRangeAxis();

    // Remember that a GPS Scatter Plot has no ChannelSelector
    if (canAutorange()) {
        // The fix could be anywhere...
        axisDomain.setAutoRangeIncludesZero(false);
        axisDomain.setAutoRange(true);
        axisRange.setAutoRange(true);
    } else {
        // Allow range to full global extents!
        axisDomain.setRange(getLinearFixedMinY(), getLinearFixedMaxY());
        axisRange.setRange(-90.0, 90.0);
    }

    return (jFreeChart);
}

From source file:v800_trainer.XYGraphik.java

public JPanel StartGraphik(JCicloTronic JTronicHandle) {

    int num = 0;//from  w  w  w.j a  v  a 2  s .c  o  m
    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);
}

From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java

public TrackerTab(Program program) {
    super(program, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true);

    filterDialog = new TrackerFilterDialog(program);

    jPopupMenu = new JPopupMenu();
    jPopupMenu.addPopupMenuListener(listener);

    JMenuItem jMenuItem;//from  w  ww  . j av a2  s .  c  om
    jMenuItem = new JMenuItem(TabsTracker.get().edit(), Images.EDIT_EDIT.getIcon());
    jMenuItem.setActionCommand(TrackerAction.EDIT.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    jMenuItem = new JMenuItem(TabsTracker.get().delete(), Images.EDIT_DELETE.getIcon());
    jMenuItem.setActionCommand(TrackerAction.DELETE.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    JMenuInfo.createDefault(jPopupMenu);

    jIskValue = new JMenuItem();
    jIskValue.setEnabled(false);
    jIskValue.setForeground(Color.BLACK);
    jIskValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon());
    jPopupMenu.add(jIskValue);

    jDateValue = new JMenuItem();
    jDateValue.setEnabled(false);
    jDateValue.setForeground(Color.BLACK);
    jDateValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jPopupMenu.add(jDateValue);

    jEditDialog = new JTrackerEditDialog(program);

    jSelectionDialog = new JSelectionDialog(program);

    JSeparator jDateSeparator = new JSeparator();

    jQuickDate = new JComboBox<QuickDate>(QuickDate.values());
    jQuickDate.setActionCommand(TrackerAction.QUICK_DATE.name());
    jQuickDate.addActionListener(listener);

    JLabel jFromLabel = new JLabel(TabsTracker.get().from());
    jFrom = createDateChooser();

    JLabel jToLabel = new JLabel(TabsTracker.get().to());
    jTo = createDateChooser();

    jAll = new JCheckBox(General.get().all());
    jAll.setSelected(true);
    jAll.setActionCommand(TrackerAction.ALL.name());
    jAll.addActionListener(listener);
    jAll.setFont(new Font(jAll.getFont().getName(), Font.ITALIC, jAll.getFont().getSize()));

    jTotal = new JCheckBox(TabsTracker.get().total());
    jTotal.setSelected(true);
    jTotal.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jTotal.addActionListener(listener);

    jWalletBalance = new JCheckBox(TabsTracker.get().walletBalance());
    jWalletBalance.setSelected(true);
    jWalletBalance.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jWalletBalance.addActionListener(listener);

    jWalletBalanceFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jWalletBalanceFilters.setActionCommand(TrackerAction.FILTER_WALLET_BALANCE.name());
    jWalletBalanceFilters.addActionListener(listener);

    jAssets = new JCheckBox(TabsTracker.get().assets());
    jAssets.setSelected(true);
    jAssets.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jAssets.addActionListener(listener);

    jAssetsFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jAssetsFilters.setActionCommand(TrackerAction.FILTER_ASSETS.name());
    jAssetsFilters.addActionListener(listener);

    jSellOrders = new JCheckBox(TabsTracker.get().sellOrders());
    jSellOrders.setSelected(true);
    jSellOrders.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jSellOrders.addActionListener(listener);

    jEscrows = new JCheckBox(TabsTracker.get().escrows());
    jEscrows.setSelected(true);
    jEscrows.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrows.addActionListener(listener);

    jEscrowsToCover = new JCheckBox(TabsTracker.get().escrowsToCover());
    jEscrowsToCover.setSelected(true);
    jEscrowsToCover.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrowsToCover.addActionListener(listener);

    jManufacturing = new JCheckBox(TabsTracker.get().manufacturing());
    jManufacturing.setSelected(true);
    jManufacturing.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jManufacturing.addActionListener(listener);

    jContractCollateral = new JCheckBox(TabsTracker.get().contractCollateral());
    jContractCollateral.setSelected(true);
    jContractCollateral.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractCollateral.addActionListener(listener);

    jContractValue = new JCheckBox(TabsTracker.get().contractValue());
    jContractValue.setSelected(true);
    jContractValue.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractValue.addActionListener(listener);

    JSeparator jOwnersSeparator = new JSeparator();

    jAllProfiles = new JCheckBox(TabsTracker.get().allProfiles());
    jAllProfiles.setActionCommand(TrackerAction.PROFILE.name());
    jAllProfiles.addActionListener(listener);

    jOwners = new JMultiSelectionList<String>();
    jOwners.getSelectionModel().addListSelectionListener(listener);
    JScrollPane jOwnersScroll = new JScrollPane(jOwners);

    JLabel jHelp = new JLabel(TabsTracker.get().help());
    jHelp.setIcon(Images.MISC_HELP.getIcon());

    JLabel jNoFilter = new JLabel(TabsTracker.get().helpLegacyData());
    jNoFilter.setIcon(new ShapeIcon(NO_FILTER));

    JLabel jFilter = new JLabel(TabsTracker.get().helpNewData());
    jFilter.setIcon(new ShapeIcon(FILTER_AND_DEFAULT));

    JDropDownButton jSettings = new JDropDownButton(Images.DIALOG_SETTINGS.getIcon());

    jIncludeZero = new JCheckBoxMenuItem(TabsTracker.get().includeZero());
    jIncludeZero.setSelected(true);
    jIncludeZero.setActionCommand(TrackerAction.INCLUDE_ZERO.name());
    jIncludeZero.addActionListener(listener);
    jSettings.add(jIncludeZero);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setDateFormatOverride(dateFormat);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setAutoTickUnitSelection(true);
    domainAxis.setAutoRange(true);
    domainAxis.setTickLabelFont(jFromLabel.getFont());

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRange(true);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    rangeAxis.setTickLabelFont(jFromLabel.getFont());

    //XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, true));
    render = new MyRender();
    XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, render);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.getRenderer()
            .setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {2} ({1})", dateFormat, iskFormat));
    plot.setDomainCrosshairLockedOnData(true);
    plot.setDomainCrosshairStroke(new BasicStroke(1));
    plot.setDomainCrosshairPaint(Color.BLACK);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);

    jNextChart = new JFreeChart(plot);
    jNextChart.setAntiAlias(true);
    jNextChart.setBackgroundPaint(jPanel.getBackground());
    jNextChart.addProgressListener(null);
    jNextChart.getLegend().setItemFont(jFrom.getFont());

    jChartPanel = new ChartPanel(jNextChart);
    jChartPanel.addMouseListener(listener);
    jChartPanel.setDomainZoomable(false);
    jChartPanel.setRangeZoomable(false);
    jChartPanel.setPopupMenu(null);
    jChartPanel.addChartMouseListener(listener);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawWidth(10);
    jChartPanel.setMinimumDrawHeight(10);

    int AssetsGapWidth = PANEL_WIDTH - jAssets.getPreferredSize().width
            - jAssetsFilters.getPreferredSize().width;
    if (AssetsGapWidth < 0) {
        AssetsGapWidth = 0;
    }
    int WalletGapWidth = PANEL_WIDTH - jWalletBalance.getPreferredSize().width
            - jWalletBalanceFilters.getPreferredSize().width;
    if (WalletGapWidth < 0) {
        WalletGapWidth = 0;
    }

    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(jHelp).addGap(20).addComponent(jNoFilter)
                    .addGap(20).addComponent(jFilter).addGap(20, 20, Integer.MAX_VALUE).addComponent(jSettings)
                    .addGap(6))
            .addComponent(jChartPanel)).addGroup(
                    layout.createParallelGroup().addComponent(jQuickDate, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFromLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH)
                                            .addComponent(jToLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH))
                                    .addGap(0)
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFrom, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)
                                            .addComponent(jTo, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)))
                            .addComponent(jDateSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jTotal, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup().addComponent(jWalletBalance)
                                    .addGap(0, 0, WalletGapWidth).addComponent(jWalletBalanceFilters))
                            .addGroup(layout.createSequentialGroup().addComponent(jAssets)
                                    .addGap(0, 0, AssetsGapWidth).addComponent(jAssetsFilters))
                            .addComponent(jSellOrders, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrows, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrowsToCover, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jManufacturing, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractCollateral, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractValue, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAllProfiles, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersScroll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)));
    layout.setVerticalGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
                    .addComponent(jHelp, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jNoFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jSettings, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight()))
                    .addComponent(jChartPanel))
            .addGroup(layout.createSequentialGroup()
                    .addComponent(jQuickDate, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jFromLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jFrom, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jToLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jTo, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addComponent(jDateSeparator, 3, 3, 3)
                    .addComponent(jAll, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jTotal, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jWalletBalance, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight())
                            .addComponent(jWalletBalanceFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jAssets, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jAssetsFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrows, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrowsToCover, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractCollateral, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractValue, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersSeparator, 3, 3, 3)
                    .addComponent(jAllProfiles, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersScroll, 70, 70, Integer.MAX_VALUE)));
}