Revision: 6019 http://sourceforge.net/p/jump-pilot/code/6019 Author: ma15569 Date: 2018-12-20 15:01:45 +0000 (Thu, 20 Dec 2018) Log Message: ----------- RasterHistogramPlugIn. Changed rightButton() action to OpenJUMP AbstractPlugIn action in order to interupt the process if it takes too much time
Modified Paths: -------------- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/ChangeLog 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/ChangeLog =================================================================== --- plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/ChangeLog 2018-12-16 16:20:27 UTC (rev 6018) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/ChangeLog 2018-12-20 15:01:45 UTC (rev 6019) @@ -3,6 +3,10 @@ # 2. make sure that lines break at 80 chars for constricted display situations #<-------------------------------- 80 chars ----------------------------------># +2018-12-20 Giuseppe Aruta. RasterHistogramPlugIn. Changed rightButton() action to + OpenJUMP AbstractPlugIn action in order to interupt the process if it takes + too much time + 2018-10-04 Giuseppe Aruta. Moved SlopeAspectHillShadePlugin to Geomorphometry tree node 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-16 16:20:27 UTC (rev 6018) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/plugin/rastertools/RasterHistogramPlugIn.java 2018-12-20 15:01:45 UTC (rev 6019) @@ -1,5 +1,7 @@ package com.geomaticaeambiente.klemgui.plugin.rastertools; +import java.awt.Cursor; + import com.geomaticaeambiente.klemgui.utils.PluginUtils; import com.geomaticaeambiente.klemgui.ui.CustomComboBox; import com.geomaticaeambiente.klemgui.ui.GUIUtils; @@ -16,10 +18,16 @@ import com.geomaticaeambiente.openjump.klem.rastertools.HistogramCalculator.Histogram; import com.geomaticaeambiente.openjump.klem.rastertools.classifiers.Autoscale; import com.geomaticaeambiente.openjump.klem.rastertools.classifiers.GivenIntervals; +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; + import javax.swing.JComboBox; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; @@ -77,60 +85,160 @@ this.mainPanel = new MainPanel(super.getInitialDialog(), componentsWithActions, false, false, true, PluginUtils.getResources().getString("MainPanel.ExecuteButton.text"), layerablesList) { - @Override public void rightButton() { - try{ - //input values - String inRaster = GUIUtils.getStringValue(componentsWithActions.getComponent("00", GUIUtils.INPUT, 1)); + try { - JComboBox jComboBox_Algo = (JComboBox) componentsWithActions.getComponent("01", GUIUtils.INPUT, 1); - String selectedAlgo = jComboBox_Algo.getSelectedItem().toString(); - - String interval = GUIUtils.getStringValue(componentsWithActions.getComponent("02", GUIUtils.INPUT, 1)); - String base = GUIUtils.getStringValue(componentsWithActions.getComponent("03", GUIUtils.INPUT, 1)); - - checksValues(inRaster, selectedAlgo, interval, base); - - DoubleBasicGrid rasterGrid = RasterUtils.getDoubleBasicGrid( - (CustomComboBox.RasterComboBox) componentsWithActions.getComponent("00", GUIUtils.INPUT, 1)); - - 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)) { - - double intervalVal = Double.parseDouble(interval); - double baseVal = Double.parseDouble(base); - - histo = rasterHisto.calcStatsContinuous(rasterGrid, - new GivenIntervals(rasterGrid, intervalVal, baseVal)); - } - - if(histo == null) { - return; - } - - JTabbedPane mainTabelPane = super.getInitialDialog().getTabbedPane(); + AbstractPlugIn + .toActionListener( + new ThreadedBasePlugIn() { + @Override + public String getName() { + return null; + } - PersonalChartHistogram persChartHisto = new PersonalChartHistogram(); - - mainTabelPane.setComponentAt(1, persChartHisto.buildHistogramPanel( - this.getInitialDialog().getTabbedPane(), histo)); - mainTabelPane.setEnabledAt(1, true); - mainTabelPane.setSelectedIndex(1); - - }catch (Exception ex){ - ErrorDialog.show( - super.getInitialDialog(), - PluginUtils.plugInName, - ex.toString(), + @Override + public boolean execute( + PlugInContext context) + throws Exception { + return true; + } + + @Override + public void run(TaskMonitor monitor, + PlugInContext context) + throws Exception { + monitor.report(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); + } catch (final Exception ex) { + JOptionPane + .showMessageDialog( + getInitialDialog() + .getTabbedPane(), + "Processo interrotto", + PluginUtils.plugInName, + JOptionPane.INFORMATION_MESSAGE); + + } + } + }, context.getWorkbenchContext(), + 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)); } + } @Override 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-16 16:20:27 UTC (rev 6018) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle.properties 2018-12-20 15:01:45 UTC (rev 6019) @@ -409,6 +409,7 @@ KlemGUI.ClassAlgo.label=Classifier KlemGUI.ClassAlgo.Algo.Auto=Auto RasterHistogram.PlugInName.label=Raster histogram +RasterHistogram.PlugInName.label=Calculating raster histogram... HydrographKlemPlugin.ChecParamA.message=Please, check the IFD a parameter (30-120). HydrographKlemPlugin.ChecParamN.message=Please, check the IFD n parameter (0-1). KlemGUI.ClassAlgo.Algo.UniqueVals=Unique values 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-16 16:20:27 UTC (rev 6018) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_en.properties 2018-12-20 15:01:45 UTC (rev 6019) @@ -402,6 +402,7 @@ KlemGUI.ClassAlgo.label=Classifier KlemGUI.ClassAlgo.Algo.Auto=Auto RasterHistogram.PlugInName.label=Raster histogram +RasterHistogram.PlugInName.label=Calculating raster histogram... HydrographKlemPlugin.ChecParamA.message=Please, check the IFD a parameter (30-120). HydrographKlemPlugin.ChecParamN.message=Please, check the IFD n param (0-1). KlemGUI.ClassAlgo.Algo.UniqueVals=Unique values 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-16 16:20:27 UTC (rev 6018) +++ plug-ins/OpenKLEM/OpenKLEMOpenJUMP/trunk/src/com/geomaticaeambiente/klemgui/resources/Bundle_it.properties 2018-12-20 15:01:45 UTC (rev 6019) @@ -402,6 +402,7 @@ KlemGUI.ClassAlgo.label=Classificatore KlemGUI.ClassAlgo.Algo.Auto=Auto RasterHistogram.PlugInName.label=Istogramma raster +RasterHistogram.PlugInName.label=Calculating raster histogram... HydrographKlemPlugin.ChecParamA.message=Verificare il parametro a delle LSPP. HydrographKlemPlugin.ChecParamN.message=Please, check the IFD n param (0-1). KlemGUI.ClassAlgo.Algo.UniqueVals=Valori unici _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel