Revision: 6026 http://sourceforge.net/p/jump-pilot/code/6026 Author: ma15569 Date: 2018-12-22 09:30:47 +0000 (Sat, 22 Dec 2018) Log Message: ----------- Add language string codes. Add monitor to some process which can take a long time to finalize
Modified Paths: -------------- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/hydrographs/klem/ParamsTab.java plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/rastertools/RasterHistogramPlugIn.java plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle.properties plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_en.properties plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_it.properties Modified: plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/hydrographs/klem/ParamsTab.java =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/hydrographs/klem/ParamsTab.java 2018-12-20 18:56:18 UTC (rev 6025) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/hydrology/hydrographs/klem/ParamsTab.java 2018-12-22 09:30:47 UTC (rev 6026) @@ -24,6 +24,8 @@ import javax.xml.parsers.ParserConfigurationException; import com.geomaticaeambiente.klemgui.exceptions.WarningException; +import com.geomaticaeambiente.klemgui.plugin.hydrology.hydrographs.klem.KlemUtils; +import com.geomaticaeambiente.klemgui.plugin.hydrology.hydrographs.klem.OutputTab; import com.geomaticaeambiente.klemgui.plugin.hydrology.hydrographs.klem.KlemProperties.RainfallType; import com.geomaticaeambiente.klemgui.ui.GUIUtils; import com.geomaticaeambiente.klemgui.ui.InitialDialog; @@ -35,9 +37,13 @@ import com.geomaticaeambiente.klemgui.utils.ComponentsTreeMap; import com.geomaticaeambiente.klemgui.utils.InitialData; import com.geomaticaeambiente.klemgui.utils.PluginUtils; +import com.vividsolutions.jump.task.TaskMonitor; import com.vividsolutions.jump.util.StringUtil; +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 com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager; /** * @@ -65,6 +71,33 @@ return setParamsTabComponentsTreeMap(personalTreeMap); } + public void calculateParameters( + final ComponentsTreeMap componentsWithActions) + throws ParserConfigurationException, IOException, WarningException, + Exception { + KlemUtils.checkParams(componentsWithActions, klemProps, + rainfallParamType); + final Klem klem = KlemUtils.buildKlem(klemProps); + + // super.getInitialDialog().setCursor(new Cursor(Cursor.WAIT_CURSOR)); + klem.run(); + + final SimulationOutput simOut = klem.getSimulationOutput(); + + final JTabbedPane mainTabelPane = super.getInitialDialog() + .getTabbedPane(); + final OutputTab outputPanel = new OutputTab(context, + super.getInitialDialog(), layerablesList, simOut, klem); + outputPanel.setKlemProperties(klemProps); + mainTabelPane.setComponentAt(3, outputPanel.getTabPluginComponents()); + + mainTabelPane.setEnabledAt(3, true); + // mainTabelPane.setEnabledAt(2, true); + mainTabelPane.setSelectedIndex(3); + } + + + @Override public JPanel buildPluginPanel(final ComponentsTreeMap componentsWithActions) { @@ -87,40 +120,39 @@ public void rightButton() { // OUTPUT try { - KlemUtils.checkParams(componentsWithActions, klemProps, - rainfallParamType); - final Klem klem = KlemUtils.buildKlem(klemProps); + AbstractPlugIn.toActionListener(new ThreadedBasePlugIn() { + @Override + public String getName() { + return null; + } - super.getInitialDialog().setCursor( - new Cursor(Cursor.WAIT_CURSOR)); - klem.run(); + @Override + public boolean execute(PlugInContext context) + throws Exception { + return true; + } - final SimulationOutput simOut = klem.getSimulationOutput(); + @Override + public void run(TaskMonitor monitor, + PlugInContext context) throws Exception { + monitor.report(PluginUtils.getResources() + .getString("OpenKlem.executing-process")); + reportNothingToUndoYet(context); + try { + calculateParameters(componentsWithActions); + } catch (final Exception ex) { + JOptionPane.showMessageDialog( + getInitialDialog().getTabbedPane(), + PluginUtils.getResources().getString( + "Process interrupted"), + PluginUtils.plugInName, + JOptionPane.INFORMATION_MESSAGE); - final JTabbedPane mainTabelPane = super.getInitialDialog() - .getTabbedPane(); - final OutputTab outputPanel = new OutputTab(context, - super.getInitialDialog(), layerablesList, simOut, - klem); - outputPanel.setKlemProperties(klemProps); - mainTabelPane.setComponentAt(3, - outputPanel.getTabPluginComponents()); - - mainTabelPane.setEnabledAt(3, true); - // mainTabelPane.setEnabledAt(2, true); - mainTabelPane.setSelectedIndex(3); - - super.getInitialDialog().setCursor( - new Cursor(Cursor.DEFAULT_CURSOR)); - - } catch (final WarningException ex) { - JOptionPane.showMessageDialog(super.getInitialDialog(), - ex.getMessage(), PluginUtils.plugInName, - JOptionPane.WARNING_MESSAGE); + } + } + }, context.getWorkbenchContext(), new TaskMonitorManager()) + .actionPerformed(null); } catch (final Exception ex) { - ex.printStackTrace(System.out); - super.getInitialDialog().setCursor( - new Cursor(Cursor.DEFAULT_CURSOR)); ErrorDialog.show(super.getInitialDialog(), PluginUtils.plugInName, ex.toString(), StringUtil.stackTrace(ex)); Modified: plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/rastertools/RasterHistogramPlugIn.java =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/rastertools/RasterHistogramPlugIn.java 2018-12-20 18:56:18 UTC (rev 6025) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/rastertools/RasterHistogramPlugIn.java 2018-12-22 09:30:47 UTC (rev 6026) @@ -76,7 +76,62 @@ return personalTreeMap; } + + + public void histogramCommand(final ComponentsTreeMap componentsWithActions) + throws Exception { + // input values + final String inRaster = GUIUtils.getStringValue(componentsWithActions + .getComponent("00", GUIUtils.INPUT, 1)); + + final JComboBox jComboBox_Algo = (JComboBox) componentsWithActions + .getComponent("01", GUIUtils.INPUT, 1); + final String selectedAlgo = jComboBox_Algo.getSelectedItem().toString(); + + final String interval = GUIUtils.getStringValue(componentsWithActions + .getComponent("02", GUIUtils.INPUT, 1)); + final String base = GUIUtils.getStringValue(componentsWithActions + .getComponent("03", GUIUtils.INPUT, 1)); + + checksValues(inRaster, selectedAlgo, interval, base); + + final DoubleBasicGrid rasterGrid = RasterUtils + .getDoubleBasicGrid((CustomComboBox.RasterComboBox) componentsWithActions + .getComponent("00", GUIUtils.INPUT, 1)); + + final HistogramCalculator rasterHisto = new HistogramCalculator(); + Histogram histo = null; + + if (selectedAlgo.equalsIgnoreCase(AUTO)) { + histo = rasterHisto.calcStatsContinuous(rasterGrid, new Autoscale( + rasterGrid)); + } else if (selectedAlgo.equalsIgnoreCase(UNIQUE_VALS)) { + histo = rasterHisto.calcStatsUnique(rasterGrid); + } else if (selectedAlgo.equalsIgnoreCase(GIVEN_INTERVAL)) { + + final double intervalVal = Double.parseDouble(interval); + final double baseVal = Double.parseDouble(base); + + histo = rasterHisto.calcStatsContinuous(rasterGrid, + new GivenIntervals(rasterGrid, intervalVal, baseVal)); + } + + if (histo == null) { + return; + } + + final JTabbedPane mainTabelPane = getInitialDialog().getTabbedPane(); + + final PersonalChartHistogram persChartHisto = new PersonalChartHistogram(); + + mainTabelPane.setComponentAt(1, persChartHisto.buildHistogramPanel( + getInitialDialog().getTabbedPane(), histo)); + mainTabelPane.setEnabledAt(1, true); + mainTabelPane.setSelectedIndex(1); + } + + @Override public JPanel buildPluginPanel(final ComponentsTreeMap componentsWithActions) { if(this.mainPanel != null) { @@ -85,10 +140,10 @@ this.mainPanel = new MainPanel(super.getInitialDialog(), componentsWithActions, false, false, true, PluginUtils.getResources().getString("MainPanel.ExecuteButton.text"), layerablesList) { + @Override public void rightButton() { try { - AbstractPlugIn .toActionListener( new ThreadedBasePlugIn() { @@ -108,121 +163,22 @@ public void run(TaskMonitor monitor, PlugInContext context) throws Exception { - monitor.report(PluginUtils + monitor.report(PluginUtils.getResources() + .getString("OpenKlem.executing-process")+": "+PluginUtils .getResources() .getString( "RasterHistogram.PlugInName.label")); // monitor.allowCancellationRequests(); - reportNothingToUndoYet(context); try { - - // input values - final String inRaster = GUIUtils - .getStringValue(componentsWithActions - .getComponent( - "00", - GUIUtils.INPUT, - 1)); - - final JComboBox jComboBox_Algo = (JComboBox) componentsWithActions - .getComponent("01", - GUIUtils.INPUT, - 1); - final String selectedAlgo = jComboBox_Algo - .getSelectedItem() - .toString(); - - final String interval = GUIUtils - .getStringValue(componentsWithActions - .getComponent( - "02", - GUIUtils.INPUT, - 1)); - final String base = GUIUtils - .getStringValue(componentsWithActions - .getComponent( - "03", - GUIUtils.INPUT, - 1)); - - checksValues(inRaster, - selectedAlgo, interval, - base); - - final DoubleBasicGrid rasterGrid = RasterUtils - .getDoubleBasicGrid((CustomComboBox.RasterComboBox) componentsWithActions - .getComponent( - "00", - GUIUtils.INPUT, - 1)); - - final HistogramCalculator rasterHisto = new HistogramCalculator(); - Histogram histo = null; - - if (selectedAlgo - .equalsIgnoreCase(AUTO)) { - histo = rasterHisto - .calcStatsContinuous( - rasterGrid, - new Autoscale( - rasterGrid)); - } else if (selectedAlgo - .equalsIgnoreCase(UNIQUE_VALS)) { - histo = rasterHisto - .calcStatsUnique(rasterGrid); - } else if (selectedAlgo - .equalsIgnoreCase(GIVEN_INTERVAL)) { - - final double intervalVal = Double - .parseDouble(interval); - final double baseVal = Double - .parseDouble(base); - - histo = rasterHisto - .calcStatsContinuous( - rasterGrid, - new GivenIntervals( - rasterGrid, - intervalVal, - baseVal)); - } - - if (histo == null) { - return; - } - - final JTabbedPane mainTabelPane = getInitialDialog() - .getTabbedPane(); - - final PersonalChartHistogram persChartHisto = new PersonalChartHistogram(); - - mainTabelPane - .setComponentAt( - 1, - persChartHisto - .buildHistogramPanel( - getInitialDialog() - .getTabbedPane(), - histo)); - mainTabelPane.setEnabledAt(1, - true); - mainTabelPane - .setSelectedIndex(1); - } catch (final ThreadDeath td) { - JOptionPane - .showMessageDialog( - getInitialDialog() - .getTabbedPane(), - "Processo interrotto", - PluginUtils.plugInName, - JOptionPane.INFORMATION_MESSAGE); + histogramCommand(componentsWithActions); } catch (final Exception ex) { JOptionPane .showMessageDialog( getInitialDialog() .getTabbedPane(), - "Processo interrotto", + PluginUtils.getResources().getString( + "Process interrupted"), PluginUtils.plugInName, JOptionPane.INFORMATION_MESSAGE); @@ -232,8 +188,6 @@ new TaskMonitorManager()) .actionPerformed(null); } catch (final Exception ex) { - super.getInitialDialog().setCursor( - new Cursor(Cursor.DEFAULT_CURSOR)); ErrorDialog.show(super.getInitialDialog(), PluginUtils.plugInName, ex.toString(), StringUtil.stackTrace(ex)); Modified: plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle.properties =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle.properties 2018-12-20 18:56:18 UTC (rev 6025) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle.properties 2018-12-22 09:30:47 UTC (rev 6026) @@ -1,6 +1,8 @@ OpenKLEM.name=OpenKlem (Open Kinematic Local Excess Model) OpenKlem.version=Version -OpenKlem.version-number=2018-07-28 +OpenKlem.version-number=2018-12-22 +OpenKlem.executing-process=Executing process... +OpenKlem.process-interrupted=Process interrupted CutRasterPlugIn.InputData.MaskRaster=Mask raster CutRasterPlugIn.OutputData.OutputRaster=Out raster ReclassRasterComponents.jLabel_StDev.text=Std. dev. Modified: plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_en.properties =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_en.properties 2018-12-20 18:56:18 UTC (rev 6025) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_en.properties 2018-12-22 09:30:47 UTC (rev 6026) @@ -1,6 +1,8 @@ OpenKLEM.name=OpenKlem (Open Kinematic Local Excess Model) OpenKlem.version=Version -OpenKlem.version-number=2018-07-28 +OpenKlem.version-number=2018-12-22 +OpenKlem.executing-process=Executing process... +OpenKlem.process-interrupted=Process interrupted CutRasterPlugIn.InputData.MaskRaster=Mask raster CutRasterPlugIn.OutputData.OutputRaster=Out raster ReclassRasterComponents.jLabel_StDev.text=Std. dev. Modified: plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_it.properties =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_it.properties 2018-12-20 18:56:18 UTC (rev 6025) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_it.properties 2018-12-22 09:30:47 UTC (rev 6026) @@ -1,6 +1,8 @@ OpenKLEM.name=OpenKlem (Open Kinematic Local Excess Model) OpenKlem.version=Versione -OpenKlem.version-number=2018-07-28 +OpenKlem.version-number=2018-12-22 +OpenKlem.executing-process=Eseguendo il processo... +OpenKlem.process-interrupted=Processo interrotto RasterizeVectorLayerPlugIn.CellDimensionLabel.text=Dimensione cella RasterizeVectorLayerPlugIn.SnapRasterCheckbox.text=Snap raster CurveNumberPlugIn.reclassTable.label=Tabella di riclassificazione _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel