class 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;
    }

}