Example usage for org.jfree.data.xy XYIntervalDataItem XYIntervalDataItem

List of usage examples for org.jfree.data.xy XYIntervalDataItem XYIntervalDataItem

Introduction

In this page you can find the example usage for org.jfree.data.xy XYIntervalDataItem XYIntervalDataItem.

Prototype

public XYIntervalDataItem(double x, double xLow, double xHigh, double y, double yLow, double yHigh) 

Source Link

Document

Creates a new instance of XYIntervalItem.

Usage

From source file:org.jfree.data.xy.XYIntervalDataItemTest.java

/**
 * Some checks for the constructor./*from   www  . j  a  v  a 2 s .com*/
 */
@Test
public void testConstructor1() {
    XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    assertEquals(new Double(1.0), item1.getX());
    assertEquals(0.5, item1.getXLowValue(), EPSILON);
    assertEquals(1.5, item1.getXHighValue(), EPSILON);
    assertEquals(2.0, item1.getYValue(), EPSILON);
    assertEquals(1.9, item1.getYLowValue(), EPSILON);
    assertEquals(2.1, item1.getYHighValue(), EPSILON);
}

From source file:org.jfree.data.xy.XYIntervalDataItemTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///  ww  w  .j  a v a 2 s. c  o m
@Test
public void testEquals() {
    XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    XYIntervalDataItem item2 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    assertTrue(item1.equals(item2));
    assertTrue(item2.equals(item1));

    // x
    item1 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1);
    assertTrue(item1.equals(item2));

    // xLow
    item1 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1);
    assertTrue(item1.equals(item2));

    // xHigh
    item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1);
    assertTrue(item1.equals(item2));

    // y
    item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1);
    assertTrue(item1.equals(item2));

    // yLow
    item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1);
    assertTrue(item1.equals(item2));

    // yHigh
    item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11);
    assertFalse(item1.equals(item2));
    item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11);
    assertTrue(item1.equals(item2));
}

From source file:org.jfree.data.xy.XYIntervalDataItemTest.java

/**
 * Some checks for the clone() method.//from w w w .j a v  a 2s  .  com
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    XYIntervalDataItem item2 = (XYIntervalDataItem) item1.clone();
    assertTrue(item1 != item2);
    assertTrue(item1.getClass() == item2.getClass());
    assertTrue(item1.equals(item2));
}

From source file:org.jfree.data.xy.XYIntervalDataItemTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from w w  w . java2s  . co  m
@Test
public void testSerialization() {
    XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    XYIntervalDataItem item2 = (XYIntervalDataItem) TestUtilities.serialised(item1);
    assertEquals(item1, item2);
}

From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java

@SuppressWarnings("unchecked")
@Override//w w w .j  a  v  a 2 s.  co m
protected void resetSerie(final IScope scope, final String serieid) {
    // TODO Auto-generated method stub

    final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid);
    final XYIntervalSeries serie = ((XYIntervalSeriesCollection) jfreedataset
            .get(IdPosition.get(dataserie.getSerieId(scope)))).getSeries(0);
    serie.clear();
    final ArrayList<Double> XValues = dataserie.getXValues(scope);
    final ArrayList<Double> YValues = dataserie.getYValues(scope);
    final ArrayList<Double> SValues = dataserie.getSValues(scope);
    boolean secondaxis = false;
    if (dataserie.getMysource().getUseSecondYAxis(scope)) {
        secondaxis = true;
        this.setUseSecondYAxis(scope, true);

    }

    if (XValues.size() > 0) {
        final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
        NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(0);
        int ids = IdPosition.get(dataserie.getSerieId(scope));
        if (secondaxis) {
            //         rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
            //            ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
            //         ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
            ((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 1);
        } else {
            //            ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
            ((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 0);

        }
        domainAxis.setAutoRange(false);
        rangeAxis.setAutoRange(false);
        // domainAxis.setRange(Math.min((double)(Collections.min(XValues)),0),
        // Math.max(Collections.max(XValues),Collections.min(XValues)+1));
        // rangeAxis.setRange(Math.min((double)(Collections.min(YValues)),0),
        // Math.max(Collections.max(YValues),Collections.min(YValues)+1));
        XYIntervalDataItem newval;
        for (int i = 0; i < XValues.size(); i++) {
            if (dataserie.isUseYErrValues()) {
                if (dataserie.isUseXErrValues()) {
                    newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i),
                            dataserie.xerrvaluesmax.get(i), YValues.get(i), dataserie.yerrvaluesmin.get(i),
                            dataserie.yerrvaluesmax.get(i));
                    // serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i));
                } else {
                    newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i),
                            YValues.get(i), dataserie.yerrvaluesmin.get(i), dataserie.yerrvaluesmax.get(i));
                    // serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i));
                }

            } else {
                if (dataserie.isUseXErrValues()) {
                    newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i),
                            dataserie.xerrvaluesmax.get(i), YValues.get(i), YValues.get(i), YValues.get(i));
                    // serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),YValues.get(i),YValues.get(i));
                } else {
                    newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i),
                            YValues.get(i), YValues.get(i), YValues.get(i));
                    // serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),YValues.get(i),YValues.get(i));
                }

            }
            serie.add(newval, false);
        }
        // domainAxis.setAutoRange(true);
        // rangeAxis.setAutoRange(true);
    }
    // resetAutorange(scope);
    if (SValues.size() > 0) {
        MarkerScale.remove(serieid);
        final ArrayList<Double> nscale = (ArrayList<Double>) SValues.clone();
        MarkerScale.put(serieid, nscale);

    }

    this.resetRenderer(scope, serieid);

}

From source file:userinterface.graph.Histogram.java

/**
 * Plots the series which is referenced by seriesKey.
 * @param seriesKey the key to the series that has to be plotted
 *//*from ww w  .  j ava2 s.co m*/
public void plotSeries(SeriesKey seriesKey) {

    double range = (maxProb - minProb) / (double) numOfBuckets; // Our range for which the histogram will be shown

    for (int i = 0; i < numOfBuckets; i++) {

        double minRange = minProb + (range * i);
        double maxRange = minRange + range;

        double height;

        if (i == (numOfBuckets - 1)) // include the first value  
            height = countProbabilities(minRange, maxRange, true);
        else
            height = countProbabilities(minRange, maxRange, false);

        double x = (minRange + maxRange) / 2.0;

        addPointToSeries(seriesKey, new XYIntervalDataItem(x, minRange, maxRange, height, height, height));

        /**Only update the x axis tick marks if this is the first series which is being plotted*/
        if (isNew) {

            if (i == 0)
                ticks.add(minRange);

            ticks.add(maxRange);
        }

    }

    /**Set the visible range of the plot*/
    plot.getDomainAxis().setRange(minProb - 0.02, maxProb + 0.02);

    /** clear the cache, we don't need it anymore*/
    dataCache.clear();
}