SeriesUtils { protected static Region getNullRegion(XYSeries series, int index) { Region region = new Region(); if(series.getX(index) != null) { throw new IllegalArgumentException("Attempt to find null region for non null index: " + index); } for(int i = index - 1; i >= 0; i--) { Number val = series.getX(i); if(val != null) { region.setMin(i); break; } } for(int i = index + 1; i < series.size(); i++) { Number val = series.getX(i); if(val != null) { region.setMax(i); break; } } return region; }  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 getNullRegion_producesExpectedResult() { XYSeries s1 = new SimpleXYSeries( SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, "s1", 0, 0, 1, 1, 2, 2, null, null, null, null, 5, 5, 6, 6); try { Region r1 = SeriesUtils.getNullRegion(s1, 0); fail("IllegalArgumentException expected."); } catch(IllegalArgumentException e) { } try { Region r2 = SeriesUtils.getNullRegion(s1, s1.size() - 1); fail("IllegalArgumentException expected."); } catch(IllegalArgumentException e) { } Region r3 = SeriesUtils.getNullRegion(s1, 3); assertEquals(2, r3.getMin().intValue()); assertEquals(5, r3.getMax().intValue()); Region r4 = SeriesUtils.getNullRegion(s1, 4); assertEquals(2, r4.getMin().intValue()); assertEquals(5, r4.getMax().intValue()); }