SeriesUtils { public static Region iBounds(XYSeries series, RectRegion visibleBounds) { final float step = series.size() >= 200 ? 50 : 1; final int iBoundsMin = iBoundsMin(series, visibleBounds.getMinX().doubleValue(), step); final int iBoundsMax = iBoundsMax(series, visibleBounds.getMaxX().doubleValue(), step); return new Region(iBoundsMin, iBoundsMax); }  static RectRegion minMax(List<XYSeries> seriesList); static RectRegion minMax(XYSeries... seriesList); static Region minMaxX(XYSeries... seriesList); static Region minMaxY(XYSeries... seriesList); static RectRegion minMax(XYConstraints constraints, List<XYSeries> seriesList); static RectRegion minMax(XYConstraints constraints, XYSeries... seriesArray); static Region minMax(Region bounds, List<Number>... lists); static Region iBounds(XYSeries series, RectRegion visibleBounds); static Region minMax(List<Number>... lists); static OrderedXYSeries.XOrder getXYOrder(XYSeries series);  }
@Test public void iBounds_findsMinMax() { FastXYSeries series = mock(FastXYSeries.class); when(series.size()).thenReturn(3); when(series.getX(0)).thenReturn(0); when(series.getX(1)).thenReturn(1); when(series.getX(2)).thenReturn(2); Region result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1)); assertEquals(0, result.getMin().intValue()); assertEquals(1, result.getMax().intValue()); when(series.size()).thenReturn(6); when(series.getX(0)).thenReturn(0); when(series.getX(1)).thenReturn(0.5); when(series.getX(2)).thenReturn(null); when(series.getX(3)).thenReturn(null); when(series.getX(4)).thenReturn(1); when(series.getX(5)).thenReturn(3); result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1)); assertEquals(0, result.getMin().intValue()); assertEquals(4, result.getMax().intValue()); }