@Test public void testGetSurroundingItems() { TimeSeries series = new TimeSeries("Series 1"); TimeSeriesCollection collection = new TimeSeriesCollection(series); collection.setXPosition(TimePeriodAnchor.MIDDLE); int[] result = collection.getSurroundingItems(0, 1000L); assertSame(result[0], -1); assertSame(result[1], -1); 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); assertSame(result[0], -1); assertSame(result[1], 0); result = collection.getSurroundingItems(0, middle1); assertSame(result[0], 0); assertSame(result[1], 0); result = collection.getSurroundingItems(0, end1); assertSame(result[0], 0); assertSame(result[1], -1); 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); assertSame(result[0], 0); assertSame(result[1], 1); result = collection.getSurroundingItems(0, middle2); assertSame(result[0], 1); assertSame(result[1], 1); result = collection.getSurroundingItems(0, end2); assertSame(result[0], 1); assertSame(result[1], -1); 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); assertSame(result[0], -1); assertSame(result[1], 0); result = collection.getSurroundingItems(0, middle3); assertSame(result[0], 0); assertSame(result[1], 0); result = collection.getSurroundingItems(0, end3); assertSame(result[0], 0); assertSame(result[1], 1); }
public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; }
TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo,
        XYRangeInfo, VetoableChangeListener, Serializable { public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; } }
TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo,
        XYRangeInfo, VetoableChangeListener, Serializable { public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; } TimeSeriesCollection();  TimeSeriesCollection(TimeZone zone);  TimeSeriesCollection(TimeSeries series);  TimeSeriesCollection(TimeSeries series, TimeZone zone); }
TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo,
        XYRangeInfo, VetoableChangeListener, Serializable { public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; } TimeSeriesCollection();  TimeSeriesCollection(TimeZone zone);  TimeSeriesCollection(TimeSeries series);  TimeSeriesCollection(TimeSeries series, TimeZone zone); @Override DomainOrder getDomainOrder(); TimePeriodAnchor getXPosition(); void setXPosition(TimePeriodAnchor anchor); List<TimeSeries> getSeries(); @Override int getSeriesCount(); int indexOf(TimeSeries series); TimeSeries getSeries(int series); TimeSeries getSeries(Comparable key); @Override Comparable getSeriesKey(int series); int getSeriesIndex(Comparable key); void addSeries(TimeSeries series); void removeSeries(TimeSeries series); void removeSeries(int index); void removeAllSeries(); @Override int getItemCount(int series); @Override double getXValue(int series, int item); @Override Number getX(int series, int item); @Override synchronized Number getStartX(int series, int item); @Override synchronized Number getEndX(int series, int item); @Override Number getY(int series, int item); @Override Number getStartY(int series, int item); @Override Number getEndY(int series, int item); int[] getSurroundingItems(int series, long milliseconds); @Override double getDomainLowerBound(boolean includeInterval); @Override double getDomainUpperBound(boolean includeInterval); @Override Range getDomainBounds(boolean includeInterval); @Override Range getDomainBounds(List<Comparable> visibleSeriesKeys,
            boolean includeInterval); Range getRangeBounds(boolean includeInterval); @Override Range getRangeBounds(List<Comparable> visibleSeriesKeys, 
            Range xRange, boolean includeInterval); @Override void vetoableChange(PropertyChangeEvent e); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone(); }
TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo,
        XYRangeInfo, VetoableChangeListener, Serializable { public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; } TimeSeriesCollection();  TimeSeriesCollection(TimeZone zone);  TimeSeriesCollection(TimeSeries series);  TimeSeriesCollection(TimeSeries series, TimeZone zone); @Override DomainOrder getDomainOrder(); TimePeriodAnchor getXPosition(); void setXPosition(TimePeriodAnchor anchor); List<TimeSeries> getSeries(); @Override int getSeriesCount(); int indexOf(TimeSeries series); TimeSeries getSeries(int series); TimeSeries getSeries(Comparable key); @Override Comparable getSeriesKey(int series); int getSeriesIndex(Comparable key); void addSeries(TimeSeries series); void removeSeries(TimeSeries series); void removeSeries(int index); void removeAllSeries(); @Override int getItemCount(int series); @Override double getXValue(int series, int item); @Override Number getX(int series, int item); @Override synchronized Number getStartX(int series, int item); @Override synchronized Number getEndX(int series, int item); @Override Number getY(int series, int item); @Override Number getStartY(int series, int item); @Override Number getEndY(int series, int item); int[] getSurroundingItems(int series, long milliseconds); @Override double getDomainLowerBound(boolean includeInterval); @Override double getDomainUpperBound(boolean includeInterval); @Override Range getDomainBounds(boolean includeInterval); @Override Range getDomainBounds(List<Comparable> visibleSeriesKeys,
            boolean includeInterval); Range getRangeBounds(boolean includeInterval); @Override Range getRangeBounds(List<Comparable> visibleSeriesKeys, 
            Range xRange, boolean includeInterval); @Override void vetoableChange(PropertyChangeEvent e); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone();  }