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

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

Introduction

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

Prototype

public void setAxisOffset(RectangleInsets offset) 

Source Link

Document

Sets the axis offsets (gap between the data area and the axes) and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel, Color color, double domainBounds[], double rangeBounds[]) {
    JFreeChart chart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, // Legend?
            true, // tooltips
            false // url
    );/* ww  w.  jav  a2s . c o m*/
    final XYPlot xyPlot = chart.getXYPlot();
    //xyPlot.setForegroundAlpha(0.85f);
    xyPlot.setNoDataMessage("No data");
    xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 10));
    // xyPlot.setInsets(new RectangleInsets(0,0,0,0));

    // todo Danny set bounds here

    //        if (domainBounds[0] != domainBounds[1]) {
    //            xyPlot.getDomainAxis().setLowerBound(domainBounds[0]);
    //            xyPlot.getDomainAxis().setUpperBound(domainBounds[1]);
    //        }
    //
    //        if (rangeBounds[0] != rangeBounds[1]) {
    //            xyPlot.getRangeAxis().setLowerBound(rangeBounds[0]);
    //            xyPlot.getRangeAxis().setUpperBound(rangeBounds[1]);
    //        }

    if (!Double.isNaN(domainBounds[0])) {
        xyPlot.getDomainAxis().setLowerBound(domainBounds[0]);
    }

    if (!Double.isNaN(domainBounds[1])) {
        xyPlot.getDomainAxis().setUpperBound(domainBounds[1]);
    }

    if (!Double.isNaN(rangeBounds[0])) {
        xyPlot.getRangeAxis().setLowerBound(rangeBounds[0]);
    }

    if (!Double.isNaN(rangeBounds[1])) {
        xyPlot.getRangeAxis().setUpperBound(rangeBounds[1]);
    }

    final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setSeriesPaint(0, color);
    StandardXYBarPainter painter = new StandardXYBarPainter();
    renderer.setBarPainter(painter);

    ChartPanel chartPanel = new ChartPanel(chart);
    //// todo Danny testing out height/width ratio preservation
    //        double histChartHeightWidthRatio = chartPanel.getPreferredSize().height / chartPanel.getPreferredSize().width;
    //        double plotSizeReduction = 1;
    //        Number preferredHeight = chartPanel.getPreferredSize().height * plotSizeReduction;
    //        Number preferredWidth = chartPanel.getPreferredSize().width * plotSizeReduction;
    //
    //        chartPanel.setPreferredSize(new Dimension(preferredWidth.intValue(), preferredHeight.intValue()));

    //  chartPanel.setPreferredSize(new Dimension(300, 200));

    //        chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem());
    return chartPanel;
}

From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java

/**
 * Creates a chart./*from   w ww  .  j a v a2s.  co  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
// protected JFreeChart createChart(XYDataset dataset, double[][] polygons, int num_poly) {

protected JFreeChart createChart(XYDataset[] dataset) {
    //System.out.println("createChart get called");
    boolean legend = false;
    /*if (num_series>1&&segment_flag==false)
       legend = true;*/

    //   System.out.println("createchart: inde="+independentVarLength);
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset[0], // data
            PlotOrientation.VERTICAL, legend, // include legend
            true, // tooltips
            false // urls
    );

    //printDataset(dataset, num_series);

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

    // get a reference to the plot for further customisation...
    XYPlot subplot1 = (XYPlot) chart.getPlot();
    subplot1.setBackgroundPaint(Color.lightGray);
    subplot1.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    subplot1.setDomainGridlinePaint(Color.white);
    subplot1.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) subplot1.getRenderer();

    renderer1.setBaseLinesVisible(false);
    renderer1.setBaseShapesVisible(true);
    renderer1.setBaseShapesFilled(true);

    int[] num_group = new int[num_series];
    Paint color_mainGroup = mEMexperiment[0].getColorOfMainGroup();

    // use same color   for all series if EM together    
    //  System.out.println("dataset0. seriescount="+dataset[0].getSeriesCount()+" itemcount="+dataset[0].getItemCount(0));
    if (num_series == 1)
        for (int s = 0; s < dataset[0].getSeriesCount(); s++) {
            renderer1.setSeriesLinesVisible(s, false);
            renderer1.setSeriesShapesVisible(s, true);
            renderer1.setSeriesShapesFilled(s, true);
            renderer1.setSeriesShape(s, series_shapes[0]); // for the shape of the dots
            renderer1.setSeriesPaint(s, color_mainGroup);
        }

    //  System.out.println("num_series="+num_series);
    //   System.out.println("num_group="+num_group);
    //  System.out.println("segment_flag="+segment_flag);

    if (legend) {
        LegendItemCollection legends_old = subplot1.getFixedLegendItems();
        LegendItemCollection legends_new = new LegendItemCollection();
        for (int s = 0; s < num_series; s++) {
            legends_new.add(legends_old.get(s));
        }
        subplot1.setFixedLegendItems(legends_new);

    }
    //segment

    for (int s = 0; s < num_series; s++) {
        num_group[s] = mEMexperiment[s].getNumOfGroup();
    }

    // System.out.println("num_group[0]="+num_group[0]);

    if (num_group[0] > 0 && segment_flag && (mixSelected == CG_MIX)) {
        Paint[] color_groups = mEMexperiment[0].getColorOfGroups();

        for (int i = 0; i < num_group[0] - 1; i++) {
            //System.out.println("color "+ i +"=" + color_groups[i].toString());
            renderer1.setSeriesPaint(i, color_groups[i]);
        }
        //System.out.println("color main ="+ color_mainGroup.toString());
        renderer1.setSeriesPaint(nkSelected, color_mainGroup);
    } else
        renderer1.setBasePaint(color_mainGroup);

    // renderer1.setShape(series_shapes[0]);   

    // subplot1.setDataset(0, dataset[0]);
    //System.out.println("setting renderer for " +0);
    //   subplot1.setRenderer(0, renderer1);
    // System.out.println("SOCR_EM creatChart: pt0="+dataset.getXValue(0, 0)+ ","+dataset.getYValue(0, 0));

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) subplot1.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    //   rangeAxis.setUpperMargin(0);
    //  rangeAxis.setLowerMargin(0);

    NumberAxis domainAxis = (NumberAxis) subplot1.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAutoRangeIncludesZero(true);
    //  domainAxis.setUpperMargin(0);
    //  domainAxis.setLowerMargin(0);

    XYLineAndShapeRenderer[] renderer1a = new XYLineAndShapeRenderer[num_series];
    if (num_series > 1) {
        for (int s = 0; s < num_series; s++) {
            //   System.out.println("adding pt for series:"+s +": seriesCount "+ dataset[s].getSeriesCount()+"itemcount="+dataset[s].getItemCount(0));
            renderer1a[s] = new XYLineAndShapeRenderer();
            if (num_group[0] > 0 && segment_flag && (mixSelected == CG_MIX)) {
                Paint[] color_groups = mEMexperiment[0].getColorOfGroups();

                for (int i = 0; i < num_group[0] - 1; i++) {
                    //System.out.println("color "+ i +"=" + color_groups[i].toString());
                    renderer1a[s].setSeriesPaint(i, color_groups[i]);
                }
                //System.out.println("color main ="+ color_mainGroup.toString());
                renderer1a[s].setSeriesPaint(nkSelected, color_mainGroup);
            } else
                renderer1a[s].setBasePaint(color_mainGroup);
            renderer1a[s].setBaseLinesVisible(false);
            renderer1a[s].setBaseShapesVisible(true);
            renderer1a[s].setBaseShapesFilled(true);
            renderer1a[s].setBaseShape(series_shapes[s]); // different shape of dots for each pair of input    
            subplot1.setDataset(s, dataset[s]);
            // System.out.println("setting renderer for " +s);
            subplot1.setRenderer(s, renderer1a[s]);
        }

    }

    if (kernels != null) {
        /*  System.out.println("draw kernels");
          System.out.println("num_series="+num_series);
          System.out.println("nkSelected="+nkSelected);*/
        XYLineAndShapeRenderer[][] renderer2 = new XYLineAndShapeRenderer[num_series][nkSelected];
        for (int s = 0; s < num_series; s++) {

            Paint[] color_kernels = mEMexperiment[s].getColorOfKernels();
            // System.out.println("SOCR_EM creatChart adding kernels:" +num_kernels+ "ws[0]="+ws[0]);
            for (int i = 0; i < nkSelected; i++) {
                // System.out.println("drawing kernel for series: "+s +" kernel:" +i);
                //  System.out.println("SOCR_EM creatChart: kernel "+i+" pt0="+kernels[i].getXValue(0, 0)+","+kernels[i].getYValue(0, 0));
                renderer2[s][i] = new XYLineAndShapeRenderer();
                renderer2[s][i].setBaseStroke(series_strokes[s]);
                renderer2[s][i].setBaseLinesVisible(true);
                renderer2[s][i].setBaseShapesVisible(false);
                //  renderer2[s][i].setShapesFilled(false);
                renderer2[s][i].setBasePaint(color_kernels[i]);
                subplot1.setDataset(num_series - 1 + s * num_series + i + 1, kernels[s][i]);
                // System.out.println("setting renderer for " +(num_series-1+s*num_series+i+1));
                subplot1.setRenderer(num_series - 1 + s * num_series + i + 1, renderer2[s][i]);
                //subplot1.setRangeAxis(i+1, rangeAxis);
            } //i
        } //s
    }

    segment_flag = false;
    return chart;

}

From source file:org.ramadda.geodata.cdmdata.CdmDataOutputHandler.java

/**
 * Create the chart//w  w  w. j a va2  s .  c o m
 *
 *
 * @param request  the request
 * @param entry    the entry
 * @param dataset  the dataset
 *
 * @return the chart
 */
private static JFreeChart createChart(Request request, Entry entry, XYDataset dataset) {
    LatLonPointImpl llp = new LatLonPointImpl(request.getLatOrLonValue(ARG_LOCATION + ".latitude", 0),
            request.getLatOrLonValue(ARG_LOCATION + ".longitude", 0));
    String title = entry.getName() + " at " + llp.toString();

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            //entry.getName(),  // title
            title, // title
            "Date", // x-axis label
            "", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);
    ValueAxis rangeAxis = new NumberAxis("");
    rangeAxis.setVisible(false);
    XYPlot plot = (XYPlot) chart.getPlot();
    if (request.get("gray", false)) {
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
    } else {
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.lightGray);
        plot.setRangeGridlinePaint(Color.lightGray);
    }
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeAxis(0, rangeAxis, false);

    XYItemRenderer r = plot.getRenderer();
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

private static ChartPanel getScatterPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel, Color color, double domainBounds[], double rangeBounds[]) {
    //  JFreeChart chart = ChartFactory.createScatterPlot(
    JFreeChart chart = ChartFactory.createXYLineChart(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, // Legend?
            true, // tooltips
            false // url
    );/*from   w  w  w .  jav a  2 s  .co m*/
    final XYPlot xyPlot = chart.getXYPlot();
    //   xyPlot.setForegroundAlpha(0.85f);
    xyPlot.setBackgroundAlpha(0.0f);
    xyPlot.setNoDataMessage("No data");
    xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 10));

    // todo Danny set bounds here

    //        if (domainBounds[0] != domainBounds[1]) {
    //            xyPlot.getDomainAxis().setLowerBound(domainBounds[0]);
    //            xyPlot.getDomainAxis().setUpperBound(domainBounds[1]);
    //        }
    //
    //        if (rangeBounds[0] != rangeBounds[1]) {
    //            xyPlot.getRangeAxis().setLowerBound(rangeBounds[0]);
    //            xyPlot.getRangeAxis().setUpperBound(rangeBounds[1]);
    //        }

    if (!Double.isNaN(domainBounds[0])) {
        xyPlot.getDomainAxis().setLowerBound(domainBounds[0]);
    }

    if (!Double.isNaN(domainBounds[1])) {
        xyPlot.getDomainAxis().setUpperBound(domainBounds[1]);
    }

    if (!Double.isNaN(rangeBounds[0])) {
        xyPlot.getRangeAxis().setLowerBound(rangeBounds[0]);
    }

    if (!Double.isNaN(rangeBounds[1])) {
        xyPlot.getRangeAxis().setUpperBound(rangeBounds[1]);
    }

    final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    renderer.setSeriesPaint(0, color);
    renderer.setUseFillPaint(true);
    renderer.setDrawOutlines(true);
    renderer.setSeriesShapesFilled(0, true);
    renderer.setSeriesFillPaint(0, color);

    ChartPanel chartPanel = new ChartPanel(chart);
    //    chartPanel.setPreferredSize(new Dimension(300, 200));

    return chartPanel;
}

From source file:v800_trainer.XYGraphik.java

public JPanel StartGraphik(JCicloTronic JTronicHandle) {

    int num = 0;//from  w w w  . jav  a  2s.c om
    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:hpssim.grafica.HPSsim.java

public void setQueueXY(String hw) {
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(datasetQueue);

    JFreeChart chart = ChartFactory.createXYLineChart("Queue Size - " + hw, "Tempo", "runq_sz",
            xyseriescollection, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    panelGraficoFinestra.add("Center", new ChartPanel(chart));
    panelGraficoFinestra.add("South", new Label(""));
}

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

/***********************************************************************************************
 * Create a simple Chart from the specified XYDataset.
 * Choose a TimeSeriesChart or a XYLineChart appropriately.
 * Called from createCustomisedChart() in each ChartUIComponent subclass.
 *
 *
 * @param dataset//  w  w  w. jav a  2  s . com
 * @param timezone
 * @param metadatalist
 * @param channelcount
 * @param temperaturechannel
 * @param updatetype
 * @param displaylimit
 * @param channelselector
 * @param debug
 *
 * @return JFreeChart
 */

public static JFreeChart createChart(final XYDataset dataset, final TimeZone timezone,
        final List<Metadata> metadatalist, final int channelcount, final boolean temperaturechannel,
        final DataUpdateType updatetype, final int displaylimit,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "ChartHelper.createChart() ";
    final JFreeChart chart;
    final String strTitle;
    final String strLabelX;
    final String strLabelY;
    final XYDataset xyDatasetToDisplay;

    // The set of Metadata available should include the Instrument
    // and any items from the current observation
    strTitle = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_TITLE.getKey());
    strLabelX = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_X.getKey());
    // Axis.Y.0 only in this version
    strLabelY = MetadataHelper.getMetadataValueByKey(metadatalist,
            MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey() + MetadataDictionary.SUFFIX_SERIES_ZERO);

    // Transform the XYdataset in accordance with the current ChannelSelection Mode before displaying

    channelselector.debugSelector(debug, SOURCE);

    xyDatasetToDisplay = copyTransformedXYDataset(dataset, timezone, updatetype, displaylimit,
            channelselector.isDecimating(), channelselector.getChannelSelectionModes());
    if (dataset instanceof TimeSeriesCollection) {
        chart = ChartFactory.createTimeSeriesChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay,
                channelselector.hasLegend(), true, false);
    } else {
        chart = ChartFactory.createXYLineChart(strTitle, strLabelX, strLabelY, xyDatasetToDisplay,
                PlotOrientation.VERTICAL, channelselector.hasLegend(), true, false);
    }

    if ((chart != null) && (chart.getXYPlot() != null) && (chart.getXYPlot().getRangeAxis() != null)) {
        final Stroke strokeCrosshair;
        final XYPlot plot;
        final XYItemRenderer renderer;

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

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

        plot = chart.getXYPlot();
        plot.setBackgroundPaint(COLOR_PLOT);
        plot.setDomainGridlinePaint(COLOR_GRIDLINES);
        plot.setRangeGridlinePaint(COLOR_GRIDLINES);
        plot.setAxisOffset(PLOT_RECTANGLE_INSETS);

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

        // 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);

        renderer = plot.getRenderer();

        if ((renderer != null) && (renderer instanceof XYLineAndShapeRenderer)) {
            final XYLineAndShapeRenderer xyItemRenderer;
            int intSeriesCount;

            xyItemRenderer = (XYLineAndShapeRenderer) renderer;

            xyItemRenderer.setBaseLinesVisible(true);
            xyItemRenderer.setBaseShapesVisible(false);
            xyItemRenderer.setBaseShapesFilled(true);
            xyItemRenderer.setItemLabelsVisible(true);

            // Set the shape for the Chart legend items
            ChartUIHelper.setLegendShape(xyItemRenderer);

            // Colour only as many Series as we know about
            intSeriesCount = 0;

            // Examine the state of each channel's selection
            for (int channel = 0; channel < channelcount; channel++) {
                final ChannelSelectionMode selectionMode;

                if ((channelselector.getChannelSelectionModes() != null)
                        && (channelselector.getChannelSelectionModes().size() == channelcount)) {
                    // If there is a ChannelSelector, get the gain setting, or OFF
                    selectionMode = channelselector.getChannelSelectionModes().get(channel);
                } else if (!channelselector.showChannels()) {
                    // If there is no ChannelSelector, we assume that all Channels are ON, at X1
                    selectionMode = ChannelSelectionMode.X1;
                } else {
                    // Not sure what to do, so just show all
                    selectionMode = ChannelSelectionMode.X1;
                }

                if (!ChannelSelectionMode.OFF.equals(selectionMode)) {
                    final ColourInterface colour;

                    colour = MetadataHelper.getChannelColour(metadatalist, channel, temperaturechannel);

                    MetadataHelper.showMetadataList(metadatalist, SOURCE + " COLOURS FOR CHART",
                            LOADER_PROPERTIES.isMetadataDebug());

                    if (colour != null) {
                        // Map the Colour to the Series
                        xyItemRenderer.setSeriesPaint(intSeriesCount, colour.getColor());
                    } else {
                        // Use the default colour if the metadata doesn't have it
                        LOGGER.error(SOURCE
                                + "The channel colour was missing or incorrectly specified in the Metadata, using default colour"
                                + " [channel=" + channel + "]");
                        xyItemRenderer.setSeriesPaint(intSeriesCount,
                                ChartUIHelper.getStandardColour(channel).getColor());
                    }

                    // Prepare for the next Series
                    intSeriesCount++;
                }
            }
        }
    }

    return (chart);
}

From source file:v800_trainer.JUebersicht.java

public JPanel Update_Uebersicht(JCicloTronic JTronicHandle) {

    int i;//from  www .  ja va2  s  .co m
    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.esa.beam.visat.toolviews.stat.ProfilePlotPanel.java

@Override
protected void initComponents() {
    getAlternativeView().initComponents();
    dataset = new XYIntervalSeriesCollection();
    this.chart = ChartFactory.createXYLineChart(CHART_TITLE, "Path in pixels", DEFAULT_SAMPLE_DATASET_NAME,
            dataset, PlotOrientation.VERTICAL, true, true, false);
    final XYPlot plot = chart.getXYPlot();

    deviationRenderer = new DeviationRenderer();
    deviationRenderer.setUseFillPaint(true);
    deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    deviationRenderer.setSeriesLinesVisible(0, true);
    deviationRenderer.setSeriesShapesVisible(0, false);
    deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);

    pointRenderer = new XYErrorRenderer();
    pointRenderer.setUseFillPaint(true);
    pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    pointRenderer.setSeriesLinesVisible(0, false);
    pointRenderer.setSeriesShapesVisible(0, true);
    pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE);

    configureRendererForCorrelativeData(deviationRenderer);
    configureRendererForCorrelativeData(pointRenderer);

    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setRenderer(deviationRenderer);

    final AxisChangeListener axisListener = new AxisChangeListener() {
        @Override//w  ww .jav  a2 s. c o m
        public void axisChanged(AxisChangeEvent event) {
            adjustAxisControlComponents();
        }
    };

    final ValueAxis domainAxis = plot.getDomainAxis();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    // allow transfer from bounds into min/max fields, if auto min/maxis enabled
    domainAxis.setAutoRange(true);
    rangeAxis.setAutoRange(true);

    domainAxis.addChangeListener(axisListener);
    rangeAxis.addChangeListener(axisListener);

    intervalMarkers = new HashSet<>();

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");

    final PropertyChangeListener changeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) {
                updateDataSet();
            }
            if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) {
                updateScalingOfYAxis();
            }
            updateUIState();
        }
    };
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    xAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false));
    xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_MARK_SEGMENTS)
            .setDescription("Toggle whether to mark segments");

    yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    yAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false));
    yAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED)
            .setDescription("Toggle whether to use a logarithmic axis");

    dataSourceConfig = new DataSourceConfig();
    final BindingContext bindingContext = new BindingContext(
            PropertyContainer.createObjectBacked(dataSourceConfig));

    JPanel middlePanel = createMiddlePanel(bindingContext);
    createUI(createChartPanel(chart), middlePanel, bindingContext);

    isInitialized = true;

    updateComponents();
}

From source file:org.ramadda.geodata.cdmdata.PointDatabaseTypeHandler.java

/**
 * _more_/*  w  ww. j  a v a  2 s.c  o m*/
 *
 *
 * @param request _more_
 * @param entry _more_
 * @param dataset _more_
 *
 * @return _more_
 */
private static JFreeChart createChart(Request request, Entry entry, XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            request.getString(ARG_POINT_TIMESERIES_TITLE, entry.getName()), // title
            "Date", // x-axis label
            "", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);
    ValueAxis rangeAxis = new NumberAxis("");
    rangeAxis.setVisible(false);
    XYPlot plot = (XYPlot) chart.getPlot();
    if (request.get("gray", false)) {
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
    } else {
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.lightGray);
        plot.setRangeGridlinePaint(Color.lightGray);
    }
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeAxis(0, rangeAxis, false);

    XYItemRenderer r = plot.getRenderer();
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}