当前位置: 首页>>代码示例>>Java>>正文


Java TimeSeriesCollection.getSurroundingItems方法代码示例

本文整理汇总了Java中org.jfree.data.time.TimeSeriesCollection.getSurroundingItems方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeriesCollection.getSurroundingItems方法的具体用法?Java TimeSeriesCollection.getSurroundingItems怎么用?Java TimeSeriesCollection.getSurroundingItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.data.time.TimeSeriesCollection的用法示例。


在下文中一共展示了TimeSeriesCollection.getSurroundingItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetSurroundingItems

import org.jfree.data.time.TimeSeriesCollection; //导入方法依赖的package包/类
/**
 * Test the getSurroundingItems() method to ensure it is returning the values we expect.
 */
public void testGetSurroundingItems() {
    
    final TimeSeries series = new TimeSeries("Series 1", Day.class);
    final TimeSeriesCollection collection = new TimeSeriesCollection(series);
    collection.setXPosition(TimePeriodAnchor.MIDDLE);
    
    // for a series with no data, we expect {-1, -1}...
    int[] result = collection.getSurroundingItems(0, 1000L);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == -1);
    
    // now test with a single value in the series...
    final Day today = new Day();
    final long start1 = today.getFirstMillisecond();
    final long middle1 = today.getMiddleMillisecond();
    final long end1 = today.getLastMillisecond();
    
    series.add(today, 99.9);
    result = collection.getSurroundingItems(0, start1);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, middle1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, end1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == -1);
    
    // now add a second value to the series...
    final Day tomorrow = (Day) today.next();
    final long start2 = tomorrow.getFirstMillisecond();
    final long middle2 = tomorrow.getMiddleMillisecond();
    final long end2 = tomorrow.getLastMillisecond();
    
    series.add(tomorrow, 199.9);
    result = collection.getSurroundingItems(0, start2);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);
    
    result = collection.getSurroundingItems(0, middle2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == 1);
    
    result = collection.getSurroundingItems(0, end2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == -1);
    
    // now add a third value to the series...
    final Day yesterday = (Day) today.previous();
    final long start3 = yesterday.getFirstMillisecond();
    final long middle3 = yesterday.getMiddleMillisecond();
    final long end3 = yesterday.getLastMillisecond();
    
    series.add(yesterday, 1.23);
    result = collection.getSurroundingItems(0, start3);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, middle3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, end3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:73,代码来源:TimeSeriesCollectionTests.java

示例2: testGetSurroundingItems

import org.jfree.data.time.TimeSeriesCollection; //导入方法依赖的package包/类
/**
 * Test the getSurroundingItems() method to ensure it is returning the 
 * values we expect.
 */
public void testGetSurroundingItems() {
    
    TimeSeries series = new TimeSeries("Series 1", Day.class);
    TimeSeriesCollection collection = new TimeSeriesCollection(series);
    collection.setXPosition(TimePeriodAnchor.MIDDLE);
    
    // for a series with no data, we expect {-1, -1}...
    int[] result = collection.getSurroundingItems(0, 1000L);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == -1);
    
    // now test with a single value in the series...
    Day today = new Day();
    long start1 = today.getFirstMillisecond();
    long middle1 = today.getMiddleMillisecond();
    long end1 = today.getLastMillisecond();
    
    series.add(today, 99.9);
    result = collection.getSurroundingItems(0, start1);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, middle1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, end1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == -1);
    
    // now add a second value to the series...
    Day tomorrow = (Day) today.next();
    long start2 = tomorrow.getFirstMillisecond();
    long middle2 = tomorrow.getMiddleMillisecond();
    long end2 = tomorrow.getLastMillisecond();
    
    series.add(tomorrow, 199.9);
    result = collection.getSurroundingItems(0, start2);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);
    
    result = collection.getSurroundingItems(0, middle2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == 1);
    
    result = collection.getSurroundingItems(0, end2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == -1);
    
    // now add a third value to the series...
    Day yesterday = (Day) today.previous();
    long start3 = yesterday.getFirstMillisecond();
    long middle3 = yesterday.getMiddleMillisecond();
    long end3 = yesterday.getLastMillisecond();
    
    series.add(yesterday, 1.23);
    result = collection.getSurroundingItems(0, start3);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, middle3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);
    
    result = collection.getSurroundingItems(0, end3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:74,代码来源:TimeSeriesCollectionTests.java

示例3: testGetSurroundingItems

import org.jfree.data.time.TimeSeriesCollection; //导入方法依赖的package包/类
/**
 * Test the getSurroundingItems() method to ensure it is returning the
 * values we expect.
 */
public void testGetSurroundingItems() {

    TimeSeries series = new TimeSeries("Series 1");
    TimeSeriesCollection collection = new TimeSeriesCollection(series);
    collection.setXPosition(TimePeriodAnchor.MIDDLE);

    // for a series with no data, we expect {-1, -1}...
    int[] result = collection.getSurroundingItems(0, 1000L);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == -1);

    // now test with a single value in the series...
    Day today = new Day();
    long start1 = today.getFirstMillisecond();
    long middle1 = today.getMiddleMillisecond();
    long end1 = today.getLastMillisecond();

    series.add(today, 99.9);
    result = collection.getSurroundingItems(0, start1);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);

    result = collection.getSurroundingItems(0, middle1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);

    result = collection.getSurroundingItems(0, end1);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == -1);

    // now add a second value to the series...
    Day tomorrow = (Day) today.next();
    long start2 = tomorrow.getFirstMillisecond();
    long middle2 = tomorrow.getMiddleMillisecond();
    long end2 = tomorrow.getLastMillisecond();

    series.add(tomorrow, 199.9);
    result = collection.getSurroundingItems(0, start2);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);

    result = collection.getSurroundingItems(0, middle2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == 1);

    result = collection.getSurroundingItems(0, end2);
    assertTrue(result[0] == 1);
    assertTrue(result[1] == -1);

    // now add a third value to the series...
    Day yesterday = (Day) today.previous();
    long start3 = yesterday.getFirstMillisecond();
    long middle3 = yesterday.getMiddleMillisecond();
    long end3 = yesterday.getLastMillisecond();

    series.add(yesterday, 1.23);
    result = collection.getSurroundingItems(0, start3);
    assertTrue(result[0] == -1);
    assertTrue(result[1] == 0);

    result = collection.getSurroundingItems(0, middle3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 0);

    result = collection.getSurroundingItems(0, end3);
    assertTrue(result[0] == 0);
    assertTrue(result[1] == 1);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:74,代码来源:TimeSeriesCollectionTests.java


注:本文中的org.jfree.data.time.TimeSeriesCollection.getSurroundingItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。