Example usage for org.jfree.data.statistics SimpleHistogramDataset SimpleHistogramDataset

List of usage examples for org.jfree.data.statistics SimpleHistogramDataset SimpleHistogramDataset

Introduction

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

Prototype

public SimpleHistogramDataset(Comparable key) 

Source Link

Document

Creates a new histogram dataset.

Usage

From source file:org.ow2.clif.jenkins.chart.FixedSliceSizeDistributionChart.java

public FixedSliceSizeDistributionChart(String testplan, String bladeId, String event,
        ChartConfiguration chartConfiguration) {
    super("FixedSliceSizeDistribution", bladeId, testplan, event, chartConfiguration);

    this.data = new SimpleHistogramDataset(this.chartId.getEvent());
}

From source file:org.jfree.data.statistics.SimpleHistogramDatasetTest.java

/**
 * Ensure that the equals() method can distinguish all fields.
 *//*w  ww. j  a v  a 2 s .c  o m*/
@Test
public void testEquals() {
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");
    SimpleHistogramDataset d2 = new SimpleHistogramDataset("Dataset 1");
    assertTrue(d1.equals(d2));

    d1.addBin(new SimpleHistogramBin(1.0, 2.0));
    assertFalse(d1.equals(d2));
    d2.addBin(new SimpleHistogramBin(1.0, 2.0));
    assertTrue(d1.equals(d2));
}

From source file:org.jfree.data.statistics.SimpleHistogramDatasetTest.java

/**
 * Some checks for the clone() method.//w w  w  .  ja  v  a2s. co m
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");
    SimpleHistogramDataset d2 = (SimpleHistogramDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // check that clone is independent of the original
    d2.addBin(new SimpleHistogramBin(2.0, 3.0));
    d2.addObservation(2.3);
    assertFalse(d1.equals(d2));
}

From source file:org.jfree.data.statistics.SimpleHistogramDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//*w  ww.  j a  v a2 s  . co  m*/
@Test
public void testSerialization() {
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1");
    SimpleHistogramDataset d2 = (SimpleHistogramDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

From source file:ch.zhaw.ias.dito.ui.util.SingleHistogramPanel.java

private SimpleHistogramDataset createDataset() {
    this.dataset = new SimpleHistogramDataset("");
    dataset.setAdjustForBinSize(false);/*from   w ww  . j av  a2s  . com*/
    return dataset;
}

From source file:org.jfree.expdemo.SelectionDemo4.java

/**
 * Creates a sample {@link HistogramDataset}.
 * /*from  ww  w. ja va2s  .  c o  m*/
 * @return the dataset.
 */
private static IntervalXYDataset createDataset() {
    SimpleHistogramDataset dataset = new SimpleHistogramDataset("H1");
    double lower = 0.0;
    for (int i = 0; i < 100; i++) {
        double upper = (i + 1) / 10.0;
        SimpleHistogramBin bin = new SimpleHistogramBin(lower, upper, true, false);
        dataset.addBin(bin);
        lower = upper;
    }
    double[] values = new double[1000];
    Random generator = new Random(12345678L);
    for (int i = 0; i < 1000; i++) {
        values[i] = generator.nextGaussian() + 5;
    }
    dataset.addObservations(values);
    return dataset;
}

From source file:org.jfree.data.statistics.SimpleHistogramDatasetTest.java

/**
 * Some checks for the clearObservations() method.
 *//*from w  w  w . j a v  a2 s. c o m*/
@Test
public void testClearObservations() {
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1");
    d1.clearObservations();
    assertEquals(0, d1.getItemCount(0));
    d1.addBin(new SimpleHistogramBin(0.0, 1.0));
    d1.addObservation(0.5);
    assertEquals(1.0, d1.getYValue(0, 0), EPSILON);
}

From source file:imageviewer.tools.HistogramTool.java

public void plot(MouseEvent e) {

    if (e.getSource() instanceof ImagePanel) {
        Image image = ((ImagePanel) e.getSource()).getSource();
        Histogram h = image.getHistogram();
        SimpleHistogramDataset shd = new SimpleHistogramDataset("Voxel distribution");
        for (int i = 0, numBands = h.getNumBands(); i < numBands; i++) {
            int[] binData = h.getBins(i);
            for (int j = 0; j < binData.length; j++) {
                SimpleHistogramBin shb = new SimpleHistogramBin(j - 0.5, j + 0.5, true, false);
                shb.setItemCount(binData[j]);
                shd.addBin(shb);/*from ww w  . j av a 2s  . c o m*/
            }
        }
        double[] domainBounds = null, rangeBounds = null;
        if (chart != null) {
            ValueAxis va = chart.getXYPlot().getDomainAxis();
            domainBounds = new double[] { va.getLowerBound(), va.getUpperBound() };
            va = chart.getXYPlot().getRangeAxis();
            rangeBounds = new double[] { va.getLowerBound(), va.getUpperBound() };
        }
        chart = ChartFactory.createHistogram(null, "Voxel value", "Count", shd, PlotOrientation.VERTICAL, false,
                true, false);
        chart.setBackgroundPaint(new Color(20, 30, 45));
        chart.setAntiAlias(true);
        ValueAxis domainAxis = chart.getXYPlot().getDomainAxis();
        domainAxis.setLabelFont(axisFont);
        domainAxis.setTickLabelFont(tickFont);
        domainAxis.setAxisLinePaint(Color.white);
        domainAxis.setTickLabelPaint(Color.white);
        domainAxis.setLabelPaint(Color.white);
        if (domainBounds != null) {
            domainAxis.setAutoRange(false);
            domainAxis.setLowerBound(domainBounds[0]);
            domainAxis.setUpperBound(domainBounds[1]);
        } else {
            domainAxis.setLowerBound(0);
        }
        ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
        rangeAxis.setLabelFont(axisFont);
        rangeAxis.setTickLabelFont(tickFont);
        rangeAxis.setAxisLinePaint(Color.white);
        rangeAxis.setTickLabelPaint(Color.white);
        rangeAxis.setLabelPaint(Color.white);
        if (rangeBounds != null) {
            rangeAxis.setAutoRange(false);
            rangeAxis.setLowerBound(rangeBounds[0]);
            rangeAxis.setUpperBound(rangeBounds[1]);
        }
        chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(0, 51, 113));
        ((XYBarRenderer) chart.getXYPlot().getRenderer()).setDrawBarOutline(false);
        chart.getXYPlot().setBackgroundAlpha(0.05f);

        double[] mean = h.getMean();
        double[] sd = h.getStandardDeviation();
        IntervalMarker im = new IntervalMarker(mean[0] - sd[0] / 2, mean[0] + sd[0] / 2);
        im.setPaint(new Color(200, 200, 200, 128));
        chart.getXYPlot().addDomainMarker(0, im, Layer.BACKGROUND);
        cp.setChart(chart);
    }
}

From source file:org.jfree.data.statistics.SimpleHistogramDatasetTest.java

/**
 * Some checks for the removeAllBins() method.
 *//*from w  w  w  .  j a  v a 2  s . co  m*/
@Test
public void testRemoveAllBins() {
    SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1");
    d1.addBin(new SimpleHistogramBin(0.0, 1.0));
    d1.addObservation(0.5);
    d1.addBin(new SimpleHistogramBin(2.0, 3.0));
    assertEquals(2, d1.getItemCount(0));
    d1.removeAllBins();
    assertEquals(0, d1.getItemCount(0));
}

From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java

private JFreeChart createHistogramChart(String title, Matrix distanceMatrix) {
    int NUM_OF_BINS = 50;
    SimpleHistogramDataset dataset = new SimpleHistogramDataset("");
    dataset.setAdjustForBinSize(false);/* ww  w  .  j a va 2s.c  o m*/
    double min = distanceMatrix.extremum(false);
    double max = distanceMatrix.extremum(true);
    double spacing = (max - min) / NUM_OF_BINS;
    double currentBound = min;

    for (int i = 0; i < NUM_OF_BINS - 1; i++) {
        dataset.addBin(new SimpleHistogramBin(currentBound, (currentBound + spacing), true, false));
        currentBound += spacing;
    }
    //ensure that the maximum is included and not lost because of numerical problems
    dataset.addBin(new SimpleHistogramBin(currentBound, max, true, true));
    for (int i = 0; i < distanceMatrix.getColCount(); i++) {
        DVector v = distanceMatrix.col(i);
        dataset.addObservations(v.getValues());
    }
    return ChartFactory.createHistogram(title, Translation.INSTANCE.get("misc.graphic.distance"),
            Translation.INSTANCE.get("misc.graphic.frequency"), dataset, PlotOrientation.VERTICAL, false, true,
            false);
}