question: @ Override public void run ( ) { amIActive = true ; String pointerHeader , loadingHeader , efficiencyHeader , absorptionHeader , outputHeader ; int row , col , x , y ; float progress = 0 ; double slope ; double z , z2 ; int i , c ; double numInNeighbours ; boolean flag = false ; double flowDir ; efficiencyMultiplier = 1d ; if ( args . length <= 0 ) { showFeedback ( "Plugin parameters have not been set." ) ; return ; } pointerHeader = args [ 0 ] ; loadingHeader = args [ 1 ] ; efficiencyHeader = args [ 2 ] ; absorptionHeader = args [ 3 ] ; outputHeader = args [ 4 ] ; if ( pointerHeader . isEmpty ( ) || outputHeader . isEmpty ( ) || loadingHeader . isEmpty ( ) || efficiencyHeader . isEmpty ( ) || absorptionHeader . isEmpty ( ) ) { showFeedback ( "One or more of the input parameters have not been set properly." ) ; return ; } try { pointer = new WhiteboxRaster ( pointerHeader , "r" ) ; int rows = pointer . getNumberRows ( ) ; int cols = pointer . getNumberColumns ( ) ; noData = pointer . getNoDataValue ( ) ; gridRes = pointer . getCellSizeX ( ) ; WhiteboxRaster loading = new WhiteboxRaster ( loadingHeader , "r" ) ; if ( loading . getNumberRows ( ) != rows || loading . getNumberColumns ( ) != cols ) { showFeedback ( "Each of the input images must have the same dimensions." ) ; return ; } double noDataLoading = loading . getNoDataValue ( ) ; efficiency = new WhiteboxRaster ( efficiencyHeader , "r" ) ; if ( efficiency . getNumberRows ( ) != rows || efficiency . getNumberColumns ( ) != cols ) { showFeedback ( "Each of the input images must have the same dimensions." ) ; return ; } double noDataEfficiency = efficiency . getNoDataValue ( ) ; if ( efficiency . getMaximumValue ( ) > 1 ) { efficiencyMultiplier = 0.01 ; } absorption = new WhiteboxRaster ( absorptionHeader , "r" ) ; if ( absorption . getNumberRows ( ) != rows || absorption . getNumberColumns ( ) != cols ) { showFeedback ( "Each of the input images must have the same dimensions." ) ; return ; } double noDataAbsorption = absorption . getNoDataValue ( ) ; double outputNoData = - 32768.0 ; output = new WhiteboxRaster ( outputHeader , "rw" , pointerHeader , WhiteboxRaster . DataType . FLOAT , 0 ) ; output . setPreferredPalette ( "blueyellow.pal" ) ; output . setDataScale ( WhiteboxRaster . DataScale . CONTINUOUS ) ; output . setZUnits ( "dimensionless" ) ; tmpGrid = new WhiteboxRaster ( outputHeader . replace ( ".dep" , "_temp.dep" ) , "rw" , pointerHeader , WhiteboxRaster . DataType . FLOAT , outputNoData ) ; tmpGrid . isTemporaryFile = true ; updateProgress ( "Loop 1 of 2:" , 0 ) ; for ( row = 0 ; row < rows ; row ++ ) { for ( col = 0 ; col < cols ; col ++ ) { flowDir = pointer . getValue ( row , col ) ; if ( flowDir != noData && loading . getValue ( row , col ) != noDataLoading && efficiency . getValue ( row , col ) != noDataEfficiency && absorption . getValue ( row , col ) != noDataAbsorption ) { i = 0 ; for ( c = 0 ; c < 8 ; c ++ ) { x = col + dX [ c ] ; y = row + dY [ c ] ; flowDir = pointer . getValue ( y , x ) ; if ( flowDir >= 0 && flowDir <= 360 ) { if ( c != 3 ) { if ( flowDir > startFD [ c ] && flowDir < endFD [ c ] ) { i ++ ; } } else { if ( flowDir > startFD [ c ] || flowDir < endFD [ c ] ) { i ++ ; } } } } tmpGrid . setValue ( row , col , i ) ; output . setValue ( row , col , loading . getValue ( row , col ) ) ; } else { output . setValue ( row , col , outputNoData ) ; } } if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * row / ( rows - 1 ) ) ; updateProgress ( "Loop 1 of 2:" , ( int ) progress ) ; } loading . close ( ) ; updateProgress ( "Loop 2 of 2:" , 0 ) ; for ( row = 0 ; row < rows ; row ++ ) { for ( col = 0 ; col < cols ; col ++ ) { if ( tmpGrid . getValue ( row , col ) == 0 ) { DinfAccum ( row , col ) ; } } if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * row / ( rows - 1 ) ) ; updateProgress ( "Loop 2 of 2:" , ( int ) progress ) ; } output . addMetadataEntry ( "Created by the " + getDescriptiveName ( ) + " tool." ) ; output . addMetadataEntry ( "Created on " + new Date ( ) ) ; pointer . close ( ) ; efficiency . close ( ) ; absorption . close ( ) ; tmpGrid . close ( ) ; output . close ( ) ; returnData ( outputHeader ) ; } catch ( OutOfMemoryError oe ) { myHost . showFeedback ( "An out-of-memory error has occurred during operation." ) ; } catch ( Exception e ) { myHost . showFeedback ( "An error has occurred during operation. See log file for details." ) ; myHost . logException ( "Error in " + getDescriptiveName ( ) , e ) ; } finally { updateProgress ( "Progress: " , 0 ) ; amIActive = false ; myHost . pluginComplete ( ) ; } }
target:  Used to execute this plugin tool.