question: @ Override public void run ( ) { amIActive = true ; String demHeader = null ; String streamHeadsHeader = null ; String elevationModifiedHeader = null ; String correctedDemHeader = null ; List < StreamHead > streamHeadList = new ArrayList < > ( ) ; int counter = 0 ; 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 ) { demHeader = args [ i ] ; } else if ( i == 1 ) { streamHeadsHeader = args [ i ] ; } else if ( i == 2 ) { elevationModifiedHeader = args [ i ] ; } else if ( i == 3 ) { correctedDemHeader = args [ i ] ; } else if ( i == 4 ) { maxRadius = Double . parseDouble ( args [ i ] ) ; } } if ( ( demHeader == null ) || ( streamHeadsHeader == null ) || ( elevationModifiedHeader == null ) || ( correctedDemHeader == null ) ) { showFeedback ( "One or more of the input parameters have not been set properly." ) ; return ; } try { dem = new WhiteboxRaster ( demHeader , "r" ) ; streamHeads = new WhiteboxRaster ( streamHeadsHeader , "r" ) ; numRows = dem . getNumberRows ( ) ; numCols = dem . getNumberColumns ( ) ; noData = dem . getNoDataValue ( ) ; gridRes = dem . getCellSizeX ( ) ; elevationModified = new WhiteboxRaster ( elevationModifiedHeader , "rw" , demHeader , WhiteboxRaster . DataType . FLOAT , 0 ) ; elevationModified . setPreferredPalette ( "blueyellow.pal" ) ; elevationModified . setDataScale ( WhiteboxRasterBase . DataScale . CONTINUOUS ) ; elevationModified . setZUnits ( "dimensionless" ) ; correctedDEM = new WhiteboxRaster ( correctedDemHeader , "rw" , demHeader , WhiteboxRaster . DataType . FLOAT , 0 ) ; correctedDEM . setPreferredPalette ( "blueyellow.pal" ) ; correctedDEM . setDataScale ( WhiteboxRasterBase . DataScale . CONTINUOUS ) ; correctedDEM . setZUnits ( "dimensionless" ) ; if ( streamHeads . getNumberColumns ( ) != numCols || streamHeads . getNumberRows ( ) != numRows ) { showFeedback ( "Input images must have the same dimensions." ) ; return ; } updateProgress ( "Loop 1 of 4:" , 0 ) ; for ( int row = 0 ; row < numRows ; row ++ ) { for ( int col = 0 ; col < numCols ; col ++ ) { if ( dem . getValue ( row , col ) != noData ) { elevationModified . setValue ( row , col , 0 ) ; } else { elevationModified . setValue ( row , col , noData ) ; } } if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * row / ( numRows - 1 ) ) ; updateProgress ( "Loop 1 of 4:" , ( int ) progress ) ; } updateProgress ( "Loop 2 of 4:" , 0 ) ; for ( int row = 0 ; row < numRows ; row ++ ) { for ( int col = 0 ; col < numCols ; col ++ ) { if ( streamHeads . getValue ( row , col ) == 1 ) { streamHeadList . add ( new StreamHead ( col , row , dem . getValue ( row , col ) ) ) ; } } if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * row / ( numRows - 1 ) ) ; updateProgress ( "Loop 2 of 4:" , ( int ) progress ) ; } streamHeadList = OrderStreamHeads ( streamHeadList ) ; updateProgress ( "Loop 3 of 4:" , 0 ) ; for ( StreamHead streamHead : streamHeadList ) { CheckFlowPath ( streamHead . GetXCoord ( ) , streamHead . GetYCoord ( ) ) ; counter = counter + 1 ; if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * counter / streamHeadList . size ( ) ) ; updateProgress ( "Loop 3 of 4:" , ( int ) progress ) ; } updateProgress ( "Loop 4 of 4:" , 0 ) ; for ( int row = 0 ; row < numRows ; row ++ ) { for ( int col = 0 ; col < numCols ; col ++ ) { if ( elevationModified . getValue ( row , col ) != noData ) { correctedDEM . setValue ( row , col , dem . getValue ( row , col ) - elevationModified . getValue ( row , col ) ) ; } else { correctedDEM . setValue ( row , col , noData ) ; } } if ( cancelOp ) { cancelOperation ( ) ; return ; } progress = ( float ) ( 100f * row / ( numRows - 1 ) ) ; updateProgress ( "Loop 4 of 4:" , ( int ) progress ) ; } elevationModified . addMetadataEntry ( "Created by the " + getDescriptiveName ( ) + " tool." ) ; elevationModified . addMetadataEntry ( "Created on " + new Date ( ) ) ; correctedDEM . addMetadataEntry ( "Created by the " + getDescriptiveName ( ) + " tool." ) ; correctedDEM . addMetadataEntry ( "Created on " + new Date ( ) ) ; dem . close ( ) ; streamHeads . close ( ) ; elevationModified . close ( ) ; correctedDEM . close ( ) ; returnData ( correctedDemHeader ) ; } catch ( Exception e ) { showFeedback ( e . getMessage ( ) ) ; } finally { updateProgress ( "Progress: " , 0 ) ; amIActive = false ; myHost . pluginComplete ( ) ; } }
target:  Used to execute this plugin tool.