private Optional < CoverageCoordAxisBuilder > subsetValues ( double minValue , double maxValue , int stride ) { if ( axis . getSpacing ( ) == CoverageCoordAxis . Spacing . discontiguousInterval ) return subsetValuesDiscontinuous ( minValue , maxValue , stride ) ; double lower = axis . isAscending ( ) ? Math . min ( minValue , maxValue ) : Math . max ( minValue , maxValue ) ; double upper = axis . isAscending ( ) ? Math . max ( minValue , maxValue ) : Math . min ( minValue , maxValue ) ; int minIndex = findCoordElement ( lower , false ) ; int maxIndex = findCoordElement ( upper , false ) ; if ( minIndex >= axis . getNcoords ( ) ) return Optional . empty ( String . format ( "no points in subset: lower %f > end %f" , lower , axis . getEndValue ( ) ) ) ; if ( maxIndex < 0 ) return Optional . empty ( String . format ( "no points in subset: upper %f < start %f" , upper , axis . getStartValue ( ) ) ) ; if ( minIndex < 0 ) minIndex = 0 ; if ( maxIndex >= axis . getNcoords ( ) ) maxIndex = axis . getNcoords ( ) - 1 ; int count = maxIndex - minIndex + 1 ; if ( count <= 0 ) throw new IllegalArgumentException ( "no points in subset" ) ; try { return Optional . of ( subsetByIndex ( new Range ( minIndex , maxIndex , stride ) ) ) ; } catch ( InvalidRangeException e ) { return Optional . empty ( e . getMessage ( ) ) ; } }
look must handle discon interval different