Example usage for org.jfree.data.time TimePeriodValuesCollection getDomainBounds

List of usage examples for org.jfree.data.time TimePeriodValuesCollection getDomainBounds

Introduction

In this page you can find the example usage for org.jfree.data.time TimePeriodValuesCollection getDomainBounds.

Prototype

@Override
public Range getDomainBounds(boolean includeInterval) 

Source Link

Document

Returns the range of the values in this dataset's domain.

Usage

From source file:org.jfree.data.time.TimePeriodValuesCollectionTest.java

/**
 * Some more checks for the getDomainBounds() method.
 * //from w w w.j av  a2s  .  c  o  m
 * @see #testGetDomainBoundsWithoutInterval()
 */
@Test
public void testGetDomainBoundsWithInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(true);
    assertNull(r);

    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(2000.0, r.getUpperBound(), EPSILON);

    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(3000.0, r.getUpperBound(), EPSILON);

    // add a third time period
    s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);

    // add a fourth time period
    s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);
}

From source file:org.jfree.data.time.TimePeriodValuesCollectionTest.java

/**
 * Some checks for the getDomainBounds() method.
 *///from ww  w .  j a va 2 s  . c o m
@Test
public void testGetDomainBoundsWithoutInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    dataset.setDomainIsPointsInTime(false);
    Range r = dataset.getDomainBounds(false);
    assertNull(r);

    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(1500.0, r.getUpperBound(), EPSILON);

    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(2250.0, r.getUpperBound(), EPSILON);
}