SeriesUtils { protected static int iBoundsMax(XYSeries series, double visibleMax, float step) { int max = series.size() - 1; final int seriesSize = series.size(); final int steps = (int) Math.ceil(seriesSize / step); for (int stepIndex = steps; stepIndex >= 0; stepIndex--) { final int i = stepIndex * (int) step; for (int ii = 0; ii < step; ii++) { final int iii = i + ii; if(iii < seriesSize) { final Number thisX = series.getX(iii); if (thisX != null) { final double thisDouble = thisX.doubleValue(); if (thisDouble > visibleMax) { max = iii; break; } else if (thisDouble == visibleMax) { return iii; } else { return max; } } } } } return max; }  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 iBoundsMax_findsMax() { XYSeries s1 = new SimpleXYSeries( Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), "s1"); assertEquals(12, SeriesUtils.iBoundsMax(s1, 12, 1)); assertEquals(6, SeriesUtils.iBoundsMax(s1, 6, 1)); assertEquals(12, SeriesUtils.iBoundsMax(s1, 12, 1)); XYSeries s2 = new SimpleXYSeries( Arrays.asList(null, 1, 2, null, null, 5, 6, 7, 8, null, 10, 11, null), Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), "s2"); assertEquals(1, SeriesUtils.iBoundsMax(s2, 0, 1)); assertEquals(5, SeriesUtils.iBoundsMax(s2, 3, 1)); assertEquals(12, SeriesUtils.iBoundsMax(s2, 12, 1)); assertEquals(1, SeriesUtils.iBoundsMax(s2, 0, 5)); assertEquals(5, SeriesUtils.iBoundsMax(s2, 3, 5)); assertEquals(12, SeriesUtils.iBoundsMax(s2, 12, 5)); }