Example usage for org.jfree.data.statistics HistogramDataset setType

List of usage examples for org.jfree.data.statistics HistogramDataset setType

Introduction

In this page you can find the example usage for org.jfree.data.statistics HistogramDataset setType.

Prototype

public void setType(HistogramType type) 

Source Link

Document

Sets the histogram type and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java

/**
 * For a single well, generate an histogram dataset.
 *
 * @param data//from w w w  . java2  s. com
 * @param seriesKey
 * @param mapTo360
 * @return an HistogramDataset
 */
private HistogramDataset getHistogramDatasetForAWell(String seriesKey, Double[] data, int bins,
        HistogramType type, boolean mapTo360) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(type);
    double[] toPrimitive = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(data));
    double[] toAdd;
    if (!mapTo360) {
        toAdd = toPrimitive;
    } else {
        double[] mappedData = new double[toPrimitive.length];
        for (int i = 0; i < toPrimitive.length; i++) {
            if (toPrimitive[i] > 0) {
                mappedData[i] = toPrimitive[i];
            } else {
                mappedData[i] = toPrimitive[i] + 360;
            }
        }
        toAdd = mappedData;
    }
    dataset.addSeries(seriesKey, toAdd, bins);
    return dataset;
}

From source file:net.bioclipse.chembl.business.ChEMBLManager.java

public void moSSViewHistogram(IStringMatrix matrix) throws BioclipseException {

    XYSeries series = new XYSeries("Activity for compounds");
    HistogramDataset histogramSeries = new HistogramDataset();
    histogramSeries.setType(HistogramType.FREQUENCY);
    ArrayList<Double> activites = new ArrayList<Double>();
    double value;
    int cnt = 1;//  ww w  .  j a v a 2 s .c o m
    double[] histact = new double[matrix.getRowCount() + 1];
    for (int i = 1; i < matrix.getRowCount() + 1; i++) {
        if (matrix.get(i, "actval").equals("")) {
            value = 0;
        } else {
            value = Double.parseDouble(matrix.get(i, "actval"));
        }
        activites.add(value);
    }
    //Sort list to increasing order of activities and adds them to histogram
    Collections.sort(activites);
    for (int i = 0; i < activites.size(); i++) {
        double d = activites.get(i);
        histact[i] = d;
        int t = activites.size() - 1;
        if (i == t) {
            series.add(d, cnt);
        } else {
            double dd = activites.get(i + 1);

            if (d == dd) {
                cnt++;
            } else {
                histact[i] = d;
                series.add(d, cnt);
                cnt = 1;
            }
        }
    }
    histogramSeries.addSeries("Histogram", histact, matrix.getRowCount());
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Histogram", "Activity values",
            "Number of compounds", histogramSeries, PlotOrientation.VERTICAL, true, false, false);

    ChartFrame frame = new ChartFrame("Activities", jfreechart);
    frame.pack();
    frame.setVisible(true);
}

From source file:MSUmpire.DIA.TargetMatchScoring.java

public void MixtureModeling() throws IOException {
    if (libTargetMatches.isEmpty()) {
        return;/*from ww w .j a  va2 s.  c  o  m*/
    }
    int IDNo = 0;
    int decoyNo = 0;
    int modelNo = 0;
    double IDmean = 0d;
    double Decoymean = 0d;

    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null) {
            IDNo++;
            IDmean += match.BestHit.UmpireScore;
        }
    }

    decoyNo = decoyModelingList.size();
    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        Decoymean += peakGroupScore.UmpireScore;
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //modelNo+= match.TargetHits.size();
        if (match.BestMS1Hit != null) {
            modelNo++;
        }
        if (match.BestMS2Hit != null) {
            modelNo++;
        }
    }

    Decoymean /= decoyNo;
    IDmean /= IDNo;

    PVector[] points = new PVector[modelNo];
    PVector[] centroids = new PVector[2];

    int idx = 0;
    for (UmpireSpecLibMatch match : libTargetMatches) {
        if (match.BestMS1Hit != null) {
            points[idx] = new PVector(1);
            points[idx].array[0] = match.BestMS1Hit.UmpireScore;
            idx++;
        }
        if (match.BestMS2Hit != null) {
            points[idx] = new PVector(1);
            points[idx].array[0] = match.BestMS2Hit.UmpireScore;
            idx++;
        }
        //            for(PeakGroupScore peakGroupScore : match.TargetHits){
        //                points[idx] = new PVector(1);
        //                points[idx].array[0] = match.BestMS2Hit.UmpireScore;
        //                idx++;
        //            }
    }

    MixtureModel mmc;
    centroids[0] = new PVector(1);
    centroids[0].array[0] = Decoymean;
    centroids[1] = new PVector(1);
    centroids[1].array[0] = IDmean;
    Vector<PVector>[] clusters = KMeans.run(points, 2, centroids);
    MixtureModel mm = ExpectationMaximization1D.initialize(clusters);
    mmc = ExpectationMaximization1D.run(points, mm);
    DecimalFormat df = new DecimalFormat("#.####");
    Logger.getRootLogger()
            .debug("----------------------------------------------------------------------------------------");
    Logger.getRootLogger().debug("No. of modeling points=" + modelNo);
    Logger.getRootLogger().debug("ID hits mean=" + df.format(IDmean));
    Logger.getRootLogger().debug("Decoy hits mean=" + df.format(Decoymean));
    //System.out.print("T-test: p-value=" + df.format(model.ttest.pValue).toString() + "\n");
    Logger.getRootLogger()
            .debug("Incorrect hits model mean=" + df.format(((PVector) mmc.param[0]).array[0]) + " variance="
                    + df.format(((PVector) mmc.param[0]).array[1]) + " weight=" + df.format(mmc.weight[0]));
    Logger.getRootLogger()
            .debug("Correct hits model mean=" + df.format(((PVector) mmc.param[1]).array[0]) + " variance="
                    + df.format(((PVector) mmc.param[1]).array[1]) + " weight=" + df.format(mmc.weight[1]));

    if (((PVector) mmc.param[0]).array[0] > ((PVector) mmc.param[1]).array[0]) {
        return;
    }

    float max = (float) (((PVector) mmc.param[1]).array[0] + 4 * Math.sqrt(((PVector) mmc.param[1]).array[1]));
    float min = (float) (((PVector) mmc.param[0]).array[0] - 4 * Math.sqrt(((PVector) mmc.param[0]).array[1]));

    IDNo = 0;
    decoyNo = 0;
    modelNo = 0;

    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        if (peakGroupScore.UmpireScore > min && peakGroupScore.UmpireScore < max) {
            decoyNo++;
        }
    }

    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null && match.BestHit.UmpireScore > min && match.BestHit.UmpireScore < max) {
            IDNo++;
        }
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //targetNo += match.TargetHits.size();
        //decoyNo += match.DecoyHits.size();
        if (match.BestMS1Hit != null && match.BestMS1Hit.UmpireScore > min
                && match.BestMS1Hit.UmpireScore < max) {
            modelNo++;
        }
        if (match.BestMS2Hit != null && match.BestMS2Hit.UmpireScore > min
                && match.BestMS2Hit.UmpireScore < max) {
            modelNo++;
        }
        //modelNo += match.TargetHits.size();            
    }

    double[] IDObs = new double[IDNo];
    double[] DecoyObs = new double[decoyNo];
    double[] ModelObs = new double[modelNo];
    idx = 0;
    int didx = 0;
    int midx = 0;
    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null && match.BestHit.UmpireScore > min && match.BestHit.UmpireScore < max) {
            IDObs[idx++] = match.BestHit.UmpireScore;
        }
    }
    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        if (peakGroupScore.UmpireScore > min && peakGroupScore.UmpireScore < max) {
            DecoyObs[didx++] = peakGroupScore.UmpireScore;
        }
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //            for(PeakGroupScore peak : match.TargetHits){
        //                ModelObs[midx++]=peak.UmpireScore;
        //            }
        if (match.BestMS1Hit != null && match.BestMS1Hit.UmpireScore > min
                && match.BestMS1Hit.UmpireScore < max) {
            ModelObs[midx++] = match.BestMS1Hit.UmpireScore;
        }
        if (match.BestMS2Hit != null && match.BestMS2Hit.UmpireScore > min
                && match.BestMS2Hit.UmpireScore < max) {
            ModelObs[midx++] = match.BestMS2Hit.UmpireScore;
        }
    }

    String pngfile = FilenameUtils.getFullPath(Filename) + "/" + FilenameUtils.getBaseName(Filename) + "_"
            + LibID + "_LibMatchModel.png";
    XYSeries model1 = new XYSeries("Incorrect matches");
    XYSeries model2 = new XYSeries("Correct matches");
    XYSeries model3 = new XYSeries("All target hits");

    String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile)
            + "_ModelPoints.txt";
    FileWriter writer = new FileWriter(modelfile);
    writer.write("UScore\tModel\tCorrect\tDecoy\n");

    int NoPoints = 1000;
    double[] model_kde_x = new double[NoPoints];
    float intv = (max - min) / NoPoints;
    PVector point = new PVector(2);
    for (int i = 0; i < NoPoints; i++) {
        point.array[0] = max - i * intv;
        model_kde_x[i] = point.array[0];
        point.array[1] = mmc.EF.density(point, mmc.param[0]) * mmc.weight[0];
        model1.add(point.array[0], point.array[1]);
        point.array[1] = mmc.EF.density(point, mmc.param[1]) * mmc.weight[1];
        model2.add(point.array[0], point.array[1]);

    }

    KernelDensityEstimator kde = new KernelDensityEstimator();
    kde.SetData(ModelObs);
    double[] model_kde_y = kde.Density(model_kde_x);

    for (int i = 0; i < NoPoints; i++) {
        if (model_kde_x[i] > min && model_kde_x[i] < max) {
            point.array[0] = max - i * intv;
            model_kde_x[i] = point.array[0];
            model3.add(model_kde_x[i], model_kde_y[i]);
            writer.write(point.array[0] + "\t" + mmc.EF.density(point, mmc.param[0]) * mmc.weight[0] + "\t"
                    + mmc.EF.density(point, mmc.param[1]) * mmc.weight[1] + "\t" + model_kde_y[i] + "\n");
        }
    }
    writer.close();
    MixtureModelProb = new float[NoPoints + 1][3];
    float positiveaccu = 0f;
    float negativeaccu = 0f;

    MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
    MixtureModelProb[0][1] = 1f;
    MixtureModelProb[0][2] = 1f;

    for (int i = 1; i < NoPoints + 1; i++) {
        float positiveNumber = model2.getY(NoPoints - i).floatValue();
        float negativeNumber = model1.getY(NoPoints - i).floatValue();
        MixtureModelProb[i][0] = model2.getX(NoPoints - i).floatValue();
        positiveaccu += positiveNumber;
        negativeaccu += negativeNumber;
        MixtureModelProb[i][2] = positiveNumber / (negativeNumber + positiveNumber);
        MixtureModelProb[i][1] = positiveaccu / (negativeaccu + positiveaccu);
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(model1);
    dataset.addSeries(model2);
    dataset.addSeries(model3);

    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
    histogramDataset.addSeries("ID hits", IDObs, 100);
    histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
    //histogramDataset.addSeries("Model hits", ModelObs, 100);

    JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits",
            histogramDataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = chart.getXYPlot();

    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(min, max);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setForegroundAlpha(0.8f);
    chart.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
    //        render.setSeriesPaint(0, Color.DARK_GRAY);
    //        render.setSeriesPaint(1, Color.DARK_GRAY); 
    //        render.setSeriesPaint(2, Color.GREEN); 
    //        render.setSeriesShape(0, new Ellipse2D.Double(0, 0, 2, 2));
    //        render.setSeriesShape(1, new Ellipse2D.Double(0, 0, 2, 2));
    //        render.setSeriesShape(2, new Ellipse2D.Double(0, 0, 2.5f, 2.5f));
    //        render.setSeriesStroke(1, new BasicStroke(1.0f));
    //        render.setSeriesStroke(0, new BasicStroke(1.0f));
    //        render.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setDataset(1, dataset);
    plot.setRenderer(1, render);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    try {
        ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
    } catch (IOException e) {
    }
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoHf(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;/*from   w w w . ja v  a2  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;// ww w.  j  a  va  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("", "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;// w w w. ja 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("", "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;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoHm(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;/*from  w w w.  j  a v a2s .  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("", "Steigung [m/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;
    }
    ;

    try {
        von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHm", "100"));
        bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHm", "200"));
        Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHm", "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].Steigm_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].Steigm_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: 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;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoCd(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;//from w w w .  j a v a  2s .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("", "Cadence [n/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;
    }

    try {
        von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonCd", "100"));
        bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisCd", "200"));
        Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepCd", "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].Cadence_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].Cadence_gesZeit[m];
                        if (Buffer >= von && Buffer <= bis) {
                            Bufferarray.add(Buffer);
                        }

                    }
                    n += m;
                }
            }

            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, "StartHistoCd\nFehler: Cd " + 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:pipeline.GUI_utils.JXTablePerColumnFiltering.java

public void updateRangeOfColumn(int columnIndex, boolean reinitializeSelection, int boundsToUpdate,
        boolean suppressModelInit) {
    if (!suppressModelInit) {
        needToInitializeFilterModel = true;
        initializeFilterModel();/* ww  w.  j a  v a 2  s .co m*/
    }
    boolean isFloat = model.getValueAt(0, columnIndex) instanceof Float;
    boolean isDouble = model.getValueAt(0, columnIndex) instanceof Double;
    boolean isInteger = model.getValueAt(0, columnIndex) instanceof Integer;
    boolean isSpreadsheetCell = model.getValueAt(0, columnIndex) instanceof SpreadsheetCell;
    if (!(isFloat || isInteger || isSpreadsheetCell || isDouble))
        return;
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;

    double[] valuesForHistogram = new double[model.getRowCount()];

    for (int i = 0; i < model.getRowCount(); i++) {
        double value;
        if (isFloat)
            value = (Float) model.getValueAt(i, columnIndex);
        else if (isDouble)
            value = (Double) model.getValueAt(i, columnIndex);
        else if (isInteger)
            value = (Integer) model.getValueAt(i, columnIndex);
        else {
            value = ((SpreadsheetCell) model.getValueAt(i, columnIndex)).getFloatValue();
        }
        if (Double.isNaN(value))
            value = 0.0d;
        if (value < min)
            min = value;
        if (value > max)
            max = value;
        valuesForHistogram[i] = value;
    }

    // Now compute a histogram; this could be optimized

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("Histogram", valuesForHistogram, 15);

    if (isFloat || isDouble || isSpreadsheetCell) {
        FloatRangeParameter param = (FloatRangeParameter) filteringModel.getValueAt(0, columnIndex);
        param.histogram = dataset;
        float[] currentValue = (float[]) param.getValue();
        if ((boundsToUpdate == BOTH_BOUNDS) || boundsToUpdate == LOWER_BOUND)
            currentValue[2] = (float) min;
        if ((boundsToUpdate == BOTH_BOUNDS) || boundsToUpdate == UPPER_BOUND)
            currentValue[3] = (float) max;
        if (reinitializeSelection) {
            currentValue[0] = currentValue[2];
            currentValue[1] = currentValue[3];
        }
        param.setValueFireIfAppropriate(currentValue, false, true, true);
    } else {
        IntRangeParameter param = (IntRangeParameter) filteringModel.getValueAt(0, columnIndex);
        int[] currentValue = (int[]) param.getValue();
        if ((boundsToUpdate == BOTH_BOUNDS) || boundsToUpdate == LOWER_BOUND)
            currentValue[2] = (int) min;
        if ((boundsToUpdate == BOTH_BOUNDS) || boundsToUpdate == UPPER_BOUND)
            currentValue[3] = (int) max;
        if (reinitializeSelection) {
            currentValue[0] = currentValue[2];
            currentValue[1] = currentValue[3];
        }
        param.setValueFireIfAppropriate(currentValue, false, true, true);
    }
}