question: @ Override public void run ( ) { amIActive = true ; String inputTextFile = null ; String inputRasterFiles = null ; String outputTextFile = null ; boolean interpolateValues = false ; boolean includeStatistics = false ; String [ ] gatHeaderFile ; List < WhiteboxRaster > gatGrids = new ArrayList < > ( ) ; String fileName ; int numberOfLines = 0 ; int counter ; String tempLine ; String [ ] line ; int id ; double xCoord ; double yCoord ; String name ; int xGridcell ; int yGridcell ; double deltaX ; double deltaY ; int dXi ; int dYi ; double average ; double w ; double [ ] ww = new double [ 4 ] ; double value ; int [ ] xd = new int [ ] { 0 , - 1 , - 1 , - 1 , 0 , 1 , 1 , 1 } ; int [ ] yd = new int [ ] { - 1 , - 1 , 0 , 1 , 1 , 1 , 0 , - 1 } ; double min ; double max ; double sum ; int sumCount ; double mean = 0 ; double neighbourValue ; FileWriter streamWriter = null ; String outputLine ; float progress = 0 ; if ( args . length <= 0 ) { showFeedback ( "Plugin parameters have not been set." ) ; return ; } for ( int i = 0 ; i < args . length ; i ++ ) { if ( i == 0 ) { inputTextFile = args [ i ] ; } else if ( i == 1 ) { inputRasterFiles = args [ i ] ; } else if ( i == 2 ) { outputTextFile = args [ i ] ; } else if ( i == 3 ) { interpolateValues = Boolean . parseBoolean ( args [ i ] ) ; } else if ( i == 4 ) { includeStatistics = Boolean . parseBoolean ( args [ i ] ) ; } } if ( ( inputTextFile == null ) || ( inputRasterFiles == null ) || ( outputTextFile == null ) ) { showFeedback ( "One or more of the input parameters have not been set properly." ) ; return ; } try { gatHeaderFile = inputRasterFiles . split ( ";" ) ; for ( int i = 0 ; i <= gatHeaderFile . length - 1 ; i ++ ) { WhiteboxRaster gatGrid = new WhiteboxRaster ( gatHeaderFile [ i ] , "r" ) ; gatGrids . add ( gatGrid ) ; } BufferedReader bufferedReader = new BufferedReader ( new FileReader ( inputTextFile ) ) ; streamWriter = new FileWriter ( outputTextFile , false ) ; outputLine = "ID" + "\t" + "X" + "\t" + "Y" ; for ( WhiteboxRaster gatGrid : gatGrids ) { fileName = gatGrid . getShortHeaderFile ( ) ; outputLine = outputLine + "\t" + fileName ; if ( includeStatistics ) { outputLine = outputLine + "\t" + fileName + "_min" + "\t" + fileName + "_max" + "\t" + fileName + "_mean" ; } } outputLine = outputLine + "\t" + "Name" ; streamWriter . write ( outputLine + System . lineSeparator ( ) ) ; while ( ( tempLine = bufferedReader . readLine ( ) ) != null ) { numberOfLines = numberOfLines + 1 ; } bufferedReader . close ( ) ; bufferedReader = new BufferedReader ( new FileReader ( inputTextFile ) ) ; tempLine = bufferedReader . readLine ( ) ; counter = 1 ; while ( ( tempLine = bufferedReader . readLine ( ) ) != null ) { line = tempLine . split ( "\t" ) ; counter = counter + 1 ; if ( ( line . length != 3 ) && ( line . length != 4 ) ) { JOptionPane . showMessageDialog ( null , "Error in input file. Line " + counter + " contains an unexpected number of elements." ) ; return ; } if ( ! IsInteger ( line [ 0 ] ) || ! IsDouble ( line [ 1 ] ) || ! IsDouble ( line [ 2 ] ) ) { JOptionPane . showMessageDialog ( null , "Error in input file. Line " + counter + " contains a value of an expected type." ) ; return ; } id = Integer . parseInt ( line [ 0 ] ) ; xCoord = Double . parseDouble ( line [ 1 ] ) ; yCoord = Double . parseDouble ( line [ 2 ] ) ; if ( line . length == 4 ) { name = line [ 3 ] ; } else { name = "" ; } outputLine = id + "\t" + xCoord + "\t" + yCoord ; for ( WhiteboxRaster gatGrid : gatGrids ) { gridRes = gatGrid . getCellSizeX ( ) ; xGridcell = ( int ) ( ( xCoord - gatGrid . getWest ( ) ) / gridRes ) ; yGridcell = ( int ) ( ( yCoord - gatGrid . getSouth ( ) ) / gridRes ) ; deltaX = xCoord - ( ( xGridcell + 0.5 ) * gridRes + gatGrid . getWest ( ) ) ; deltaY = yCoord - ( ( yGridcell + 0.5 ) * gridRes + gatGrid . getSouth ( ) ) ; yGridcell = InvertYCoord ( gatGrid , yGridcell ) ; if ( deltaX > 0 ) { dXi = 1 ; } else { dXi = - 1 ; } if ( deltaY > 0 ) { dYi = - 1 ; } else { dYi = 1 ; } deltaX = Math . abs ( deltaX ) ; deltaY = Math . abs ( deltaY ) ; if ( interpolateValues ) { if ( ( gatGrid . getValue ( yGridcell , xGridcell ) == gatGrid . getNoDataValue ( ) ) || ( gatGrid . getValue ( yGridcell + dYi , xGridcell ) == gatGrid . getNoDataValue ( ) ) || ( gatGrid . getValue ( yGridcell , xGridcell + dXi ) == gatGrid . getNoDataValue ( ) ) || ( gatGrid . getValue ( yGridcell + dYi , xGridcell + dXi ) == gatGrid . getNoDataValue ( ) ) ) { value = gatGrid . getNoDataValue ( ) ; } else if ( deltaX == 0 && deltaY == 0 ) { value = gatGrid . getValue ( yGridcell , xGridcell ) ; } else { ww [ 0 ] = 1 / Math . sqrt ( Math . pow ( deltaX , 2 ) + Math . pow ( deltaY , 2 ) ) ; average = gatGrid . getValue ( yGridcell , xGridcell ) * ww [ 0 ] ; w = ww [ 0 ] ; ww [ 1 ] = 1 / Math . sqrt ( Math . pow ( deltaX , 2 ) + Math . pow ( gridRes - deltaY , 2 ) ) ; average = average + gatGrid . getValue ( yGridcell + dYi , xGridcell ) * ww [ 1 ] ; w = w + ww [ 1 ] ; ww [ 2 ] = 1 / Math . sqrt ( Math . pow ( gridRes - deltaX , 2 ) + Math . pow ( deltaY , 2 ) ) ; average = average + gatGrid . getValue ( yGridcell , xGridcell + dXi ) * ww [ 2 ] ; w = w + ww [ 2 ] ; ww [ 3 ] = 1 / Math . sqrt ( Math . pow ( gridRes - deltaX , 2 ) + Math . pow ( gridRes - deltaY , 2 ) ) ; average = average + gatGrid . getValue ( yGridcell + dYi , xGridcell + dXi ) * ww [ 3 ] ; w = w + ww [ 3 ] ; value = average / w ; } } else { value = gatGrid . getValue ( yGridcell , xGridcell ) ; } outputLine = outputLine + "\t" + value ; if ( includeStatistics ) { value = gatGrid . getValue ( yGridcell , xGridcell ) ; if ( value == gatGrid . getNoDataValue ( ) ) { min = Double . MAX_VALUE ; max = Double . MIN_VALUE ; sum = 0 ; sumCount = 0 ; mean = gatGrid . getNoDataValue ( ) ; } else { min = value ; max = value ; sum = value ; sumCount = 1 ; } for ( int c = 0 ; c < 8 ; c ++ ) { neighbourValue = gatGrid . getValue ( yGridcell + yd [ c ] , xGridcell + xd [ c ] ) ; if ( neighbourValue != gatGrid . getNoDataValue ( ) ) { if ( neighbourValue < min ) { min = neighbourValue ; } if ( neighbourValue > max ) { max = neighbourValue ; } sum = sum + neighbourValue ; sumCount = sumCount + 1 ; } } if ( sumCount == 0 ) { min = gatGrid . getNoDataValue ( ) ; max = gatGrid . getNoDataValue ( ) ; } else { mean = sum / sumCount ; } outputLine = outputLine + "\t" + min + "\t" + max + "\t" + mean ; } } if ( name != "" ) { outputLine = outputLine + "\t" + name ; } streamWriter . write ( outputLine + System . lineSeparator ( ) ) ; if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * counter / numberOfLines ) ; updateProgress ( "" , ( int ) progress ) ; } for ( WhiteboxRaster gatGrid : gatGrids ) { gatGrid . close ( ) ; } streamWriter . close ( ) ; } catch ( IOException | HeadlessException | NumberFormatException e ) { showFeedback ( e . getMessage ( ) ) ; } finally { updateProgress ( "Progress: " , 0 ) ; amIActive = false ; myHost . pluginComplete ( ) ; } }
target:  Used to execute this plugin tool.