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

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

Introduction

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

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the domain axis, and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:speedbagalg.OscopeView.java

/**
 * Creates new form OscopeView/*from   w  ww .j  av  a 2  s.  c  o  m*/
 */
/*    
    public OscopeView(String fileName)
    {
this.fileName = fileName;
initComponents();
updateThread = new RunnableMember2(this, "updateGUI");
ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true));
// create a dataset...
int maxAge = 2400;
this.xData = new TimeSeries("X axis");
this.xData.setMaximumItemAge(maxAge);
this.yData = new TimeSeries("Y axis");
this.yData.setMaximumItemAge(maxAge);
this.zData = new TimeSeries("Z axis");
this.zData.setMaximumItemAge(maxAge);
this.averageData = new TimeSeries("Avg. Data");
this.averageData.setMaximumItemAge(maxAge);
//this.windSpeedSeries = new TimeSeries("Wind Speed");
//this.windSpeedSeries.setMaximumItemAge(maxAge);
//this.rainSeries = new TimeSeries("Rain 24hrs");
//this.rainSeries.setMaximumItemAge(maxAge);
        
final TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(xData);
dataset.addSeries(yData);
dataset.addSeries(zData);
dataset.addSeries(averageData);
        
//dataset.addSeries(windSpeedSeries);
//dataset.addSeries(rainSeries);
final JFreeChart chart = ChartFactory.createTimeSeriesChart(
        "Accel Data",
        "Time",
        "Value",
        dataset,
        true,
        true,
        false);
final XYPlot plot = chart.getXYPlot();
        
ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(true);
axis = plot.getRangeAxis();
axis.setRange(-1000.0, 10000.0);
        
chart.setBackgroundPaint(Color.white);
        
//XYPlot plot = (XYPlot) chart.getPlot();
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);
        
// create and display a frame...
thePanel = new ChartPanel(chart);
        
Dimension d = new Dimension(200, 100);
thePanel.setSize(d);
thePanel.setPreferredSize(d);
BorderLayout layout = new BorderLayout();
jPanelOscope.setLayout(layout);
jPanelOscope.add(thePanel, BorderLayout.CENTER);
        
plotXCheckBox.setSelected(plotX);
plotYCheckBox.setSelected(plotY);
plotZCheckBox.setSelected(plotZ);
    }
*/
public OscopeView(String fileName) {
    this.fileName = fileName;
    initComponents();
    updateThread = new RunnableMember2(this, "updateGUI");
    ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true));
    // create a dataset...
    this.xData = new XYSeries("Min");
    //this.xData.setMaximumItemAge(maxAge);
    this.yData = new XYSeries("Peak");
    //this.yData.setMaximumItemAge(maxAge);
    this.zData = new XYSeries("Z axis");
    //this.zData.setMaximumItemAge(maxAge);
    this.averageData = new XYSeries("Avg. Data");
    //this.averageData.setMaximumItemAge(maxAge);
    //this.windSpeedSeries = new TimeSeries("Wind Speed");
    //this.windSpeedSeries.setMaximumItemAge(maxAge);
    //this.rainSeries = new TimeSeries("Rain 24hrs");
    //this.rainSeries.setMaximumItemAge(maxAge);

    final XYSeriesCollection dataset = new XYSeriesCollection();
    //SlidingCategoryDataset dataset = new SlidingCategoryDataset(0, 10);
    dataset.addSeries(xData);
    dataset.addSeries(yData);
    dataset.addSeries(zData);
    dataset.addSeries(averageData);

    //dataset.addSeries(windSpeedSeries);
    //dataset.addSeries(rainSeries);
    chart = ChartFactory.createXYLineChart("Accel Data", "Time", "Value", dataset, PlotOrientation.VERTICAL,
            true, true, false);
    final XYPlot plot = chart.getXYPlot();

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(false);
    axis.setRange(minStart, maxDomain);
    axis = plot.getRangeAxis();
    axis.setRange(vMin, vMax);

    chart.setBackgroundPaint(Color.white);

    //XYPlot plot = (XYPlot) chart.getPlot();
    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);

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

    Dimension d = new Dimension(200, 100);
    thePanel.setSize(d);
    thePanel.setPreferredSize(d);
    BorderLayout layout = new BorderLayout();
    jPanelOscope.setLayout(layout);
    jPanelOscope.add(thePanel, BorderLayout.CENTER);

    plotXCheckBox.setSelected(plotX);
    plotYCheckBox.setSelected(plotY);
    plotZCheckBox.setSelected(plotZ);

    vMaxSpinner.setValue(vMax);
}

From source file:adams.flow.sink.JFreeChartFileWriter.java

/**
 * Executes the flow item./* ww w  .  j  a va 2 s  .c  o  m*/
 *
 * @return      null if everything is fine, otherwise error message
 */
@Override
protected String doExecute() {
    String result;
    SpreadSheet sheet;
    Dataset dataset;
    JFreeChart jfreechart;
    BufferedImage image;
    BufferedImageContainer cont;
    Shape shape;
    XYPlot plot;

    result = null;

    try {
        sheet = (SpreadSheet) m_InputToken.getPayload();
        dataset = m_Dataset.generate(sheet);
        jfreechart = m_Chart.generate(dataset);
        shape = m_Shape.generate();
        jfreechart.getPlot().setBackgroundPaint(Color.WHITE);
        if (jfreechart.getPlot() instanceof XYPlot) {
            plot = (XYPlot) jfreechart.getPlot();
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.GRAY);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.GRAY);
            plot.getRenderer().setSeriesPaint(0, m_PlotColor);
            if (plot.getSeriesCount() > 1)
                plot.getRenderer().setSeriesPaint(1, m_DiagonalColor);
            if (shape != null)
                plot.getRenderer().setSeriesShape(0, shape);
        }
        image = jfreechart.createBufferedImage(m_Width, m_Height);
        cont = new BufferedImageContainer();
        cont.setImage(image);
        m_Writer.write(m_OutputFile, cont);
    } catch (Exception e) {
        result = handleException("Failed to generate plot!", e);
    }

    return result;
}

From source file:vinci.project2.pkg1.View.java

/**
 * creates the actual chart w/ dimensions, et al
 *//*from   ww  w  .  j av  a 2s  .co m*/
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYLineChart("Pre/Post Taxes/Totals", "Age", "Amounts ($)",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:org.jfree.chart.demo.DifferenceChartDemo2.java

/**
 * Creates a chart./*from w  w  w .ja v a  2 s  .  c  o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Daylight Hours - London, UK", "Date", "Time",
            dataset, true, // legend
            true, // tool tips
            false // URLs
    );
    chart.setBackgroundPaint(Color.white);

    final XYDifferenceRenderer renderer = new XYDifferenceRenderer(Color.blue, Color.blue, false);
    renderer.setStroke(new BasicStroke(2.0f));
    renderer.setSeriesPaint(0, Color.yellow);
    renderer.setSeriesPaint(1, Color.red);
    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));

    final DateAxis domainAxis = new DateAxis("Time");
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    final Color c = new Color(255, 60, 24, 63);
    final Marker bst = new IntervalMarker(new Day(28, 3, 2004).getFirstMillisecond(),
            new Day(30, 10, 2004).getFirstMillisecond(), c, new BasicStroke(2.0f), null, null, 1.0f);
    bst.setLabel("British Summer Time");
    bst.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, 10));
    bst.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT);
    plot.addDomainMarker(bst, Layer.BACKGROUND);

    final DateAxis rangeAxis = new DateAxis("Time");
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);
    plot.setRangeAxis(rangeAxis);
    return chart;
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Plots the CMD using the existing dataset. Used whenever chart annotations change, without the
 * underlying plot data changing. This method identifies all sources lying within the boxed region
 * and loads them into the secondary list {@link #boxedSources}.
 * // w  ww.java2s .  c o m
 * @param allSources
 *    The {@link Source}s to plot
 * @return
 *    A JFreeChart presenting the colour-magnitude diagram for the current selection criteria and colours.
 */
private JFreeChart plotCmd() {

    XYSeries outside = new XYSeries("Outside");
    XYSeries inside = new XYSeries("Inside");

    // Use a Path2D.Double instance to determine polygon intersection
    Path2D.Double path = new Path2D.Double();
    boxedSources.clear();

    boolean performBoxSelection = (points.size() > 2);

    if (performBoxSelection) {
        // Initialise Path2D object
        path.moveTo(points.get(0)[0], points.get(0)[1]);
        for (double[] point : points) {
            path.lineTo(point[0], point[1]);
        }
    }

    for (Source source : selectedSources) {
        double magnitude = source.getMag(magFilter);
        double col1 = source.getMag(col1Filter);
        double col2 = source.getMag(col2Filter);

        double x = col1 - col2;
        double y = magnitude;

        if (performBoxSelection) {
            Point2D.Double point = new Point2D.Double(x, y);
            if (path.contains(point)) {
                inside.add(x, y);
                boxedSources.add(source);
            } else {
                outside.add(x, y);
            }
        } else {
            outside.add(x, y);
        }
    }

    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(outside);
    data.addSeries(inside);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new Ellipse2D.Float(-0.5f, -0.5f, 1, 1));
    renderer.setSeriesPaint(0, ChartColor.BLACK);

    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesShape(1, new Ellipse2D.Float(-0.5f, -0.5f, 1, 1));
    renderer.setSeriesPaint(1, ChartColor.RED);

    NumberAxis xAxis = new NumberAxis(col1Filter.toString() + " - " + col2Filter.toString());
    xAxis.setRange(getXRange());

    NumberAxis yAxis = new NumberAxis(magFilter.toString());
    yAxis.setRange(getYRange());
    yAxis.setInverted(true);

    // Configure plot
    XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.white);

    // Specify selection box, if points have been specified
    if (!points.isEmpty()) {

        double[] coords = new double[points.size() * 2];

        for (int i = 0; i < points.size(); i++) {
            double[] point = points.get(i);
            coords[2 * i + 0] = point[0];
            coords[2 * i + 1] = point[1];
        }
        XYPolygonAnnotation box = new XYPolygonAnnotation(coords, new BasicStroke(2.0f), Color.BLUE);
        xyplot.addAnnotation(box);
    }

    // Configure chart
    JFreeChart chart = new JFreeChart("47 Tuc CMD", xyplot);
    chart.setBackgroundPaint(Color.white);
    chart.setTitle("47 Tuc colour-magnitude diagram");
    chart.removeLegend();

    return chart;
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Computes the luminosity function for the current boxed region and plots it in a JFrame.
 * Also prints out the coordinates of the selection box vertices and the luminosity function
 * quantities.//from w  w  w.j  a  va2s. co m
 * 
 * @param sources
 *    The {@link Source}s to compute the luminosity function for.
 */
private void computeAndPlotLuminosityFunction(List<Source> sources) {

    // Print out coordinates of selection box corners
    System.out.println("# Coordinates of selection box corners:");
    System.out.println("# (" + col1Filter + "-" + col2Filter + ")\t" + magFilter);
    for (double[] point : points) {
        System.out.println("# " + point[0] + "\t" + point[1]);
    }
    System.out.println("# Luminosity function:");
    System.out.println("# Mag.\tN\tsigN");

    double magBinWidth = 0.5;

    // Get the range of the data
    double mMin = Double.MAX_VALUE;
    double mMax = -Double.MAX_VALUE;
    for (Source source : sources) {
        double mag = source.getMag(magFilter) - mu;
        mMin = Math.min(mMin, mag);
        mMax = Math.max(mMax, mag);
    }

    // Quantize this to a whole number
    mMin = Math.floor(mMin);
    mMax = Math.ceil(mMax);

    int nBins = (int) Math.rint((mMax - mMin) / magBinWidth);

    // Array to accumulate all objects in each bin
    int[] n = new int[nBins];

    for (Source source : sources) {
        double mag = source.getMag(magFilter) - mu;
        // Bin number
        int bin = (int) Math.floor((mag - mMin) / magBinWidth);
        n[bin]++;
    }

    YIntervalSeries luminosityFunction = new YIntervalSeries("Luminosity Function");

    for (int i = 0; i < nBins; i++) {
        // Bin centre
        double x = mMin + i * magBinWidth + 0.5 * magBinWidth;
        double y = n[i];
        double yErr = n[i] > 0 ? Math.sqrt(y) : 0;
        luminosityFunction.add(x, y, y - yErr, y + yErr);
        System.out.println(x + "\t" + y + "\t" + yErr);
    }

    final YIntervalSeriesCollection data = new YIntervalSeriesCollection();
    data.addSeries(luminosityFunction);

    XYErrorRenderer renderer = new XYErrorRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new Ellipse2D.Float(-1f, -1f, 2, 2));
    renderer.setSeriesPaint(0, ChartColor.BLACK);

    NumberAxis xAxis = new NumberAxis("Absolute Magnitude (" + magFilter.toString() + ")");
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    NumberAxis yAxis = new NumberAxis("N");
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(true);

    // Configure plot
    XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.white);

    // Configure chart
    JFreeChart chart = new JFreeChart("Luminosity Function", xyplot);
    chart.setBackgroundPaint(Color.white);
    chart.setTitle("47 Tuc luminosity function");
    chart.removeLegend();

    final ChartPanel lfChartPanel = new ChartPanel(chart);

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFrame tester = new JFrame();
            tester.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            tester.setLayout(new BorderLayout());
            tester.add(lfChartPanel, BorderLayout.CENTER);
            tester.pack();
            tester.setVisible(true);
        }
    });

}

From source file:org.ramadda.data.services.PointFormHandler.java

/**
 * create jfree chart//from w  w  w . java2s  .  c  o m
 *
 * @param request the request
 * @param entry The entry
 * @param dataset the dataset
 * @param backgroundImage background image
 *
 * @return the chart
 */
public static JFreeChart createTimeseriesChart(Request request, Entry entry, XYDataset dataset,
        Image backgroundImage) {
    JFreeChart chart = ChartFactory.createXYLineChart("", // chart title
            "", // x axis label
            "Height", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    DateAxis timeAxis = new DateAxis("Time", request.getRepository().TIMEZONE_UTC);
    NumberAxis valueAxis = new NumberAxis("Data");
    valueAxis.setAutoRangeIncludesZero(true);

    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.setBackgroundPaint(Color.white);
    if (backgroundImage != null) {
        plot.setBackgroundImage(backgroundImage);
        plot.setBackgroundImageAlignment(org.jfree.ui.Align.TOP_LEFT);
    }

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    plot.setAxisOffset(new RectangleInsets(5, 0, 5, 0));

    return chart;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoHf(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;/*from  w ww  . j  a  v a  2 s. c  o m*/
    int bis = 0;
    int num = 0;
    int selected;
    int single;
    int Gruppen = 0;
    int i = 100;
    int j = 10;
    int m = 0;
    int n = 0;
    int Linecount = 0;
    int Anzahl = 1;

    JFreeChart chart;

    double DummyData[] = new double[1];

    selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex();
    Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected();

    chart = ChartFactory.createHistogram("", "Herzfrequenz [p/min]", "Hufigkeit", new HistogramDataset(),
            PlotOrientation.HORIZONTAL, true, true, true);

    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.getRangeAxis().setFixedDimension(15.0);

    ArrayList Bufferarray = new ArrayList();
    double Buffer;

    if (selected == 0) {
        single = 1;
    } else {
        single = 0;
        Summenhisto = false;
    } //einzelne Tour oder alle Touren

    von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHf", "100"));
    bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHf", "200"));
    Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHf", "10"));
    Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; //komische Mathe;
    //wenn nur eine Tour ausgewhlt ist single = 0  und damit Anzahl =1
    // sonst single gleich 1 und die Anzahl ist ItemCont - 1
    for (j = 0; j < Anzahl; j++) {
        if (single == 1) {
            selected = j + 1; // single = 1 => Summe ist ausgewhlt und selected muss ein hher gesetz werden
        }
        if (!Summenhisto) {
            num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
        } else {
            num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
        }

        n = 0;

        if (!Summenhisto) {
            create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln
            for (i = start; i < stop; i++) { //hier wird nun ber alle Daten gezhlt
                Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; //aktueller Wert zwischengespeichert
                if (Buffer >= von && Buffer <= bis) {
                    Bufferarray.add(Buffer); //wenn im ges. Intervall dann in das Bufferarray
                }
            }
        } else { //Summenhist ist ausgewhlt
            for (i = 0; i < j + 1; i++) { //schlechte Schleifensteuerung i=1;i<j htte es auch getan

                create_Start_Stop(JTronicHandle, i + 1);
                for (m = start; m < stop; m++) { // Schleife ber alle Datenpunkte
                    Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Hf_gesZeit[m];
                    if (Buffer >= von && Buffer <= bis) {
                        Bufferarray.add(Buffer);
                    }
                }

            }
        }

        DummyData = new double[Bufferarray.size()];

        for (i = 0; i < Bufferarray.size(); i++) {
            DummyData[i] = new Double(Bufferarray.get(i).toString());
        }

        if (!Summenhisto) {
            HistogramDataset histoHF = new HistogramDataset();
            histoHF.addSeries(
                    "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                            + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                            + JTronicHandle.Statistikhandle.TourData[selected].Jahr,
                    DummyData, Gruppen, (double) von, (double) bis);
            histoHF.setType(HistogramType.RELATIVE_FREQUENCY);
            plot.setDataset(Linecount, histoHF);
            plot.mapDatasetToRangeAxis(Linecount, 0);
            XYBarRenderer renderer = new XYBarRenderer();
            renderer.setDrawBarOutline(true);
            //                renderer.setShadowVisible(false);

            renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl));

            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            plot.setRenderer(Linecount, renderer);

        }
        Linecount++;
    }

    if (Summenhisto) {
        HistogramDataset histoHF = new HistogramDataset();
        histoHF.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis);
        histoHF.setType(HistogramType.RELATIVE_FREQUENCY);

        plot.setDataset(0, histoHF);
        plot.mapDatasetToRangeAxis(0, 0);
        XYItemRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        plot.setRenderer(0, renderer);
    }

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

    return Panel;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoSp(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;//from   w  w w .  j a  v  a  2  s .  c o m
    int bis = 0;
    int num = 0;
    int selected;
    int single;
    int Gruppen = 0;
    int i = 100;
    int j = 10;
    int m = 0;
    int n = 0;
    int Linecount = 0;
    int Anzahl = 1;

    JFreeChart chart;

    double DummyData[] = new double[1];

    selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex();
    Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected();

    chart = ChartFactory.createHistogram("", "Geschwindigkeit [km/h]", "Hufigkeit", new HistogramDataset(),
            PlotOrientation.HORIZONTAL, true, true, true);

    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.getRangeAxis().setFixedDimension(15.0);

    ArrayList Bufferarray = new ArrayList();
    double Buffer;

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

    try {
        von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonSp", "100"));
        bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisSp", "200"));
        Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepSp", "10"));
        Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1;
        for (j = 0; j < Anzahl; j++) {
            if (single == 1) {
                selected = j + 1;
            }
            if (!Summenhisto) {
                num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            } else {
                num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            }

            n = 0;
            if (!Summenhisto) {
                create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln

                for (i = start; i < stop; i++) {
                    Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Geschw_gesZeit[i];
                    if (Buffer >= von && Buffer <= bis) {
                        Bufferarray.add(Buffer);
                    }
                }
            } else {
                for (i = 0; i < j + 1; i++) {
                    create_Start_Stop(JTronicHandle, i + 1);
                    for (m = start; m < stop; m++) {
                        Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Geschw_gesZeit[m];
                        if (Buffer >= von && Buffer <= bis) {
                            Bufferarray.add(Buffer);
                        }

                    }
                }
            }

            DummyData = new double[Bufferarray.size()];

            for (i = 0; i < Bufferarray.size(); i++) {
                DummyData[i] = new Double(Bufferarray.get(i).toString());
            }

            if (!Summenhisto) {
                HistogramDataset histoHM = new HistogramDataset();
                histoHM.addSeries(
                        "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Jahr,
                        DummyData, Gruppen, (double) von, (double) bis);
                histoHM.setType(HistogramType.RELATIVE_FREQUENCY);
                plot.setDataset(Linecount, histoHM);
                plot.mapDatasetToRangeAxis(Linecount, 0);
                XYBarRenderer renderer = new XYBarRenderer();
                renderer.setDrawBarOutline(true);

                renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl));

                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                plot.setRenderer(Linecount, renderer);

            }
            Linecount++;
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "StartHistoSp\nFehler: Sp " + e + " " + i + " " + j, "Achtung!",
                JOptionPane.ERROR_MESSAGE);
    }

    if (Summenhisto) {
        HistogramDataset histoHM = new HistogramDataset();
        histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis);
        histoHM.setType(HistogramType.RELATIVE_FREQUENCY);

        plot.setDataset(0, histoHM);
        plot.mapDatasetToRangeAxis(0, 0);
        XYItemRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        plot.setRenderer(0, renderer);
    }
    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);

    return Panel;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoSchrittlnge(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;/*from   www .  j a v  a 2  s . co  m*/
    int bis = 0;
    int num = 0;
    int selected;
    int single;
    int Gruppen = 0;
    int i = 100;
    int j = 10;
    int m = 0;
    int n = 0;
    int Linecount = 0;
    int Anzahl = 1;

    JFreeChart chart;

    double DummyData[] = new double[1];

    selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex();
    Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected();

    chart = ChartFactory.createHistogram("", "Schrittlnge [cm]", "Hufigkeit", new HistogramDataset(),
            PlotOrientation.HORIZONTAL, true, true, true);

    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.getRangeAxis().setFixedDimension(15.0);

    ArrayList Bufferarray = new ArrayList();
    double Buffer;

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

    try {
        von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonSchrittlnge", "100"));
        bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisSchrittlnge", "200"));
        Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepSchrittlnge", "10"));
        Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1;
        for (j = 0; j < Anzahl; j++) {
            if (single == 1) {
                selected = j + 1;
            }
            if (!Summenhisto) {
                num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            } else {
                num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            }

            n = 0;
            if (!Summenhisto) {
                create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln

                for (i = start; i < stop; i++) {
                    Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i];
                    if (Buffer >= von && Buffer <= bis) {
                        Bufferarray.add(Buffer);
                    }
                }
            } else {
                for (i = 0; i < j + 1; i++) {
                    create_Start_Stop(JTronicHandle, i + 1);
                    for (m = start; m < stop; m++) {
                        Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Schritt_lnge[m];
                        if (Buffer >= von && Buffer <= bis) {
                            Bufferarray.add(Buffer);
                        }

                    }

                }
            }

            DummyData = new double[Bufferarray.size()];

            for (i = 0; i < Bufferarray.size(); i++) {
                DummyData[i] = new Double(Bufferarray.get(i).toString());
            }

            if (!Summenhisto) {
                HistogramDataset histoHM = new HistogramDataset();
                histoHM.addSeries(
                        "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Jahr,
                        DummyData, Gruppen, (double) von, (double) bis);
                histoHM.setType(HistogramType.RELATIVE_FREQUENCY);
                plot.setDataset(Linecount, histoHM);
                plot.mapDatasetToRangeAxis(Linecount, 0);
                XYBarRenderer renderer = new XYBarRenderer();
                renderer.setDrawBarOutline(true);

                renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl));

                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                plot.setRenderer(Linecount, renderer);

            }
            Linecount++;
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "StartHistoSchrittlnge\nFehler: Hm " + e + " " + i + " " + j,
                "Achtung!", JOptionPane.ERROR_MESSAGE);
    }

    if (Summenhisto) {
        HistogramDataset histoHM = new HistogramDataset();
        histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis);
        histoHM.setType(HistogramType.RELATIVE_FREQUENCY);

        plot.setDataset(0, histoHM);
        plot.mapDatasetToRangeAxis(0, 0);
        XYItemRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        plot.setRenderer(0, renderer);
    }
    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);

    return Panel;
}