public CoordinateAxis1D section ( Range r ) throws InvalidRangeException { Section section = new Section ( ) . appendRange ( r ) ; CoordinateAxis1D result = ( CoordinateAxis1D ) section ( section ) ; int len = r . length ( ) ; // deal with the midpoints, bounds if ( isNumeric ( ) ) { double [ ] new_mids = new double [ len ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_mids [ idx ] = coords [ old_idx ] ; } result . coords = new_mids ; if ( isInterval ) { double [ ] new_bound1 = new double [ len ] ; double [ ] new_bound2 = new double [ len ] ; double [ ] new_edge = new double [ len + 1 ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_bound1 [ idx ] = bound1 [ old_idx ] ; new_bound2 [ idx ] = bound2 [ old_idx ] ; new_edge [ idx ] = bound1 [ old_idx ] ; new_edge [ idx + 1 ] = bound2 [ old_idx ] ; // all but last are overwritten } result . bound1 = new_bound1 ; result . bound2 = new_bound2 ; result . edge = new_edge ; } else { double [ ] new_edge = new double [ len + 1 ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_edge [ idx ] = edge [ old_idx ] ; new_edge [ idx + 1 ] = edge [ old_idx + 1 ] ; // all but last are overwritten } result . edge = new_edge ; } } if ( names != null ) { String [ ] new_names = new String [ len ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_names [ idx ] = names [ old_idx ] ; } result . names = new_names ; } result . wasCalcRegular = false ; result . calcIsRegular ( ) ; return result ; }
Create a new CoordinateAxis1D as a section of this CoordinateAxis1D .