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:org.jfree.chart.demo.HistogramDemo.java

/**
 * Creates a sample {@link HistogramDataset}.
 * //from   www.j  a v  a 2s. c o m
 * @return The dataset.
 */
private IntervalXYDataset createDataset() {
    final HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("H1", gaussianData(1000, 3.0), 20);
    dataset.addSeries("H0", gaussianData(1000, 0), 20);
    return dataset;
}

From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java

private HistogramDataset getDataSet() {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY);

    List<Double> values = CollectionUtils.mapNullRemoves(download.getAllValidConnections(),
            new CollectionUtils.Function<BitTorrentConnection, Double>() {
                public Double evaluate(BitTorrentConnection connection) {
                    BitField bitField = connection.getRemoteBitField();
                    if (bitField == null || !connection.isOpen()) {
                        return null;
                    }//from w w w  .j  av  a  2s . c o m
                    return 100.0 * bitField.getAvailablePieceCount() / bitField.getPieceCount();
                }
            });

    dataset.addSeries("Completion", CollectionUtils.toArray(values), 50, 0.0, 100.0);
    return dataset;
}

From source file:Core.CircuitEvolution.QPace4.HistogramDemo.java

/**
 * Creates a sample {@link HistogramDataset}.
 * //from   ww w  .  ja v  a  2s. co m
 * @return The dataset.
 */
private IntervalXYDataset createDataset() {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("H1", gaussianData(1000, 3.0), 20);
    dataset.addSeries("H0", gaussianData(1000, 0), 20);
    return dataset;
}

From source file:biz.ixnay.pivot.charts.skin.jfree.HistogramViewSkin.java

private HistogramDataset createDataSet(HistogramView chartView) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY);
    for (Object object : chartView.getChartData()) {
        HistogramSeries<?> histogramSeries = (HistogramSeries<?>) object;
        dataset.addSeries(histogramSeries.getName(), getValues(histogramSeries), histogramSeries.getBinCount());
    }/*  w w  w.  j  a v  a2s  . c om*/

    /*double[] values = getValues(chartView.getChartData());
    int binCount = chartView.getBinCount();
            
            
    dataset.addSeries("", values, binCount);*/

    return dataset;
}

From source file:edu.gmu.cs.sim.util.media.chart.HistogramGenerator.java

protected void update() {
    // We have to rebuild the dataset from scratch (deleting and replacing it) because JFreeChart's
    // histogram facility doesn't have a way to remove or move elements.  Stupid stupid stupid.

    SeriesAttributes[] sa = getSeriesAttributes();
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(histogramType);

    for (int i = 0; i < sa.length; i++) {
        HistogramSeriesAttributes attributes = (HistogramSeriesAttributes) (sa[i]);
        dataset.addSeries(new UniqueString(attributes.getSeriesName()), attributes.getValues(),
                attributes.getNumBins());
    }/*from  w  w w  .  jav a 2 s .c om*/

    setSeriesDataset(dataset);
}

From source file:edu.gmu.cs.sim.util.media.chart.HistogramGenerator.java

protected void buildChart() {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY); // when buildChart() is called, histogramType hasn't been set yet.

    chart = ChartFactory.createHistogram("Untitled Chart", "Untitled X Axis", "Untitled Y Axis", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setAntiAlias(true);// w  w  w  . j a v a 2s .  com
    //chartPanel = new ScrollableChartPanel(chart, true);         
    chartPanel = buildChartPanel(chart);
    setChartPanel(chartPanel);
    //chartHolder.getViewport().setView(chartPanel);
    ((XYBarRenderer) (chart.getXYPlot().getRenderer())).setShadowVisible(false);
    ((XYBarRenderer) (chart.getXYPlot().getRenderer())).setBarPainter(new StandardXYBarPainter());

    // this must come last because the chart must exist for us to set its dataset
    setSeriesDataset(dataset);
}

From source file:syg_package01.PanelRysunek2.java

private void initGUI() {
    try {/* w ww. java 2 s  . c o  m*/
        GridLayout thisLayout = new GridLayout(1, 1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setColumns(1);
        this.setLayout(thisLayout);
        setPreferredSize(new Dimension(400, 300));

        if (this.wykres) {
            double punkt = this.sygnalWyswietlany.gett1();
            HistogramDataset histogramDataset = new HistogramDataset();
            histogramDataset.setType(HistogramType.FREQUENCY);
            ArrayList<Double> punkty = new ArrayList<Double>();

            double ta = this.sygnalWyswietlany.gett1();

            if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY
                    || sygnalWyswietlany.getPunktyY().size() <= 0) {
                while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) {
                    punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta);
                    // this.sygnalWyswietlany.setPunktyY (punkt);
                    punkty.add(punkt);
                    ta = ta + this.sygnalWyswietlany.getkroczek();
                }
            } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY) {
                int iloscProbek = (int) (this.sygnalWyswietlany.getT()
                        / (Double) this.sygnalWyswietlany.getkroczek());
                for (int i = 0; i < iloscProbek; i++) {
                    punkt = this.sygnalWyswietlany.getPunktzindexu(i);
                    punkty.add(punkt);
                    ta = ta + this.sygnalWyswietlany.getkroczek();
                }
            }

            JFreeChart chartHist;
            if (this.iloscPrzedzialowHistogramu > 0) {
                double[] tablicaHistogramu = new double[punkty.size()];
                for (int licznik = 0; licznik < punkty.size(); ++licznik)
                    tablicaHistogramu[licznik] = punkty.get(licznik);

                histogramDataset.addSeries("Histogram (" + iloscPrzedzialowHistogramu + ")", tablicaHistogramu,
                        this.iloscPrzedzialowHistogramu);

                chartHist = ChartFactory.createHistogram("Histogram", null, null, histogramDataset,
                        PlotOrientation.VERTICAL, true, false, false);

                final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                renderer.setSeriesLinesVisible(0, false);

                ChartPanel chartpanel1 = new ChartPanel(chartHist);
                chartpanel1.setDomainZoomable(true);

                this.add(chartpanel1);
            }
        }
        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Demo.HistGraph.java

private JFreeChart CreateChart(String para) {
    // read .dat file
    double[] value = Utils.GetParaTab(para);

    // generate chart
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY);
    dataset.addSeries(para, value, 20);/*w w  w .  j  a  va2  s  . c o  m*/

    String plotTitle = para;
    String xaxis = "value";
    String yaxis = "frequecy";
    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);

    final XYPlot xyPlot = chart.getXYPlot();
    final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.BLUE);

    return chart;
}

From source file:edu.gmu.cs.sim.util.media.chart.HistogramGenerator.java

public HistogramGenerator() {
    // buildChart is called by super() first

    LabelledList list = new LabelledList("Show Histogram...");
    DisclosurePanel pan1 = new DisclosurePanel("Show Histogram...", list);

    final HistogramType[] styles = new HistogramType[] { HistogramType.FREQUENCY,
            HistogramType.RELATIVE_FREQUENCY, HistogramType.SCALE_AREA_TO_1 };
    final JComboBox style = new JComboBox(
            new String[] { "By Frequency", "By Relative Frequency", "With Area = 1.0" });
    style.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            histogramType = styles[style.getSelectedIndex()];
            HistogramDataset dataset = (HistogramDataset) (getSeriesDataset());
            dataset.setType(histogramType);
        }//from  www  . j a  va2s  .  co  m
    });
    list.add(style);
    addGlobalAttribute(pan1);
}

From source file:presenter.MainPresenter.java

@Override
public void createHistogram() {
    HistogramDataset histData = new HistogramDataset();
    histData.setType(HistogramType.FREQUENCY);
    double[] values = this.emissionsequenceModel.getEmissionsAsArray();
    histData.addSeries("H1", values, EmissionsequenceModel.EMISSIONCOUNT);

    JFreeChart chart;/*from  ww  w  .  jav  a 2s.  c o  m*/
    if (this.model != null) {
        chart = ChartFactory.createHistogram(this.model.getName(), "EmissionID", "Frequency", histData,
                PlotOrientation.VERTICAL, false, false, false);
    } else {
        chart = ChartFactory.createHistogram("unknown Model", "EmissionID", "Frequency", histData,
                PlotOrientation.VERTICAL, false, false, false);
    }
    new HistogramView(new ChartPanel(chart));
}