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

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

Introduction

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

Prototype

public XIntervalSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) 

Source Link

Document

Constructs a new xy-series that contains no data.

Usage

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

/**
 * A check for the indexOf() method for an unsorted series.
 *//*from   w w w  . j  av a  2s .c  om*/
@Test
public void testIndexOf2() {
    XIntervalSeries s1 = new XIntervalSeries("Series 1", false, true);
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));
    assertEquals(1, s1.indexOf(new Double(3.0)));
    assertEquals(2, s1.indexOf(new Double(2.0)));
}

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

/**
 * Some checks for the add() method for an UNSORTED series.
 */// w w  w.  j a  v a 2s  . c o m
@Test
public void testAdd() {
    XIntervalSeries series = new XIntervalSeries("Series", false, true);
    series.add(5.0, 5.50, 5.50, 5.50);
    series.add(5.1, 5.51, 5.51, 5.51);
    series.add(6.0, 6.6, 6.6, 6.6);
    series.add(3.0, 3.3, 3.3, 3.3);
    series.add(4.0, 4.4, 4.4, 4.4);
    series.add(2.0, 2.2, 2.2, 2.2);
    series.add(1.0, 1.1, 1.1, 1.1);
    assertEquals(5.5, series.getYValue(0), EPSILON);
    assertEquals(5.51, series.getYValue(1), EPSILON);
    assertEquals(6.6, series.getYValue(2), EPSILON);
    assertEquals(3.3, series.getYValue(3), EPSILON);
    assertEquals(4.4, series.getYValue(4), EPSILON);
    assertEquals(2.2, series.getYValue(5), EPSILON);
    assertEquals(1.1, series.getYValue(6), EPSILON);
}

From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java

/**
 * Convert the intervals & values to a dataset that JFreeChart can use
 * @param snpIntervals/*from  ww  w . j  a  va 2s  . com*/
 *          the intervals
 * @param visualInterval
 *          the visual interval that we should use
 * @return
 *          the data set
 */
private XYDataset createSnpIntervalHistogramData(final List<? extends RealValuedBasePairInterval> snpIntervals,
        final HighlightedSnpInterval visualInterval) {
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();

    XIntervalSeries series = new XIntervalSeries("Interval Values", false, true);
    XIntervalSeries highlightSeries = new XIntervalSeries("Highlighted Interval Values", false, true);

    int endIndex = visualInterval.getEndIndex();
    int[] highlightIndices = visualInterval.getIndicesToHighlight();
    for (int i = visualInterval.getStartIndex(); i <= endIndex; i++) {
        RealValuedBasePairInterval currSnpInterval = snpIntervals.get(i);

        boolean highlight = false;
        for (int j = 0; j < highlightIndices.length; j++) {
            if (i == highlightIndices[j]) {
                highlight = true;
                break;
            }
        }

        if (highlight) {
            highlightSeries.add(currSnpInterval.getStartInBasePairs(), currSnpInterval.getStartInBasePairs(),
                    currSnpInterval.getEndInBasePairs(), currSnpInterval.getRealValue());
        } else {
            series.add(currSnpInterval.getStartInBasePairs(), currSnpInterval.getStartInBasePairs(),
                    currSnpInterval.getEndInBasePairs(), currSnpInterval.getRealValue());
        }
    }

    dataset.addSeries(series);
    dataset.addSeries(highlightSeries);
    return dataset;
}