Revision: 6099
          http://sourceforge.net/p/jump-pilot/code/6099
Author:   ma15569
Date:     2019-01-19 06:27:02 +0000 (Sat, 19 Jan 2019)
Log Message:
-----------
added monitoring to raster build

Modified Paths:
--------------
    
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/DemFillerPlugIn.java
    
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/FlowDirectionPlugIn.java

Modified: 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/DemFillerPlugIn.java
===================================================================
--- 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/DemFillerPlugIn.java
   2019-01-19 06:24:34 UTC (rev 6098)
+++ 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/DemFillerPlugIn.java
   2019-01-19 06:27:02 UTC (rev 6099)
@@ -1,29 +1,35 @@
 package com.geomaticaeambiente.klemgui.plugin.hydrology;
 
-import com.geomaticaeambiente.klemgui.utils.PluginUtils;
+import java.io.File;
+
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.openjump.core.rasterimage.RasterImageLayer;
+
 import com.geomaticaeambiente.klemgui.ui.CustomComboBox;
 import com.geomaticaeambiente.klemgui.ui.GUIUtils;
 import com.geomaticaeambiente.klemgui.ui.InitialDialog;
+import com.geomaticaeambiente.klemgui.ui.LayerablesList;
 import com.geomaticaeambiente.klemgui.ui.MainPanel;
-import com.geomaticaeambiente.klemgui.ui.LayerablesList;
 import com.geomaticaeambiente.klemgui.utils.AbstractInputKlemPlugin;
 import com.geomaticaeambiente.klemgui.utils.ActionObject;
 import com.geomaticaeambiente.klemgui.utils.ComponentsTreeMap;
+import com.geomaticaeambiente.klemgui.utils.InitialData;
+import com.geomaticaeambiente.klemgui.utils.PluginUtils;
 import com.geomaticaeambiente.klemgui.utils.RasterUtils;
-import com.geomaticaeambiente.klemgui.utils.InitialData;
 import com.geomaticaeambiente.openjump.klem.fill.DemFiller;
 import com.geomaticaeambiente.openjump.klem.grid.DoubleBasicGrid;
+import com.vividsolutions.jump.task.TaskMonitor;
 import com.vividsolutions.jump.util.StringUtil;
+import com.vividsolutions.jump.workbench.Logger;
+import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.plugin.ThreadedBasePlugIn;
 import com.vividsolutions.jump.workbench.ui.ErrorDialog;
-import java.awt.geom.NoninvertibleTransformException;
-import java.io.File;
-import java.util.concurrent.ExecutionException;
-import javax.swing.JButton;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import org.openjump.core.rasterimage.RasterImageLayer;
+import com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager;
 
 /**
  * Plugin for fill the DEM. The raster must be loaded on OJ TOC. The output
@@ -33,23 +39,29 @@
  */
 public class DemFillerPlugIn extends AbstractInputKlemPlugin {
 
-    public DemFillerPlugIn(PlugInContext context, InitialDialog initialDialog, 
LayerablesList rasterLayersList) {
+    public DemFillerPlugIn(PlugInContext context, InitialDialog initialDialog,
+            LayerablesList rasterLayersList) {
         super(context, initialDialog);
         this.context = context;
-        this.layerablesList = rasterLayersList;
+        layerablesList = rasterLayersList;
     }
 
     @Override
     public InitialData setInitialData() {
 
-//        rasterImageLayers = 
PluginUtils.getRasterImageLayers(layerablesList.getLayerables());
+        //        rasterImageLayers = 
PluginUtils.getRasterImageLayers(layerablesList.getLayerables());
 
-        InitialData initialData = new InitialData();
+        final InitialData initialData = new InitialData();
         //input data
-        initialData.setParam_Label_TextBox(GUIUtils.setGUILabel(RASTER_DEM), 
PluginUtils.getRasterImageLayers(layerablesList.getLayerables()), 
GUIUtils.INPUT);
+        initialData
+                .setParam_Label_TextBox(GUIUtils.setGUILabel(RASTER_DEM),
+                        PluginUtils.getRasterImageLayers(layerablesList
+                                .getLayerables()), GUIUtils.INPUT);
 
         //output data
-        
initialData.setParam_Label_TextBox_Button(GUIUtils.setGUILabel(RASTER_PITFILLEDDEM),
 "", new ActionObject(""), GUIUtils.OUTPUT);
+        initialData.setParam_Label_TextBox_Button(
+                GUIUtils.setGUILabel(RASTER_PITFILLEDDEM), "",
+                new ActionObject(""), GUIUtils.OUTPUT);
 
         return initialData;
 
@@ -56,63 +68,109 @@
     }
 
     @Override
-    public ComponentsTreeMap setComponentsActions(ComponentsTreeMap 
personalTreeMap) {
+    public ComponentsTreeMap setComponentsActions(
+            ComponentsTreeMap personalTreeMap) {
 
-        final JTextField outputTextField = (JTextField) 
personalTreeMap.getComponent("00", GUIUtils.OUTPUT, 1);
-        JButton outputButton = (JButton) personalTreeMap.getComponent("00", 
GUIUtils.OUTPUT, 2);
+        final JTextField outputTextField = (JTextField) personalTreeMap
+                .getComponent("00", GUIUtils.OUTPUT, 1);
+        final JButton outputButton = (JButton) personalTreeMap.getComponent(
+                "00", GUIUtils.OUTPUT, 2);
         outputButton.setIcon(PluginUtils.getFolderIcon());
-        
outputButton.addActionListener(GUIUtils.setSaveRasterTif(outputTextField));
+        outputButton.addActionListener(GUIUtils
+                .setSaveRasterTif(outputTextField));
 
         return personalTreeMap;
     }
 
+    public void demFillerCommand(final ComponentsTreeMap componentsWithActions)
+            throws Exception {
+        //get input raster names
+        final String rasterSelected1 = GUIUtils
+                .getStringValue(componentsWithActions.getComponent("00",
+                        GUIUtils.INPUT, 1));
+
+        //get output raster name
+        final String outRasterName = GUIUtils
+                .getStringValue(componentsWithActions.getComponent("00",
+                        GUIUtils.OUTPUT, 1));
+
+        //check input values
+        GUIUtils.checkStringValue(rasterSelected1, RASTER_DEM);
+        GUIUtils.checkFileValue(outRasterName, 
GUIUtils.getOutputRasterString());
+
+        //get input raster as rasterImageLayer from string
+        final RasterImageLayer inputRasterSelected = PluginUtils
+                .getRasterImageLayerSelected((CustomComboBox.RasterComboBox) 
componentsWithActions
+                        .getComponent("00", GUIUtils.INPUT, 1));
+        final DoubleBasicGrid demGrid = RasterUtils
+                .getDoubleBasicGrid(inputRasterSelected);
+
+        //Fill...
+        final DemFiller demFiller = new DemFiller(demGrid);
+        final DoubleBasicGrid demFilled = demFiller.calculate();
+
+        //Save grid as tiff
+        RasterUtils.saveOutputRasterAsTiff(demFilled, new File(outRasterName));
+        //Display raster on OJ from file                
+        RasterUtils.displayRasterFileOnOJ(context.getWorkbenchContext(),
+                new File(outRasterName), null);
+
+        JOptionPane.showMessageDialog(super.getInitialDialog(), PluginUtils
+                .getResources().getString("SetWorkspacePlugin.Done.message"),
+                PluginUtils.plugInName, JOptionPane.INFORMATION_MESSAGE);
+    }
+
     @Override
     public JPanel buildPluginPanel(final ComponentsTreeMap 
componentsWithActions) {
 
-        if(this.mainPanel != null) {
-            return this.mainPanel;
+        if (mainPanel != null) {
+            return mainPanel;
         }
-        this.mainPanel = new MainPanel(super.getInitialDialog(), 
componentsWithActions, false, false, true,
-                
PluginUtils.getResources().getString("MainPanel.ExecuteButton.text"), 
layerablesList) {
+        mainPanel = new MainPanel(super.getInitialDialog(),
+                componentsWithActions, false, false, true, PluginUtils
+                        .getResources().getString(
+                                "MainPanel.ExecuteButton.text"), 
layerablesList) {
 
+            /**
+                     * 
+                     */
+            private static final long serialVersionUID = 1L;
+
             @Override
             public void rightButton() {
                 try {
 
-                    //get input raster names
-                    String rasterSelected1 = 
GUIUtils.getStringValue(componentsWithActions.getComponent("00", 
GUIUtils.INPUT, 1));
+                    AbstractPlugIn.toActionListener(new ThreadedBasePlugIn() {
+                        @Override
+                        public String getName() {
+                            return null;
+                        }
 
-                    //get output raster name
-                    String outRasterName = 
GUIUtils.getStringValue(componentsWithActions.getComponent("00", 
GUIUtils.OUTPUT, 1));
+                        @Override
+                        public boolean execute(PlugInContext context)
+                                throws Exception {
+                            return true;
+                        }
 
-                    //check input values
-                    GUIUtils.checkStringValue(rasterSelected1, RASTER_DEM);
-                    GUIUtils.checkFileValue(outRasterName, 
GUIUtils.getOutputRasterString());
+                        @Override
+                        public void run(TaskMonitor monitor,
+                                PlugInContext context) throws Exception {
+                            monitor.report(PluginUtils.getResources()
+                                    .getString("OpenKlem.executing-process"));
+                            // monitor.allowCancellationRequests();
+                            reportNothingToUndoYet(context);
+                            try {
+                                demFillerCommand(componentsWithActions);
+                            } catch (final Exception ex) {
+                                Logger.error(getName(), ex);
+                            }
+                        }
+                    }, context.getWorkbenchContext(), new TaskMonitorManager())
+                            .actionPerformed(null);
 
-                    //get input raster as rasterImageLayer from string
-                    RasterImageLayer inputRasterSelected = 
PluginUtils.getRasterImageLayerSelected((CustomComboBox.RasterComboBox)componentsWithActions.getComponent("00",
 GUIUtils.INPUT, 1));
-                    DoubleBasicGrid demGrid = 
RasterUtils.getDoubleBasicGrid(inputRasterSelected);
-
-                    //Fill...
-                    DemFiller demFiller = new DemFiller(demGrid);
-                    DoubleBasicGrid demFilled = demFiller.calculate();
-
-                    //Save grid as tiff
-                    RasterUtils.saveOutputRasterAsTiff(demFilled, new 
File(outRasterName));
-                    //Display raster on OJ from file                
-                    RasterUtils.displayRasterFileOnOJ(
-                            context.getWorkbenchContext(),
-                            new File(outRasterName),
-                            null);
-
-                    JOptionPane.showMessageDialog(super.getInitialDialog(), 
-                            
PluginUtils.getResources().getString("SetWorkspacePlugin.Done.message"), 
PluginUtils.plugInName, JOptionPane.INFORMATION_MESSAGE);
-
-                } catch (Exception ex) {
-                    ErrorDialog.show(
-                            super.getInitialDialog(),
-                            PluginUtils.plugInName,
-                            ex.toString(),
+                } catch (final Exception ex) {
+                    ErrorDialog.show(super.getInitialDialog(),
+                            PluginUtils.plugInName, ex.toString(),
                             StringUtil.stackTrace(ex));
                 }
             }
@@ -127,18 +185,21 @@
                 throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
             }
         };
-        return this.mainPanel;
+        return mainPanel;
     }
 
     @Override
     public String toString() {
-        return 
PluginUtils.getResources().getString("DemFillerPlugIn.PlugInName.label");
+        return PluginUtils.getResources().getString(
+                "DemFillerPlugIn.PlugInName.label");
     }
 
     private MainPanel mainPanel;
     private final PlugInContext context;
-    private final String RASTER_DEM = 
PluginUtils.getResources().getString("KlemGUI.InputDem.label");
-    private final String RASTER_PITFILLEDDEM = 
PluginUtils.getResources().getString("KlemGUI.InputFilledDem.label");
+    private final String RASTER_DEM = PluginUtils.getResources().getString(
+            "KlemGUI.InputDem.label");
+    private final String RASTER_PITFILLEDDEM = PluginUtils.getResources()
+            .getString("KlemGUI.InputFilledDem.label");
     private final LayerablesList layerablesList;
 
 }

Modified: 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/FlowDirectionPlugIn.java
===================================================================
--- 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/FlowDirectionPlugIn.java
       2019-01-19 06:24:34 UTC (rev 6098)
+++ 
plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/FlowDirectionPlugIn.java
       2019-01-19 06:27:02 UTC (rev 6099)
@@ -1,40 +1,42 @@
 package com.geomaticaeambiente.klemgui.plugin.hydrology;
 
-import com.geomaticaeambiente.klemgui.utils.PluginUtils;
+import java.io.File;
+
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.openjump.core.rasterimage.RasterImageLayer;
+
 import com.geomaticaeambiente.klemgui.ui.CustomComboBox.LayerComboBox;
 import com.geomaticaeambiente.klemgui.ui.CustomComboBox.RasterComboBox;
 import com.geomaticaeambiente.klemgui.ui.GUIUtils;
 import com.geomaticaeambiente.klemgui.ui.InitialDialog;
+import com.geomaticaeambiente.klemgui.ui.LayerablesList;
 import com.geomaticaeambiente.klemgui.ui.MainPanel;
-import com.geomaticaeambiente.klemgui.ui.LayerablesList;
 import com.geomaticaeambiente.klemgui.ui.Symbologies;
 import com.geomaticaeambiente.klemgui.utils.AbstractInputKlemPlugin;
 import com.geomaticaeambiente.klemgui.utils.ActionObject;
 import com.geomaticaeambiente.klemgui.utils.ComponentsTreeMap;
 import com.geomaticaeambiente.klemgui.utils.GeometryUtils;
+import com.geomaticaeambiente.klemgui.utils.InitialData;
+import com.geomaticaeambiente.klemgui.utils.PluginUtils;
 import com.geomaticaeambiente.klemgui.utils.RasterUtils;
-import com.geomaticaeambiente.klemgui.utils.InitialData;
 import com.geomaticaeambiente.openjump.klem.flowdir.FlowDirsCalculator;
 import com.geomaticaeambiente.openjump.klem.flowdir.FlowDirsStripe;
 import com.geomaticaeambiente.openjump.klem.grid.DoubleBasicGrid;
 import com.geomaticaeambiente.openjump.klem.grid.FlowDirBasicGrid;
 import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jump.task.TaskMonitor;
 import com.vividsolutions.jump.util.StringUtil;
+import com.vividsolutions.jump.workbench.Logger;
 import com.vividsolutions.jump.workbench.model.Layer;
+import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.plugin.ThreadedBasePlugIn;
 import com.vividsolutions.jump.workbench.ui.ErrorDialog;
-import java.awt.geom.NoninvertibleTransformException;
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JButton;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import org.openjump.core.rasterimage.RasterImageLayer;
-import org.openjump.core.rasterimage.TiffTags;
+import com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager;
 
 /**
  *
@@ -42,7 +44,8 @@
  */
 public class FlowDirectionPlugIn extends AbstractInputKlemPlugin {
 
-    public FlowDirectionPlugIn(PlugInContext context, InitialDialog 
initialDialog, LayerablesList layerablesList) {
+    public FlowDirectionPlugIn(PlugInContext context,
+            InitialDialog initialDialog, LayerablesList layerablesList) {
         super(context, initialDialog);
         this.context = context;
         this.layerablesList = layerablesList;
@@ -51,90 +54,147 @@
     @Override
     public InitialData setInitialData() {
 
-//        ar_rasterImageLayers = PluginUtils.getRasterImageLayers(context);
+        //        ar_rasterImageLayers = 
PluginUtils.getRasterImageLayers(context);
 
-        InitialData initialData = new InitialData();
+        final InitialData initialData = new InitialData();
         //input data        
-        
initialData.setParam_Label_TextBox(GUIUtils.setGUILabel(RASTER_IN_LABEL),
-                
PluginUtils.getRasterImageLayers(layerablesList.getLayerables()), 
GUIUtils.INPUT);//combobox with rasterImageLayer
+        initialData.setParam_Label_TextBox(GUIUtils
+                .setGUILabel(RASTER_IN_LABEL), PluginUtils
+                .getRasterImageLayers(layerablesList.getLayerables()),
+                GUIUtils.INPUT);//combobox with rasterImageLayer
         initialData.setParam_Label_TextBox(
-                
GUIUtils.setGUILabel(PluginUtils.getResources().getString("HydrographKlemPlugin.Bluelines.label")),
-                PluginUtils.getLayers(layerablesList.getLayerables()), 
GUIUtils.INPUT);
+                GUIUtils.setGUILabel(PluginUtils.getResources().getString(
+                        "HydrographKlemPlugin.Bluelines.label")),
+                PluginUtils.getLayers(layerablesList.getLayerables()),
+                GUIUtils.INPUT);
 
         //output data
-        
initialData.setParam_Label_TextBox_Button(GUIUtils.setGUILabel(RASTER_FLOWDIRS),
 "", new ActionObject(""), GUIUtils.OUTPUT);
+        initialData.setParam_Label_TextBox_Button(
+                GUIUtils.setGUILabel(RASTER_FLOWDIRS), "",
+                new ActionObject(""), GUIUtils.OUTPUT);
 
         return initialData;
     }
 
     @Override
-    public ComponentsTreeMap setComponentsActions(ComponentsTreeMap 
personalTreeMap) {
+    public ComponentsTreeMap setComponentsActions(
+            ComponentsTreeMap personalTreeMap) {
 
-        final JTextField outputTextField = (JTextField) 
personalTreeMap.getComponent("00", GUIUtils.OUTPUT, 1);
-        JButton outputButton = (JButton) personalTreeMap.getComponent("00", 
GUIUtils.OUTPUT, 2);
+        final JTextField outputTextField = (JTextField) personalTreeMap
+                .getComponent("00", GUIUtils.OUTPUT, 1);
+        final JButton outputButton = (JButton) personalTreeMap.getComponent(
+                "00", GUIUtils.OUTPUT, 2);
         outputButton.setIcon(PluginUtils.getFolderIcon());
-        
outputButton.addActionListener(GUIUtils.setSaveRasterTif(outputTextField));
+        outputButton.addActionListener(GUIUtils
+                .setSaveRasterTif(outputTextField));
 
         return personalTreeMap;
     }
 
+    public void flowDirectionCommand(
+            final ComponentsTreeMap componentsWithActions) throws Exception {
+        //get input raster names
+        final String rasterSelected = GUIUtils
+                .getStringValue(componentsWithActions.getComponent("00",
+                        GUIUtils.INPUT, 1));
+
+        //get output raster name
+        final String outRasterName = GUIUtils
+                .getStringValue(componentsWithActions.getComponent("00",
+                        GUIUtils.OUTPUT, 1));
+
+        //check input values
+        GUIUtils.checkStringValue(rasterSelected, RASTER_IN_LABEL);
+        //check output values
+        GUIUtils.checkFileValue(outRasterName, 
GUIUtils.getOutputRasterString());
+
+        //get input raster as rasterImageLayer from string
+        final RasterImageLayer inputRasterSelected = PluginUtils
+                .getRasterImageLayerSelected((RasterComboBox) 
componentsWithActions
+                        .getComponent("00", GUIUtils.INPUT, 1));
+        final DoubleBasicGrid inputGrid = RasterUtils
+                .getDoubleBasicGrid(inputRasterSelected);
+
+        final Layer bluelinesLayer = PluginUtils
+                .getLayerSelected((LayerComboBox) componentsWithActions
+                        .getComponent("01", GUIUtils.INPUT, 1));
+
+        LineString[] bluelines = null;
+        if (bluelinesLayer != null) {
+            bluelines = GeometryUtils.getLineStringsFromFeatures(bluelinesLayer
+                    .getFeatureCollectionWrapper());
+        }
+
+        //Flow direction
+        final FlowDirsCalculator flowDireCalculator = new FlowDirsCalculator(
+                inputGrid, FlowDirsStripe.FlowDirAlgorithm.D8, bluelines, 
100d);
+        final FlowDirBasicGrid flowDirByteGrid = 
flowDireCalculator.calculate();
+
+        //Create the output rasterImageLayer
+        //Save grid as tiff
+        RasterUtils.saveOutputRasterAsTiff(flowDirByteGrid, new File(
+                outRasterName));
+        //Display raster on OJ from file                
+        RasterUtils.displayRasterFileOnOJ(context.getWorkbenchContext(),
+                new File(outRasterName), Symbologies.getFlowDirSymb());
+
+        JOptionPane.showMessageDialog(super.getInitialDialog(), PluginUtils
+                .getResources().getString("SetWorkspacePlugin.Done.message"),
+                PluginUtils.plugInName, JOptionPane.INFORMATION_MESSAGE);
+    }
+
     @Override
     public JPanel buildPluginPanel(final ComponentsTreeMap 
componentsWithActions) {
-        
-        if(this.mainPanel != null) {
-            return this.mainPanel;
+
+        if (mainPanel != null) {
+            return mainPanel;
         }
-        this.mainPanel = new MainPanel(super.getInitialDialog(), 
componentsWithActions, false, false, true,
-                
PluginUtils.getResources().getString("MainPanel.ExecuteButton.text"), 
layerablesList) {
+        mainPanel = new MainPanel(super.getInitialDialog(),
+                componentsWithActions, false, false, true, PluginUtils
+                        .getResources().getString(
+                                "MainPanel.ExecuteButton.text"), 
layerablesList) {
 
+            /**
+                     * 
+                     */
+            private static final long serialVersionUID = 1L;
+
             @Override
             public void rightButton() {
 
                 try {
 
-                    //get input raster names
-                    String rasterSelected = 
GUIUtils.getStringValue(componentsWithActions.getComponent("00", 
GUIUtils.INPUT, 1));
+                    AbstractPlugIn.toActionListener(new ThreadedBasePlugIn() {
+                        @Override
+                        public String getName() {
+                            return null;
+                        }
 
-                    //get output raster name
-                    String outRasterName = 
GUIUtils.getStringValue(componentsWithActions.getComponent("00", 
GUIUtils.OUTPUT, 1));
+                        @Override
+                        public boolean execute(PlugInContext context)
+                                throws Exception {
+                            return true;
+                        }
 
-                    //check input values
-                    GUIUtils.checkStringValue(rasterSelected, RASTER_IN_LABEL);
-                    //check output values
-                    GUIUtils.checkFileValue(outRasterName, 
GUIUtils.getOutputRasterString());
+                        @Override
+                        public void run(TaskMonitor monitor,
+                                PlugInContext context) throws Exception {
+                            monitor.report(PluginUtils.getResources()
+                                    .getString("OpenKlem.executing-process"));
+                            // monitor.allowCancellationRequests();
+                            reportNothingToUndoYet(context);
+                            try {
+                                flowDirectionCommand(componentsWithActions);
+                            } catch (final Exception ex) {
+                                Logger.error(getName(), ex);
+                            }
+                        }
+                    }, context.getWorkbenchContext(), new TaskMonitorManager())
+                            .actionPerformed(null);
 
-                    //get input raster as rasterImageLayer from string
-                    RasterImageLayer inputRasterSelected = 
PluginUtils.getRasterImageLayerSelected((RasterComboBox)componentsWithActions.getComponent("00",
 GUIUtils.INPUT, 1));
-                    DoubleBasicGrid inputGrid = 
RasterUtils.getDoubleBasicGrid(inputRasterSelected);
-
-                    Layer bluelinesLayer = 
PluginUtils.getLayerSelected((LayerComboBox) 
componentsWithActions.getComponent("01", GUIUtils.INPUT, 1));
-                    
-                    LineString[] bluelines = null;
-                    if(bluelinesLayer != null) {   
-                        bluelines = 
GeometryUtils.getLineStringsFromFeatures(bluelinesLayer.getFeatureCollectionWrapper());
-                    }
-                    
-                    //Flow direction
-                    FlowDirsCalculator flowDireCalculator = new 
FlowDirsCalculator(inputGrid, FlowDirsStripe.FlowDirAlgorithm.D8, bluelines, 
100d);
-                    FlowDirBasicGrid flowDirByteGrid = 
flowDireCalculator.calculate();
-
-                    //Create the output rasterImageLayer
-                    //Save grid as tiff
-                    RasterUtils.saveOutputRasterAsTiff(flowDirByteGrid, new 
File(outRasterName));
-                    //Display raster on OJ from file                
-                    RasterUtils.displayRasterFileOnOJ(
-                            context.getWorkbenchContext(),
-                            new File(outRasterName),
-                            Symbologies.getFlowDirSymb());
-
-                    JOptionPane.showMessageDialog(super.getInitialDialog(), 
-                            
PluginUtils.getResources().getString("SetWorkspacePlugin.Done.message"), 
PluginUtils.plugInName, JOptionPane.INFORMATION_MESSAGE);
-                    
-                } catch (Exception ex) {
-                    ErrorDialog.show(
-                            super.getInitialDialog(),
-                            PluginUtils.plugInName,
-                            ex.toString(),
+                } catch (final Exception ex) {
+                    ErrorDialog.show(super.getInitialDialog(),
+                            PluginUtils.plugInName, ex.toString(),
                             StringUtil.stackTrace(ex));
                 }
 
@@ -152,19 +212,22 @@
 
         };
 
-        return this.mainPanel;
+        return mainPanel;
     }
 
     @Override
     public String toString() {
-        return 
PluginUtils.getResources().getString("FlowDirectionPlugin.PlugInName.label");
+        return PluginUtils.getResources().getString(
+                "FlowDirectionPlugin.PlugInName.label");
     }
 
     private MainPanel mainPanel;
     private final PlugInContext context;
-//    private RasterImageLayer[] ar_rasterImageLayers;
-    private final String RASTER_IN_LABEL = 
PluginUtils.getResources().getString("KlemGUI.InputFilledDem.label");
-    private final String RASTER_FLOWDIRS = 
PluginUtils.getResources().getString("FlowDirectionPlugin.PlugInName.label");
+    //    private RasterImageLayer[] ar_rasterImageLayers;
+    private final String RASTER_IN_LABEL = PluginUtils.getResources()
+            .getString("KlemGUI.InputFilledDem.label");
+    private final String RASTER_FLOWDIRS = PluginUtils.getResources()
+            .getString("FlowDirectionPlugin.PlugInName.label");
     private final LayerablesList layerablesList;
 
 }



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to