Example usage for org.jfree.chart ChartFactory createHistogram

List of usage examples for org.jfree.chart ChartFactory createHistogram

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createHistogram.

Prototype

public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel,
        IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips,
        boolean urls) 

Source Link

Document

Creates a histogram chart.

Usage

From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java

private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel, Color color) {
    JFreeChart chart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, // Legend?
            true, // tooltips
            false // url
    );/*  w w  w. j  a  v  a 2s. c  o  m*/
    final XYPlot xyPlot = chart.getXYPlot();
    //xyPlot.setForegroundAlpha(0.85f);
    xyPlot.setNoDataMessage("No data");
    xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    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);
    chartPanel.setPreferredSize(new Dimension(300, 200));
    //        chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem());
    return chartPanel;
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoSchrittlnge(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;/*from  w ww.j  a va2s .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:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 *
 * @return/*from  ww  w .  j a  va  2  s.c o  m*/
 */
protected JFreeChart histogramIDProbs() {
    HistogramDataset dataset = new HistogramDataset();

    List<Double> histDataList = new ArrayList<Double>();

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (AmtPeptideEntry entry : entries) {
        if (entry.getNumObservations() > 1)
            histDataList.add((double) entry.calculateIDProbability());
    }
    double[] histData = new double[histDataList.size()];

    for (int i = 0; i < histData.length; i++)
        histData[i] = histDataList.get(i);

    ApplicationContext.setMessage("Mean ID probability: " + BasicStatistics.mean(histData));

    dataset.addSeries("ID probablity", histData, 200);

    JFreeChart chart = ChartFactory.createHistogram("id_probability", "id_probability", "id_probability",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    PanelWithChart pwc = new PanelWithChart(chart);
    pwc.setName("id probs");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java

private JFreeChart createHistogramChart(String transportMode, double[] travelTimes) {

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("evacuation travel time " + transportMode, travelTimes, 20);

    JFreeChart chart = ChartFactory.createHistogram(null, null, "frequency", dataset, PlotOrientation.VERTICAL,
            true, false, false);//from  w  w  w  . ja va 2  s  .c o m
    chart.getXYPlot().setForegroundAlpha(0.75f);

    /*
     * set x-axis range 
     */
    double min = 0.0;
    double max = maxEvacuationTime;
    if (limitMaxEvacuationTime) {
        double cutOffValue = meanEvacuationTime + standardDeviation * evacuationTimeCutOffFactor;
        max = cutOffValue;
    }
    chart.getXYPlot().getDomainAxis().setLowerBound(min);
    chart.getXYPlot().getDomainAxis().setUpperBound(max);

    return chart;
}

From source file:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 * Show a histogram of the standard deviations of hydrophobicity observations per peptide
 * @return//from w  w  w .ja v  a2s.  c om
 */
protected JFreeChart histogramHydroStdDev() {
    HistogramDataset dataset = new HistogramDataset();

    List<Double> histDataList = new ArrayList<Double>();

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (int i = 0; i < amtDB.numEntries(); i++) {
        if (entries[i].getNumObservations() > 1)
            histDataList.add(entries[i].getHydrophobicityStandardDeviation());
    }
    double[] histData = new double[histDataList.size()];

    for (int i = 0; i < histData.length; i++)
        histData[i] = histDataList.get(i);

    ApplicationContext.setMessage("Mean H standard deviation: " + BasicStatistics.mean(histData));

    dataset.addSeries("hyd_std_dev", histData, 100);

    JFreeChart chart = ChartFactory.createHistogram("hydstddev", "hydstddev", "hydstddev", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    PanelWithChart pwc = new PanelWithChart(chart);
    pwc.setName("mean h std devs");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 * Histogram all masses in the database/*from   w  w  w  .j  a v  a  2  s .c  o  m*/
 * @return
 */
protected JFreeChart histogramMasses() {
    HistogramDataset dataset = new HistogramDataset();

    double[] histData = new double[amtDB.numEntries()];

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (int i = 0; i < amtDB.numEntries(); i++) {
        histData[i] = entries[i].getMass();

    }
    dataset.addSeries("masses", histData, 500);

    JFreeChart chart = ChartFactory.createHistogram("masses", "masses", "masses", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    ChartDialog cd2 = new ChartDialog(chart);
    cd2.setSize(800, 600);
    PanelWithChart pwc = new PanelWithChart(chart);

    pwc.setName("masses");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:simulation.AureoZauleckAnsLab2.java

public static JFreeChart createHistogram(ArrayList doubleMatrix, int width, String title, String label) {

    // Generate a one dimensional array of the size w*h of the double matrix
    ArrayList<Double> dataArrayList = new ArrayList<Double>();

    for (int i = 0; i < doubleMatrix.size(); i++) {

        double value = Double.parseDouble(doubleMatrix.get(i).toString());
        if (Double.isNaN(value))
            continue;
        else/*  w w w . ja v a  2s . c om*/
            dataArrayList.add(value);
        System.out.println(value);
    }

    double[] data = new double[dataArrayList.size()];

    for (int p = 0; p < dataArrayList.size(); p++)
        data[p] = dataArrayList.get(p);

    // int number = data.length;
    HistogramDataset dataset = new HistogramDataset();

    dataset.setType(HistogramType.FREQUENCY);
    dataset.addSeries("Hist", data, width);
    String plotTitle = title;
    String yAxis = "Frequency";
    String xAxis = label;
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, dataset, orientation, show,
            toolTips, urls);

    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    JFrame l = new JFrame();
    l.setContentPane(chartPanel);
    l.setSize(400, 400);
    l.setVisible(true);

    return chart;
}

From source file:jchrest.gui.Shell.java

private JPanel getHistogramPane(Map<Integer, Integer> contentSizes, String label, String title, String xAxis) {
    int largest = 0;
    for (Integer key : contentSizes.keySet()) {
        if (key > largest)
            largest = key;/*from   ww  w  .  ja  v  a2  s.  co  m*/
    }
    SimpleHistogramDataset dataset = new SimpleHistogramDataset(label);
    for (int i = 0; i <= largest; ++i) {
        SimpleHistogramBin bin = new SimpleHistogramBin((double) i, (double) (i + 1), true, false);
        int count = 0;
        if (contentSizes.containsKey(i)) {
            count = contentSizes.get(i);
        }
        bin.setItemCount(count);
        dataset.addBin(bin);
    }
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = true;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(title, xAxis, "frequency", dataset, orientation, show,
            toolTips, urls);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(new ChartPanel(chart, 400, 300, 200, 100, 600, 600, true, true, true, true, true, true));
    JButton saveButton = new JButton("Save Data");
    saveButton.setToolTipText("Save the histogram data to a CSV file");
    saveButton.addActionListener(new SaveHistogramActionListener(this, contentSizes));
    panel.add(saveButton, BorderLayout.SOUTH);
    return panel;
}

From source file:MSUmpire.DIA.TargetMatchScoring.java

public void MixtureModeling() throws IOException {
    if (libTargetMatches.isEmpty()) {
        return;/*from ww  w .  j a va  2 s .  co 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:fr.inria.soctrace.framesoc.ui.histogram.view.HistogramView.java

/**
 * Refresh the UI using the current dataset
 * /* w w  w . j  a va2  s.c  om*/
 * @param first
 *            flag indicating if it is the first refresh for a given load
 */
private void refresh(final boolean first, final boolean cancelled, final boolean keepZoom) {

    if (dataset == null) {
        return;
    }

    /*
     * Prepare data
     */

    DeltaManager dm = new DeltaManager();
    dm.start();
    // get the last snapshot
    HistogramDataset hdataset = dataset.getSnapshot(loadedInterval);
    // if we have not been cancelled, the x range corresponds to the requested interval
    final TimeInterval histogramInterval = new TimeInterval(requestedInterval);
    if (cancelled) {
        // we have been cancelled, the x range corresponds to the actual loaded interval
        histogramInterval.copy(loadedInterval);
    }
    if (keepZoom && plot != null) {
        long min = (long) plot.getDomainAxis().getRange().getLowerBound();
        long max = (long) plot.getDomainAxis().getRange().getUpperBound();
        TimeInterval displayed = new TimeInterval(min, max);
        histogramInterval.copy(displayed);
    }

    /*
     * Prepare chart
     */

    final JFreeChart chart = ChartFactory.createHistogram(HISTOGRAM_TITLE, X_LABEL, Y_LABEL, hdataset,
            PlotOrientation.VERTICAL, HAS_LEGEND, HAS_TOOLTIPS, HAS_URLS);

    // customize plot
    preparePlot(first, chart, histogramInterval);

    // display chart in UI
    displayChart(chart, histogramInterval, first);

    logger.debug(dm.endMessage("Finished refreshing"));
}