Revision: 4859 http://sourceforge.net/p/jump-pilot/code/4859 Author: ma15569 Date: 2016-03-23 17:52:32 +0000 (Wed, 23 Mar 2016) Log Message: ----------- 2016-03- 23 Giuseppe Aruta <giuseppe_ar...@yahoo.it> emhenced version of RasterImageLayerPropertiesPlugIn: 1) New display style HTML table "a la" GvSIG, 2) Faster info checker (all cell statistic related to Sextante raster image have been removed as alredy embedded into Raster Statistic plugin, 3) Added a limited projection checker < see other details into org.openjump.core.ui.util.ProjUtils.class>, 4) Added a Raster Transparency panel *
Modified Paths: -------------- core/trunk/ChangeLog core/trunk/src/language/jump.properties core/trunk/src/language/jump_cz.properties core/trunk/src/language/jump_de.properties core/trunk/src/language/jump_es.properties core/trunk/src/language/jump_fi.properties core/trunk/src/language/jump_fr.properties core/trunk/src/language/jump_hu.properties core/trunk/src/language/jump_it.properties core/trunk/src/language/jump_ja_JP.properties core/trunk/src/language/jump_ml.properties core/trunk/src/language/jump_pt.properties core/trunk/src/language/jump_pt_BR.properties core/trunk/src/language/jump_ta_IN.properties core/trunk/src/language/jump_te.properties core/trunk/src/language/jump_zh_CN.properties core/trunk/src/language/jump_zh_HK.properties core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/panel/RasterTransparencyPanel.java core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java Added Paths: ----------- core/trunk/src/org/openjump/core/ui/util/ProjUtils.java Modified: core/trunk/ChangeLog =================================================================== --- core/trunk/ChangeLog 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/ChangeLog 2016-03-23 17:52:32 UTC (rev 4859) @@ -3,6 +3,16 @@ # 2. make sure that lines break at 80 chars for constricted display situations #<-------------------------------- 80 chars ----------------------------------># +2016-03- 23 Giuseppe Aruta <giuseppe_ar...@yahoo.it> + * emhenced version of RasterImageLayerPropertiesPlugIn: + * 1) New info HTML table "a la" GvSIG style + * 2) Faster info checker (all cell statistic related to Sextante raster image + * have been removed as alredy embedded into Raster Statistic plugin + * 3) Added a limited projection checker < see other details into + * org.openjump.core.ui.util.ProjUtils.class + * 4) Added a Raster Transparency panel + * + 2016-03-15 mmichaud <m.michael.mich...@orange.fr> * Switch compiler source and target to java 1.7 * Adopt java 5 style for feature package (generics, foreach loops) Modified: core/trunk/src/language/jump.properties =================================================================== --- core/trunk/src/language/jump.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -1099,6 +1099,9 @@ org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number = bands org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum = sum org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory = Layer not saved +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata=Geographic metadata org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.columns = Columns org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.rows = Rows org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.name = Compare selected Grid Raster layers Modified: core/trunk/src/language/jump_cz.properties =================================================================== --- core/trunk/src/language/jump_cz.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_cz.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -1050,6 +1050,9 @@ org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number= \#T\:bands org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum= \#T\:sum org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory= \#T\:Layer not saved +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.columns=\#T\:Columns org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.rows=\#T\:Rows org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.name=\#T\:Compare Grid Raster layers Modified: core/trunk/src/language/jump_de.properties =================================================================== --- core/trunk/src/language/jump_de.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_de.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -1073,6 +1073,9 @@ org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number = B\u00E4nder org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum = Summe org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory = Ebene nicht gespeichert +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.columns = Spalten org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.rows = Reihen org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.name = Vergleiche Rasterebenen Modified: core/trunk/src/language/jump_es.properties =================================================================== --- core/trunk/src/language/jump_es.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_es.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -1060,6 +1060,9 @@ org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number=bandas org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum= suma org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory= Capa sin datos +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = No reconosido o no definido +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = Projeci\00F3n +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= etadatos geogr\u00e1ficos org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.columns=Columnas org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.rows=l\u00edneas org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.name=Comparar capas MDE selecionadas Modified: core/trunk/src/language/jump_fi.properties =================================================================== --- core/trunk/src/language/jump_fi.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_fi.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2624,3 +2624,6 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata Modified: core/trunk/src/language/jump_fr.properties =================================================================== --- core/trunk/src/language/jump_fr.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_fr.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2654,3 +2654,6 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=Angle minimum org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=Supprimer les pointes (ou rebroussements) org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=Localisation des pointes +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_hu.properties =================================================================== --- core/trunk/src/language/jump_hu.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_hu.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2647,3 +2647,6 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_it.properties =================================================================== --- core/trunk/src/language/jump_it.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_it.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -1060,6 +1060,9 @@ org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number=bande org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum=somma org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory=Livello senza datasource +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = Non riconosciuta o non impostata +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = Proiezione +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata=Metadati geografici org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.columns=Colonne org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.rows=Righe org.openjump.core.ui.plugin.raster.DEMStatisticsPlugIn.name=Compara livelli raster DEM selezionati Modified: core/trunk/src/language/jump_ja_JP.properties =================================================================== --- core/trunk/src/language/jump_ja_JP.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_ja_JP.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2648,4 +2648,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_ml.properties =================================================================== --- core/trunk/src/language/jump_ml.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_ml.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -3919,4 +3919,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_pt.properties =================================================================== --- core/trunk/src/language/jump_pt.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_pt.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2644,4 +2644,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_pt_BR.properties =================================================================== --- core/trunk/src/language/jump_pt_BR.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_pt_BR.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2645,4 +2645,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_ta_IN.properties =================================================================== --- core/trunk/src/language/jump_ta_IN.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_ta_IN.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2647,4 +2647,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_te.properties =================================================================== --- core/trunk/src/language/jump_te.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_te.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -3153,4 +3153,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_zh_CN.properties =================================================================== --- core/trunk/src/language/jump_zh_CN.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_zh_CN.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2808,4 +2808,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/language/jump_zh_HK.properties =================================================================== --- core/trunk/src/language/jump_zh_HK.properties 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/language/jump_zh_HK.properties 2016-03-23 17:52:32 UTC (rev 4859) @@ -2807,4 +2807,7 @@ org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance=\#T\:Angle tolerance org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.angle-tolerance-tooltip=\#T\:Minimum angle org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn=\#T\:Remove spikes -org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation \ No newline at end of file +org.openjump.core.ui.plugin.tools.RemoveSpikePlugIn.spikes-localisation=\#T\:Spikes localisation +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection = \#T\:Not recognized or not set +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection = \#T\:Projection +org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata= \#T\:Geographic metadata \ No newline at end of file Modified: core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/panel/RasterTransparencyPanel.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/panel/RasterTransparencyPanel.java 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/panel/RasterTransparencyPanel.java 2016-03-23 17:52:32 UTC (rev 4859) @@ -50,191 +50,192 @@ * ChangeRasterImageStyleDialog */ public class RasterTransparencyPanel extends JPanel implements ValueChecker, - ActionListener, StylePanel { - private static final long serialVersionUID = 619781257815627447L; + ActionListener, StylePanel { + private static final long serialVersionUID = 619781257815627447L; - protected JColorChooser colorChooser = new JColorChooser(); - protected RasterImageLayer rasterImageLayer = null; - protected JSlider transparencySlider = new JSlider(), - speedSlider = new JSlider(); - protected Dictionary sliderLabelDictionary = new Hashtable(); - protected JCheckBox useTransCB = null; + protected JColorChooser colorChooser = new JColorChooser(); + protected RasterImageLayer rasterImageLayer = null; + protected JSlider transparencySlider = new JSlider(), + speedSlider = new JSlider(); + protected Dictionary sliderLabelDictionary = new Hashtable(); + protected JCheckBox useTransCB = null; - // protected JButton useTransCB; - // JButton useTransCB = new JButton("Click"); + // protected JButton useTransCB; + // JButton useTransCB = new JButton("Click"); - public RasterTransparencyPanel(RasterImageLayer rasterImageLayer) { - super(new BorderLayout()); + public RasterTransparencyPanel(RasterImageLayer rasterImageLayer) { + super(new BorderLayout()); - this.rasterImageLayer = rasterImageLayer; + this.rasterImageLayer = rasterImageLayer; - this.setupGui(); - } + this.setupGui(); + } - @SuppressWarnings("unchecked") - public void setupGui() { + @SuppressWarnings("unchecked") + public void setupGui() { - JPanel transparencyOnOffPanel = new JPanel(); + JPanel transparencyOnOffPanel = new JPanel(); - transparencyOnOffPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - transparencyOnOffPanel - .add(new JLabel( - I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.Do-you-want-a-color-to-be-transparent"))); - // this.useTransCB =new JButton(IconLoader.icon("color_wheel.png")); + transparencyOnOffPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); + transparencyOnOffPanel + .add(new JLabel( + I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.Do-you-want-a-color-to-be-transparent"))); + // this.useTransCB =new JButton(IconLoader.icon("color_wheel.png")); - this.useTransCB = new JCheckBox(); - transparencyOnOffPanel.add(this.useTransCB); - this.useTransCB.addActionListener(this); + this.useTransCB = new JCheckBox(); + transparencyOnOffPanel.add(this.useTransCB); + this.useTransCB.addActionListener(this); - this.colorChooser.getSelectionModel().setSelectedColor( - this.rasterImageLayer.getTransparentColor()); - this.colorChooser - .setToolTipText(I18N - .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.Choose-transparent-color")); - this.colorChooser.setBorder(BorderFactory.createEtchedBorder()); - JPanel slidersPanel = new JPanel(); - slidersPanel.setLayout(new GridLayout(2, 1)); + this.colorChooser.getSelectionModel().setSelectedColor( + this.rasterImageLayer.getTransparentColor()); + this.colorChooser + .setToolTipText(I18N + .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.Choose-transparent-color")); + this.colorChooser.setBorder(BorderFactory.createEtchedBorder()); + JPanel slidersPanel = new JPanel(); + slidersPanel.setLayout(new GridLayout(2, 1)); - JPanel transparencySliderPanel = new JPanel(); - transparencySliderPanel.setLayout(new GridLayout(2, 1)); - transparencySliderPanel - .add(new JLabel( - " " + I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.set-overall-transparency"))); + JPanel transparencySliderPanel = new JPanel(); + transparencySliderPanel.setLayout(new GridLayout(2, 1)); + transparencySliderPanel + .add(new JLabel( + " " + + I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.set-overall-transparency"))); - for (int i = 0; i <= 100; i += 25) { - this.sliderLabelDictionary.put(new Integer(i), new JLabel(i + "%")); - } - this.transparencySlider.setLabelTable(this.sliderLabelDictionary); - this.transparencySlider.setPaintLabels(true); + for (int i = 0; i <= 100; i += 25) { + this.sliderLabelDictionary.put(new Integer(i), new JLabel(i + "%")); + } + this.transparencySlider.setLabelTable(this.sliderLabelDictionary); + this.transparencySlider.setPaintLabels(true); - this.transparencySlider.setMaximum(100); - this.transparencySlider.setMinimum(0); - this.transparencySlider.setMajorTickSpacing(10); - this.transparencySlider.setMinorTickSpacing(5); - this.transparencySlider.setPaintTicks(true); + this.transparencySlider.setMaximum(100); + this.transparencySlider.setMinimum(0); + this.transparencySlider.setMajorTickSpacing(10); + this.transparencySlider.setMinorTickSpacing(5); + this.transparencySlider.setPaintTicks(true); - this.transparencySlider.setMinimumSize(new Dimension(150, 20)); - this.transparencySlider.setValue((int) (this.rasterImageLayer - .getTransparencyLevel() * 100)); + this.transparencySlider.setMinimumSize(new Dimension(150, 20)); + this.transparencySlider.setValue((int) (this.rasterImageLayer + .getTransparencyLevel() * 100)); - transparencySliderPanel.add(this.transparencySlider); + transparencySliderPanel.add(this.transparencySlider); - slidersPanel.add(transparencySliderPanel); + slidersPanel.add(transparencySliderPanel); - JPanel speedSliderPanel = new JPanel(); - speedSliderPanel.setLayout(new GridLayout(2, 1)); - speedSliderPanel - .add(new JLabel( - I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.processing-speed"))); + JPanel speedSliderPanel = new JPanel(); + speedSliderPanel.setLayout(new GridLayout(2, 1)); + speedSliderPanel + .add(new JLabel( + I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageLayerControllPanel.processing-speed"))); - this.speedSlider.setLabelTable(this.sliderLabelDictionary); - this.speedSlider.setPaintLabels(true); + this.speedSlider.setLabelTable(this.sliderLabelDictionary); + this.speedSlider.setPaintLabels(true); - this.speedSlider.setMaximum(85); - this.speedSlider.setMinimum(15); - this.speedSlider.setMajorTickSpacing(10); - this.speedSlider.setMinorTickSpacing(5); - this.speedSlider.setPaintTicks(true); + this.speedSlider.setMaximum(85); + this.speedSlider.setMinimum(15); + this.speedSlider.setMajorTickSpacing(10); + this.speedSlider.setMinorTickSpacing(5); + this.speedSlider.setPaintTicks(true); - this.speedSlider.setMinimumSize(new Dimension(150, 20)); - this.speedSlider.setValue((int) ((1.0 - RasterImageLayer - .getFreeRamFactor()) * 100)); + this.speedSlider.setMinimumSize(new Dimension(150, 20)); + this.speedSlider.setValue((int) ((1.0 - RasterImageLayer + .getFreeRamFactor()) * 100)); - speedSliderPanel.add(this.speedSlider); + speedSliderPanel.add(this.speedSlider); - slidersPanel.add(speedSliderPanel); + slidersPanel.add(speedSliderPanel); - this.add(slidersPanel, BorderLayout.SOUTH); - if (rasterImageLayer.getNumBands() > 1) { - this.setSize(new Dimension(400, 500)); - this.setPreferredSize(new Dimension(400, 500)); - this.add(this.colorChooser, BorderLayout.CENTER); - this.add(transparencyOnOffPanel, BorderLayout.NORTH); - this.add(slidersPanel, BorderLayout.SOUTH); - } else { - this.add(slidersPanel, BorderLayout.NORTH); - } + this.add(slidersPanel, BorderLayout.SOUTH); + if (rasterImageLayer.getNumBands() > 1) { + this.setSize(new Dimension(400, 500)); + this.setPreferredSize(new Dimension(400, 500)); + this.add(this.colorChooser, BorderLayout.CENTER); + this.add(transparencyOnOffPanel, BorderLayout.NORTH); + this.add(slidersPanel, BorderLayout.SOUTH); + } else { + this.add(slidersPanel, BorderLayout.NORTH); + } - // this.setPreferredSize(new Dimension(300, - // this.colorChooser.getHeight() + 50)); + // this.setPreferredSize(new Dimension(300, + // this.colorChooser.getHeight() + 50)); - this.doLayout(); + this.doLayout(); - // setup checkbox (and color chooser) - this.useTransCB - .setSelected(this.rasterImageLayer.getTransparentColor() != null); - this.actionPerformed(null); - } + // setup checkbox (and color chooser) + this.useTransCB + .setSelected(this.rasterImageLayer.getTransparentColor() != null); + this.actionPerformed(null); + } - /** - * @inheritDoc - */ - public boolean areValuesOk() { + /** + * @inheritDoc + */ + public boolean areValuesOk() { - this.rasterImageLayer.setFiringAppearanceEvents(false); + this.rasterImageLayer.setFiringAppearanceEvents(false); - if (this.useTransCB.isSelected()) { - this.rasterImageLayer.setTransparentColor(this.colorChooser - .getColor()); - } else { - this.rasterImageLayer.setTransparentColor(null); - } - int newTransparencyValue = this.transparencySlider.getValue(); - this.rasterImageLayer - .setTransparencyLevelInPercent(newTransparencyValue); + if (this.useTransCB.isSelected()) { + this.rasterImageLayer.setTransparentColor(this.colorChooser + .getColor()); + } else { + this.rasterImageLayer.setTransparentColor(null); + } + int newTransparencyValue = this.transparencySlider.getValue(); + this.rasterImageLayer + .setTransparencyLevelInPercent(newTransparencyValue); - int newFreeRamValue = this.speedSlider.getValue(); - RasterImageLayer.setFreeRamFactor(1.0 - newFreeRamValue / 100d); + int newFreeRamValue = this.speedSlider.getValue(); + RasterImageLayer.setFreeRamFactor(1.0 - newFreeRamValue / 100d); - this.rasterImageLayer.setFiringAppearanceEvents(true); + this.rasterImageLayer.setFiringAppearanceEvents(true); - return true; - } + return true; + } - /** - * @inheritDoc - */ - public void actionPerformed(ActionEvent event) { - // the checkbox was toogled + /** + * @inheritDoc + */ + public void actionPerformed(ActionEvent event) { + // the checkbox was toogled - // diabling the color chooser has no effect! - this.colorChooser.setEnabled(this.useTransCB.isSelected()); - this.colorChooser.setVisible(this.useTransCB.isSelected()); - } + // diabling the color chooser has no effect! + this.colorChooser.setEnabled(this.useTransCB.isSelected()); + this.colorChooser.setVisible(this.useTransCB.isSelected()); + } - public String getTitle() { - return I18N.get("ui.renderer.style.ColorThemingPanel.transparency"); + public String getTitle() { + return I18N.get("ui.renderer.style.ColorThemingPanel.transparency"); - } + } - public void updateStyles() { - this.rasterImageLayer.setFiringAppearanceEvents(false); + public void updateStyles() { + this.rasterImageLayer.setFiringAppearanceEvents(false); - if (this.useTransCB.isSelected()) { - this.rasterImageLayer.setTransparentColor(this.colorChooser - .getColor()); - } else { - this.rasterImageLayer.setTransparentColor(null); - } - int newTransparencyValue = this.transparencySlider.getValue(); - this.rasterImageLayer - .setTransparencyLevelInPercent(newTransparencyValue); + if (this.useTransCB.isSelected()) { + this.rasterImageLayer.setTransparentColor(this.colorChooser + .getColor()); + } else { + this.rasterImageLayer.setTransparentColor(null); + } + int newTransparencyValue = this.transparencySlider.getValue(); + this.rasterImageLayer + .setTransparencyLevelInPercent(newTransparencyValue); - int newFreeRamValue = this.speedSlider.getValue(); - RasterImageLayer.setFreeRamFactor(1.0 - newFreeRamValue / 100d); + int newFreeRamValue = this.speedSlider.getValue(); + RasterImageLayer.setFreeRamFactor(1.0 - newFreeRamValue / 100d); - this.rasterImageLayer.setFiringAppearanceEvents(true); + this.rasterImageLayer.setFiringAppearanceEvents(true); - return; + return; - } + } - public String validateInput() { - // TODO Auto-generated method stub - return null; - } + public String validateInput() { + // TODO Auto-generated method stub + return null; + } - public void okPressed() { - return; - } + public void okPressed() { + return; + } } Modified: core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java 2016-03-22 22:18:51 UTC (rev 4858) +++ core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java 2016-03-23 17:52:32 UTC (rev 4859) @@ -2,9 +2,9 @@ import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.geom.NoninvertibleTransformException; -import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.Raster; @@ -13,33 +13,40 @@ import java.io.IOException; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Locale; import javax.media.jai.PlanarImage; import javax.swing.BorderFactory; +import javax.swing.Box; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JButton; -import javax.swing.JInternalFrame; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JSlider; import javax.swing.JTabbedPane; import javax.swing.border.Border; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; - import org.openjump.core.apitools.LayerTools; import org.openjump.core.rasterimage.RasterImageLayer; import org.openjump.core.rasterimage.TiffTags.TiffReadingException; import org.openjump.core.rasterimage.sextante.OpenJUMPSextanteRasterLayer; import org.openjump.core.rasterimage.sextante.rasterWrappers.GridWrapperNotInterpolated; +import org.openjump.core.ui.swing.DetachableInternalFrame; +import org.openjump.core.ui.util.ProjUtils; +import org.saig.core.gui.swing.sldeditor.util.FormUtils; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.util.FileUtil; import com.vividsolutions.jump.workbench.WorkbenchContext; import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; import com.vividsolutions.jump.workbench.plugin.PlugInContext; -import com.vividsolutions.jump.workbench.ui.HTMLFrame; import com.vividsolutions.jump.workbench.ui.HTMLPanel; import com.vividsolutions.jump.workbench.ui.images.IconLoader; @@ -56,648 +63,617 @@ * Info can be saved as HTML file * @version 0.4 - 2015_03_27. (Giuseppe Aruta) Added Raster Layer statistics tab * with several info about cell values + * @version 0.5 - 2016_03_23 (Giuseppe Aruta) Enhenced version. It uses basic + * GvSIG table format for data display. Added Transparency panel. + * Remove statistic panel as already implemented as in the Raster + * Statistics plugin. Added a minimal raster projection display: + * currently it only displays simple project definition (not EPSG). */ public class RasterImageLayerPropertiesPlugIn extends AbstractPlugIn { - protected static final String TXTENDING = ".txt"; - private String minVal; - private String maxVal; - private String noVal; - private String varVal; - private int datatype; - private String meanVal; - private String directory; - private String cellSizeX; - private String cellSizeY; - private String name_raster; - private String name; - private int X; - private int Y; - private String area; - private String width; - private String height; - private long size; - private String sizeMB; - private String type; - private String filetype; - private int colordepth; - private int numbands; // number bands - private double variance; // Variance of band0 values - private String stdvar; // Standard deviation - private String covar; // Covariance - private String sum; // Sum of cell values + // Components + private JSlider transparencySlider = new JSlider(); + @SuppressWarnings("rawtypes") + protected Dictionary sliderLabelDictionary = new Hashtable(); + private JPanel transparencySliderPanel = new JPanel(new GridBagLayout()); + private String layer_name; + private String file_path; + private String raster_bands; + private String raster_datatype; + private String raster_colordepth; + private String raster_dpi; + private int extent_columns; + private int extent_rows; + private String extent_cellnumber; + private String extent_area; + private String extent_width; + private String extent_height; + private String extent_cellSizeX; + private String extent_cellSizeY; + private String extent_minX; + private String extent_maxX; + private String extent_minY; + private String extent_maxY; + private long file_size; + private String file_sizeMB; + private String file_type; + private String raster_nodata; + private String proj_file_path; + private String proj_coordinate; - private final static String CANCEL = I18N.get("ui.OKCancelPanel.cancel"); - // /Language code deriving from previous RasterImageLayerPropertiesPlugIn - private final static String INFO = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn"); - private final static String MAX = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.max"); - private final static String MIN = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.min"); - private final static String MEAN = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.mean"); - private final static String NODATA = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.nodata"); + private final static String PLUGIN_NAME = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn"); + private final static String LAYER_PROPERTIES = I18N + .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Layer-Properties"); + private static final String INFO = I18N + .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Info"); + private final static String PROPORTIONAL_TRANSPARENCY_ADJUSTER = I18N + .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Proportional-Transparency-Adjustment"); + private final static String TRANSPARENCY = I18N + .get("ui.renderer.style.ColorThemingPanel.transparency"); + private final static String FILE = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.namefile"); + private final static String FILE_NAME = I18N + .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Source-Path"); + private final static String FILE_TYPE = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.type"); + private final static String FILE_DIMENSION = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension"); + private final static String RASTER = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.raster"); + private final static String RASTER_BANDS = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number"); + private final static String RASTER_DPI = "DPI"; + private final static String RASTER_DATATYPE = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.datatype"); + private final static String RASTER_COLORDEPTH = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.colordepth"); + private final static String RASTER_NODATA = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cell.nodata"); + private final static String EXTENT = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.extent"); + private final static String EXTENT_XMIN = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.xmin"); + private final static String EXTENT_YMIN = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.ymin"); + private final static String EXTENT_XMAX = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.xmax"); + private final static String EXTENT_YMAX = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.ymax"); + private final static String EXTENT_SIZE = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension_raster"); + private final static String EXTENT_CELL_SIZE = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension_cell"); + private final static String EXTENT_CELL_NUM = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cellnum"); + private final static String EXTENT_AREA = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.area"); + private final static String BAND = I18N + .get("org.openjump.core.ui.plugin.raster.CreatePolygonGridFromSelectedImageLayerPlugIn.band"); + private static final String LAYER = I18N + .get("com.vividsolutions.jump.workbench.ui.plugin.AddNewLayerPlugIn.name"); + private static final String NAME = I18N + .get("jump.workbench.ui.plugin.datastore.ConnectionDescriptorPanel.Name"); + private static final String SEXTANTE = I18N + .get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image"); + private static final String NOT_SAVED = I18N + .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Not-Saved"); + private static final String CANCEL = I18N.get("ui.OKCancelPanel.cancel"); + private static final String OK = I18N.get("ui.OKCancelPanel.ok"); + private static final String COORDINATE_SYSTEM = I18N + .get("datasource.FileDataSourceQueryChooser.coordinate-system-of-file"); + private static final String R_MAX = I18N + .get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.maximum"); + private static final String R_MIN = I18N + .get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.minimum"); + private static final String R_MEAN = I18N + .get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.mean"); + private static final String R_STD = I18N + .get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.standard-dev"); + private static final String GEO_METADATA = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.geographic_metadata"); + private static final String PROJECTION = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.projection"); - // New language codes + private Envelope extent; - private final static String RASTER = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.raster"); - private final static String NAMEFILE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.namefile"); - private final static String STATISTICS = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.statistics"); - private final static String ENV = I18N - .get("ui.plugin.LayerStatisticsPlugIn.envelope"); - private final static String DIRECTORY = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.directory"); - private final static String EXTENT = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.extent"); - private final static String BANDS = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.bands_number"); - private final static String BAND = I18N - .get("org.openjump.core.ui.plugin.raster.CreatePolygonGridFromSelectedImageLayerPlugIn.band"); - private final static String RASTER_SIZE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension_raster"); - private final static String CELL_SIZE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension_cell"); - private final static String DATATYPE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.datatype"); - private final static String LAYER_NAME = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_name"); - private final static String NAME = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.name"); - private final static String AREA = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.area"); - private final static String STD = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.std"); - private final static String CVAR = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cvar"); - private final static String TYPE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.type"); - private final static String DIMENSION = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.dimension"); - private final static String COLORDEPTH = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.colordepth"); - private final static String CELL_NUM = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.cellnum"); - private final static String VARIANCE = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.variance"); - private final static String EXPORT_TO_TXT = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.export"); - private final static String NODATACELLS = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.nodatacell"); - private final static String VALIDCELLS = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.validcells"); - private final static String SUM = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.sum"); - private final static String FILE_SAVED = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.file.saved"); - private final static String LAYER_IN_MEMORY = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.layer_memory"); - private final static String ERROR = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.error"); - private final static String XMIN = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.xmin"); - private final static String YMIN = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.ymin"); - private final static String XMAX = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.xmax"); - private final static String YMAX = I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.ymax"); - private final static String UNSPECIFIED = I18N - .get("coordsys.CoordinateSystem.unspecified"); + public static MultiEnableCheck createEnableCheck( + final WorkbenchContext workbenchContext) { + EnableCheckFactory checkFactory = new EnableCheckFactory( + workbenchContext); + MultiEnableCheck multiEnableCheck = new MultiEnableCheck(); + multiEnableCheck.add(checkFactory + .createExactlyNLayerablesMustBeSelectedCheck(1, + RasterImageLayer.class)); + return multiEnableCheck; + } - private Envelope extent; + public Icon getIcon() { + return IconLoader.icon("information_16x16.png"); + } - /* - * @Override public void initialize(PlugInContext context) throws Exception - * { WorkbenchContext workbenchContext = context.getWorkbenchContext(); new - * FeatureInstaller(workbenchContext); - * context.getFeatureInstaller().addMainMenuPlugin(this, new String[] { - * MenuNames.RASTER }, INFO, false, getIcon(), - * createEnableCheck(context.getWorkbenchContext())); } - */ + public String getName() { + return PLUGIN_NAME; + } - public static MultiEnableCheck createEnableCheck( - final WorkbenchContext workbenchContext) { - EnableCheckFactory checkFactory = new EnableCheckFactory( - workbenchContext); - MultiEnableCheck multiEnableCheck = new MultiEnableCheck(); - multiEnableCheck.add(checkFactory - .createExactlyNLayerablesMustBeSelectedCheck(1, - RasterImageLayer.class)); - return multiEnableCheck; - } + private final String bgColor0 = "\"#FEEDD6\""; // light salmon + private final String bgColor1 = "\"#EAEAEA\""; // light grey + private final String bgColor3 = "\"#FBFFE1\""; // light yellow + private final String bgColor4 = "\"#CCCCCC\""; // - public Icon getIcon() { - return IconLoader.icon("information_16x16.png"); - } + public String title(String textA, String textB) { + String cabecera = " <tr valign=\"top\">" + + " <td width=\"400\" height=\"18\" " + + "align=\"center\"><font face=\"Arial\" size=\"4\" align=\"right\"><b>" + + textA + "</b></font></td>" + + " <td width=\"1586\" height=\"18\" " + + "align=\"left\"><font face=\"Arial\" size=\"4\"><b>" + textB + + "</b></font></td>" + " </tr>"; + return cabecera; + } - public static final ImageIcon ICON_STAT = IconLoader - .icon("statistics16.png"); + public String header(String textA, String textB) { + String cabecera = " <tr valign=\"top\">" + + " <td width=\"400\" height=\"18\" bgcolor=" + + bgColor3 + + "align=\"center\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>" + + textA + "</b></font></td>" + + " <td width=\"1586\" height=\"18\" bgcolor=" + bgColor3 + + "align=\"center\"><font face=\"Arial\" size=\"3\"><b>" + + textB + "</b></font></td>" + " </tr>"; + return cabecera; + } - public String getName() { - return I18N - .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn"); - } + public String property(String textA, String textB, String color) { - /* - * Associate Byte, Megabytes, etc to Raster dimension - */ - private static final String[] Q = new String[] { "", "KB", "MB", "GB", - "TB", "PB", "EB" }; + String propiedad = " <tr valign=\"top\">" + + " <td width=\"400\" height=\"18\" bgcolor=" + + bgColor4 + + "align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\">" + + textA + "</font></td>" + + " <td width=\"1586\" height=\"18\" bgcolor=" + color + + "align=\"left\"><font face=\"Arial\" size=\"3\">" + textB + + "</font></td>" + " </tr>"; + return propiedad; + } - /* - * Return bytes as string - */ - public String getAsString(long bytes) { - for (int i = 6; i > 0; i--) { - double step = Math.pow(1024, i); - if (bytes > step) - return String.format("%3.1f %s", bytes / step, Q[i]); - } - return Long.toString(bytes); - } + public String infoText(RasterImageLayer rLayer) + throws NoninvertibleTransformException, TiffReadingException, + Exception { + String infotext = null; + setInfo(rLayer); + setInfoProjection(rLayer); + int numBands = rLayer.getNumBands(); + String info = ""; + info = info + title(INFO, ""); + info = info + header("", LAYER); + info = info + property(NAME, layer_name, bgColor0); + info += header("", FILE); + if (rLayer.getImageFileName().contains( + System.getProperty("java.io.tmpdir"))) { + info += property(FILE_NAME, NOT_SAVED, bgColor1); + } else { + info += property(FILE_TYPE, file_type, bgColor0); + info += property(FILE_NAME, file_path, bgColor1); + info += property(FILE_DIMENSION, file_sizeMB + " (" + file_size + + " bytes)", bgColor0); + info = info + header("", COORDINATE_SYSTEM); + info = info + property(PROJECTION, proj_coordinate, bgColor1); + info = info + property(FILE_NAME, proj_file_path, bgColor0); + } + info += header("", EXTENT); + info += property(EXTENT_XMIN, extent_minX, bgColor0); + info += property(EXTENT_XMAX, extent_maxX, bgColor1); + info += property(EXTENT_YMIN, extent_minY, bgColor0); + info += property(EXTENT_YMAX, extent_maxY, bgColor1); + info += property(EXTENT_SIZE, extent_width + " x " + extent_height + + " (" + EXTENT_AREA + ": " + extent_area + ")", bgColor0); + info += property(EXTENT_CELL_SIZE, extent_cellSizeX + ", " + + extent_cellSizeY, bgColor1); + info += property(EXTENT_CELL_NUM, extent_cellnumber, bgColor0); + info += header("", RASTER); + info += property(RASTER_DPI, raster_dpi, bgColor0); + info += property(RASTER_DATATYPE, raster_datatype, bgColor1); + info += property(RASTER_COLORDEPTH, raster_colordepth, bgColor0); + info += property(RASTER_BANDS, raster_bands, bgColor1); + if (rLayer.getNumBands() == 1) { + info += property(RASTER_NODATA, raster_nodata, bgColor0); + } + for (int b = 0; b < numBands; b++) { + int numerobanda = b + 1; + info += header("", BAND + " - " + numerobanda); + info += property(R_MIN, + String.valueOf(rLayer.getMetadata().getStats().getMin(b)), + bgColor0); + info += property(R_MAX, + String.valueOf(rLayer.getMetadata().getStats().getMax(b)), + bgColor1); + info += property(R_MEAN, + String.valueOf(rLayer.getMetadata().getStats().getMean(b)), + bgColor0); + info += property(R_STD, String.valueOf(rLayer.getMetadata() + .getStats().getStdDev(b)), bgColor1); + } + String table = "<table border='0.1'>"; + String table2 = "</table>"; + infotext = "<html>" + table + info + table2 + "</html>"; + return infotext; - /* - * Count the number of cells (of a Sextante monoband raster layer) with no - * data value - */ - public int nodata(PlugInContext context, - OpenJUMPSextanteRasterLayer rstLayer) { - int counter = 0; - GridWrapperNotInterpolated gwrapper = new GridWrapperNotInterpolated( - rstLayer, rstLayer.getLayerGridExtent()); - int nx = rstLayer.getLayerGridExtent().getNX(); - int ny = rstLayer.getLayerGridExtent().getNY(); - for (int y = 0; y < ny; y++) { - for (int x = 0; x < nx; x++) { - double value = gwrapper.getCellValueAsDouble(x, y, 0); - if (value == rstLayer.getNoDataValue()) - counter++; - } - } - return counter; - } + } - /* - * Check the Data type of the DataBuffer storing the pixel data. - */ - public String dataType(PlugInContext context, RasterImageLayer rLayer) - throws IOException { - Raster r = rLayer.getRasterData(null); - SampleModel sm = r.getSampleModel(); - datatype = sm.getDataType(); - switch (datatype) { - case DataBuffer.TYPE_BYTE: { - type = "byte"; - break; - } - case DataBuffer.TYPE_SHORT: { - type = "short"; - break; - } - case DataBuffer.TYPE_USHORT: { - type = "ushort"; - break; - } - case DataBuffer.TYPE_INT: { - type = "int"; - break; - } - case DataBuffer.TYPE_FLOAT: { - type = "float"; - break; - } - case DataBuffer.TYPE_DOUBLE: { - type = "double"; - break; - } - case DataBuffer.TYPE_UNDEFINED: { - type = "undefined"; - break; - } - } - return type; - } + @SuppressWarnings("unchecked") + private JPanel Transparency(final RasterImageLayer layer) { + transparencySliderPanel.setBorder(BorderFactory + .createTitledBorder(PROPORTIONAL_TRANSPARENCY_ADJUSTER)); + Box box = new Box(1); + for (int i = 0; i <= 100; i += 25) { + sliderLabelDictionary.put(new Integer(i), new JLabel(i + "%")); + } + transparencySlider.setMinimumSize(new Dimension(200, 20)); + transparencySlider.setPreferredSize(new Dimension(460, 50)); + transparencySlider.setPaintLabels(true); + transparencySlider.setPaintTicks(true); + transparencySlider.setLabelTable(sliderLabelDictionary); + transparencySlider.setMajorTickSpacing(10); + transparencySlider.setMinorTickSpacing(5); + transparencySlider.setMaximum(100); + transparencySlider.setMinimum(0); + transparencySlider.setValue((int) (layer.getTransparencyLevel() * 100)); + box.add(transparencySlider); + transparencySlider.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + JSlider source = (JSlider) e.getSource(); + if (!source.getValueIsAdjusting()) { + int newTransparencyValue = transparencySlider.getValue(); + layer.setTransparencyLevelInPercent(newTransparencyValue); + layer.fireAppearanceChanged(); + } + } + }); + transparencySliderPanel.add(box); + return transparencySliderPanel; + } - /* - * Return the extension of the file as String - */ - public static String getExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); - if (i > 0 && i < s.length() - 1) { - ext = s.substring(i + 1).toUpperCase(); - } - return ext; - } + public boolean execute(final PlugInContext context) throws Exception { + final RasterImageLayer rLayer = (RasterImageLayer) LayerTools + .getSelectedLayerable(context, RasterImageLayer.class); + final double transparency = rLayer.getTransparencyLevel(); + final DetachableInternalFrame frame = new DetachableInternalFrame( + LAYER_PROPERTIES + ": " + rLayer.getName()); + frame.setIconifiable(true); + frame.setFrameIcon(IconLoader.icon("information_16x16.png")); + HTMLPanel infoHTML = new HTMLPanel(); + infoHTML.getRecordPanel().removeAll(); + infoHTML.createNewDocument(); + infoHTML.append(infoText(rLayer)); + JTabbedPane tabbedPane = new JTabbedPane(); + Border mainComponentBorder = BorderFactory.createCompoundBorder( + BorderFactory.createEtchedBorder(), + BorderFactory.createEmptyBorder(5, 5, 5, 5)); + JPanel panelTransparency = new JPanel(); + FormUtils.addRowInGBL(panelTransparency, 1, 0, Transparency(rLayer)); + tabbedPane.setBorder(mainComponentBorder); + tabbedPane.addTab(INFO, getIcon(), infoHTML, ""); + tabbedPane.addTab(TRANSPARENCY, null, panelTransparency, ""); + // OK- Cancel panel + final JButton okButton = new JButton(OK) { + private static final long serialVersionUID = 1L; - /* - * Enumeration of File extension used in Sextante Raster Layer - */ - public enum TypeFile { - ASC, TXT, FLT, TIF, TIFF, JPG, JPEG, PNG, GIF, GRD, JP2, BMP - } + @Override + public Dimension getPreferredSize() { + return new Dimension(100, 25); + } + }; + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + frame.dispose(); + return; + } + }); + final JButton cancelButton = new JButton(CANCEL) { + private static final long serialVersionUID = 1L; - /* - * Return type of the Sextante Raster Layer as String - */ - public String filetype(File file) { - TypeFile extension1 = TypeFile.valueOf(getExtension(file)); - switch (extension1) { - case ASC: { - filetype = "ASC - ESRI ASCII grid"; - break; - } - case TXT: { - filetype = "TXT - ESRI ASCII grid"; - break; - } - case FLT: { - filetype = "FLT - ESRI Binary grid"; - break; - } - case TIF: { - filetype = "GEOTIF/TIFF Tagged Image File Format"; - break; - } - case TIFF: { - filetype = "GEOTIF/TIFF Tagged Image File Format"; - break; - } - case JPG: { - filetype = "JPEG/JPG - Joint Photographic Experts Group"; - break; - } - case JPEG: { - filetype = "JPEG/JPG - Joint Photographic Experts Group"; - break; - } - case PNG: { - filetype = "PNG - Portable Network Graphics"; - break; - } - case GIF: { - filetype = "GIF - Graphics Interchange Format"; - break; - } - case GRD: { - filetype = "GRD - Surfer ASCII Grid"; - break; - } - case JP2: { - filetype = "JPEG 2000 - Joint Photographic Experts Group"; - break; - } - case BMP: { - filetype = "BMP - Windows Bitmap"; - break; - } - } - return filetype; - } + @Override + public Dimension getPreferredSize() { + return new Dimension(100, 25); + } + }; + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + rLayer.setTransparencyLevel(transparency); + transparencySlider.setValue((int) (transparency) * 100); + frame.dispose(); + return; + } + }); + JPanel okCancelPane = new JPanel(); + okCancelPane.add(okButton); + okCancelPane.add(cancelButton); + frame.add(tabbedPane, BorderLayout.CENTER); + frame.add(okCancelPane, BorderLayout.SOUTH); + frame.setClosable(true); + frame.setResizable(true); + frame.setMaximizable(true); + frame.setSize(550, 400); + frame.setVisible(true); + frame.setIcon(true); + context.getWorkbenchFrame().addInternalFrame(frame, true, true); + return true; + } - public String InfoText(PlugInContext context, RasterImageLayer rLayer) - throws NoninvertibleTransformException, TiffReadingException, - Exception { - String infotext = null; - extent = rLayer.getWholeImageEnvelope(); - /* - * Check the source file of selected Raster Image Ex. - * C:/Document/Image/Test.jpg - */ - String checkfile = rLayer.getImageFileName(); - BufferedImage pi = null; - pi = rLayer.getImageForDisplay(); - pi.getWidth(); - int band = pi.getSampleModel().getNumBands();// Number of bands + /* + * Gets all data info + */ + private void setInfo(RasterImageLayer rLayer) throws IOException { + Locale locale = new Locale("en", "UK"); + String pattern = "###.####"; + DecimalFormat df = (DecimalFormat) NumberFormat + .getNumberInstance(locale); + df.applyPattern(pattern); + layer_name = rLayer.getName();// Get name of layer + file_path = rLayer.getImageFileName();// get file path + String fileSourcePath = rLayer.getImageFileName(); + String extension = FileUtil.getExtension(fileSourcePath); + if ((extension.equals("tif") || extension.equals("tiff") + || extension.equals("TIF") || extension.equals("TIFF")) + && ProjUtils.isGeoTIFF(fileSourcePath)) { + file_type = "GeoTIFF" + " - " + SEXTANTE;// Get GeoTIF + // description + } else { + file_type = fileExtension(rLayer) + " - " + SEXTANTE;// Get file + // description + } + file_size = getFileSizeBytes(rLayer); // Get file size in byte + file_sizeMB = getFileSizeMegaBytes(file_size); // Get file size in Mega + // Bytes + raster_bands = df.format(rLayer.getNumBands());// Get raster number of + // bands + raster_datatype = getDataType(rLayer);// Get raster data type + raster_colordepth = getColorDepth(rLayer);// Get raster color depth + raster_dpi = getDPI(rLayer);// Get raster DPI + extent = rLayer.getWholeImageEnvelope(); // Get Envelope + extent_cellSizeX = df.format(cellSizeX(rLayer));// Get X Cell size + extent_cellSizeY = df.format(cellSizeY(rLayer));// Get Y Cell size + extent_columns = getNumColumns(rLayer); // Get Number of columns + extent_rows = getNumRows(rLayer); // Get Number of rows + extent_cellnumber = String.valueOf(extent_columns * extent_rows); // Get + // cell + // number + extent_area = df.format(rLayer.getWholeImageEnvelope().getArea()); // Get + // Area + extent_width = df.format(rLayer.getWholeImageEnvelope().getWidth()); // Get + // Width + extent_height = df.format(rLayer.getWholeImageEnvelope().getHeight()); // Get + // Height + extent_minX = df.format(extent.getMinX()); + extent_maxX = df.format(extent.getMaxX()); + extent_minY = df.format(extent.getMinY()); + extent_maxY = df.format(extent.getMaxY()); + raster_nodata = String.valueOf(rLayer.getNoDataValue()); + int numBands = rLayer.getNumBands(); + raster_bands = String.valueOf(numBands); + for (int b = 0; b < numBands; b++) { + int numerobanda = b + 1; + String.valueOf(numerobanda); + String.valueOf(rLayer.getMetadata().getStats().getMax(b)); + String.valueOf(rLayer.getMetadata().getStats().getMin(b)); + String.valueOf(rLayer.getMetadata().getStats().getMean(b)); + String.valueOf(rLayer.getMetadata().getStats().getStdDev(b)); + } + } - /* - * Overwrite Locale to UK Decimal format ####.## - */ - Locale locale = new Locale("en", "UK"); - String pattern = "###.########"; - DecimalFormat df = (DecimalFormat) NumberFormat - .getNumberInstance(locale); - df.applyPattern(pattern); + /* + * Get Projection of selected raster. First it checks if selected raster is + * a GeoTIF and scan tiff tags for projection. If selected file is not a + * GeoTIF, it checks if <Filename>.AUX.XML exists and scans inside it. As + * last choice it scans into <filename>.PRJ file + */ + private void setInfoProjection(RasterImageLayer layer) throws IOException { + String fileSourcePath = layer.getImageFileName(); + String extension = FileUtil.getExtension(fileSourcePath); + if ((extension.equals("tif") || extension.equals("tiff") + || extension.equals("TIF") || extension.equals("TIFF"))) { + if (ProjUtils.isGeoTIFF(fileSourcePath)) { + proj_file_path = GEO_METADATA; + proj_coordinate = ProjUtils + .getGeoTiffProjection(fileSourcePath); + } else { + proj_file_path = ProjUtils + .getFileProjectionPath(fileSourcePath); + proj_coordinate = ProjUtils.getFileProjection(fileSourcePath); + } + } else if ((extension.equals("asc") || extension.equals("ASC") + || extension.equals("FLT") || extension.equals("flt"))) { + proj_file_path = ProjUtils.getFileProjectionPath(fileSourcePath); + proj_coordinate = ProjUtils.getFileProjection(fileSourcePath); + } else { + proj_file_path = ProjUtils.getFileProjectionPath(fileSourcePath); + proj_coordinate = ProjUtils.getFileProjection(fileSourcePath); + } + } - /* - * Create different Dialog if Layer has datasource or not 1. Raster - * Layer with no Datasource 2. Raster Layer monoband with datasource 3. - * Raster Layer multiple bands with datasource - */ + // ////////////////////////////////////////// - /* - * 1. Raster Layer with no datasource - */ - if (checkfile == null) { + private int datatype; + private String type; - name = rLayer.getName();// Name of Layer - extent = rLayer.getWholeImageEnvelope();// Extent of Layer - double cellSizeX = (extent.getMaxX() - extent.getMinX()) - / pi.getWidth();// Cell size - double cellSizeY = (extent.getMaxY() - extent.getMinY()) - / pi.getHeight();// Cell size - - infotext = LAYER_NAME + ": " + "\t" + name + "\n" + "\n" + NAMEFILE - + "\n" + "\t" + NAME + ": " + LAYER_IN_MEMORY + "\n" + "\t" - + TYPE + ": " + "..." + "\n" + "\t" + DIMENSION + ": " - + "..." + "\n" + "\t" + DIRECTORY + ": " + "..." + "\n" - + "\n" + EXTENT + "\n" + "\t" + XMIN + ": " - + df.format(extent.getMinX()) + "\n" + "\t" + YMIN + ": " - + df.format(extent.getMinY()) + "\n" + "\t" + XMAX + ": " - + df.format(extent.getMaxX()) + "\n" + "\t" + YMAX + ": " - + df.format(extent.getMaxY()) + "\n" + "\t" + AREA + ": " - + df.format(extent.getHeight() * extent.getWidth()) + " (" - + df.format(extent.getWidth()) + " X " - + df.format(extent.getHeight()) + ")" + "\n" + "\t" - + CELL_SIZE + ": " + df.format(cellSizeX) + ", " + df.format(cellSizeY) + "\n" + "\t" - + CELL_NUM + ": " + (pi.getWidth() * pi.getHeight()) - / (cellSizeX * cellSizeY) + "\n" + "\n" + RASTER + "\n" - + "\t" + DATATYPE + ": " + dataType(context, rLayer) + "\n" - + "\t" + COLORDEPTH + ": " + colordepth + " bpp" + "\n" - + "\t" + RASTER_SIZE + ": " - + df.format(rLayer.getOrigImageWidth()) + " X " - + df.format(rLayer.getOrigImageHeight()) + " pixel" + "\n" - + "\t" + BANDS + ": " + band + "\n"; - } else { - OpenJUMPSextanteRasterLayer rstLayer = new OpenJUMPSextanteRasterLayer(); - rstLayer.create(rLayer); - final File image = new File(rstLayer.getFilename()); - Raster r = rLayer.getRasterData(null); - SampleModel sm = r.getSampleModel(); - ColorModel cm = PlanarImage.createColorModel(sm); + private static final String[] Q = new String[] { "", "KB", "MB", "GB", + "TB", "PB", "EB" }; - /* - * List of elements displayed in the TeatArea - */ - minVal = df.format(rstLayer.getMinValue());// Min value of cells - maxVal = df.format(rstLayer.getMaxValue());// Max value of cells - numbands = rstLayer.getBandsCount();// Number of bands - variance = rstLayer.getVariance();// Variance - stdvar = df.format(Math.sqrt(variance));// Standard deviation - covar = df.format(variance / rstLayer.getMeanValue());// Covariance - meanVal = df.format(rstLayer.getMeanValue());// Mean value - noVal = df.format(rstLayer.getNoDataValue());// No data value - varVal = df.format(rstLayer.getVariance());// variance + /* + * Converts bytes to multiple (Kilo, Mega, Giga-bytes according to the + * dimension of the file + */ + public String getFileSizeMegaBytes(long bytes) { + for (int i = 6; i > 0; i--) { + double step = Math.pow(1024, i); + if (bytes > step) + return String.format("%3.1f %s", bytes / step, Q[i]); + } + return Long.toString(bytes); + } - directory = image.getParent(); // Directory of file - colordepth = cm.getPixelSize();// Color depth - cellSizeX = df.format(rstLayer.getLayerCellSize().x);// Cell size - cellSizeY = df.format(rstLayer.getLayerCellSize().y);// Cell size - name_raster = rstLayer.getName();// Name of layer - name = image.getName();// Name of file - X = rstLayer.getNX(); // Number of columns - Y = rstLayer.getNY(); // Number of rows - int cellnumber = X * Y; // Number of cells - area = df.format(rLayer.getWholeImageEnvelope().getArea()); // Area - width = df.format(rLayer.getWholeImageEnvelope().getWidth()); // Width - height = df.format(rLayer.getWholeImageEnvelope().getHeight()); // Height - size = image.length(); // Size in byte - sizeMB = getAsString(size); // Size in Mega Bytes - sum = df.format(rstLayer.getMeanValue() - * (X * Y - nodata(context, rstLayer)));// Sum - // of - // values + /* + * Gets dimension of file in bytes + */ + public long getFileSizeBytes(RasterImageLayer layer) { + File rfile = new File(layer.getImageFileName()); + return rfile.length(); + } - infotext = "<HTML><BODY>"; - infotext += "<DIV style=\"width: 500px; text-justification: justify;\">"; + /* + * Return the extension of the file as String + */ + public String fileExtension(RasterImageLayer layer) { + File f = new File(layer.getImageFileName()); + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + if (i > 0 && i < s.length() - 1) { + ext = s.substring(i + 1).toUpperCase(); + } + return ext; + } - infotext += "<table border='0.1'>"; - infotext += "<tr><td bgcolor=#CCCCCC><b>" + LAYER_NAME - + "</b> </td><td>" + name_raster + "</td></tr>"; - infotext += "</table>"; + /* + * Gets the number of bands + */ + public String numBands(RasterImageLayer layer) { + int bands = layer.getNumBands(); + return String.valueOf(bands); + } - // infotext += "<b>" + NAMEFILE + "</b>" + "<br>"; - infotext += "<table border='0.1'>"; - infotext += "<tr><td bgcolor=#CCCCCC><b>" + NAMEFILE + " " - + "</b></td><td><b>" + NAME + "</b></td><td>" + name - + "</td></tr>"; - // infotext += "<tr> <td></td> <td><b>" + NAME + "</b></td><td>" - // + name + "</td></tr>"; - infotext += "<tr> <td></td> <td<b>" + TYPE + "</b></td><td>" - + filetype(image) + "</td></tr>"; - infotext += "<tr> <td></td> <td><b> " + DIMENSION + "</b></td><td>" - + sizeMB + " (" + size + " bytes)" + "</td></tr>"; - infotext += "<tr> <td></td> <td><b>" + DIRECTORY + "</b></td><td>" - + directory + "</td></tr>"; - infotext += "</table>"; + /* + * Gets data type + */ + public String getDataType(RasterImageLayer rLayer) throws IOException { + Raster r = rLayer.getRasterData(null); + SampleModel sm = r.getSampleModel(); + datatype = sm.getDataType(); + switch (datatype) { + case DataBuffer.TYPE_BYTE: { + type = "byte"; + break; + } + case DataBuffer.TYPE_SHORT: { + type = "short"; + break; + } + case DataBuffer.TYPE_USHORT: { + type = "ushort"; + break; + } + case DataBuffer.TYPE_INT: { + type = "int"; + break; + } + case DataBuffer.TYPE_FLOAT: { + type = "float"; + break; + } + case DataBuffer.TYPE_DOUBLE: { + type = "double"; + break; + } + case DataBuffer.TYPE_UNDEFINED: { + type = "undefined"; + break; + } + } + return type; + } - // infotext += "<br>"; - // infotext += "<b>" + RASTER + "</b>" + "<br>"; - infotext += "<table border='0.1'>"; - infotext += "<tr><td bgcolor=#CCCCCC><b>" + RASTER - + "</b></td><td><b>" + BANDS + "</b></td><td>" + numbands - + "</td></tr>"; - infotext += "<tr><td></td> <td><b>" + DATATYPE + "</b></td><td>" - + dataType(context, rLayer) + "</td></tr>"; - infotext += "<tr><td></td> <td><b>" + COLORDEPTH + "</b></td><td>" - + colordepth + "</td></tr>"; - infotext += "<tr><td></td> <td><b>" + RASTER_SIZE + "</b></td><td>" - + X + " X " + Y + " pixel" + "</td></tr>"; - infotext += "</table>"; + /* + * Gets color depth + */ + public String getColorDepth(RasterImageLayer layer) throws IOException { + Raster r = null; + r = layer.getRasterData(null); + SampleModel sm = r.getSampleModel(); + ColorModel cm = PlanarImage.createColorModel(sm); + int colordepth = cm.getNumComponents(); + String color = String.valueOf(colordepth) + " bpp"; + return color; + } - // infotext += "<br>"; + /* + * Gets Dots per Inch (DPI) + */ + public String getDPI(RasterImageLayer layer) throws IOException { + Raster r = null; + r = layer.getRasterData(null); + SampleModel sm = r.getSampleModel(); + ColorModel cm = PlanarImage.createColorModel(sm); + String color = String.valueOf(cm.getPixelSize()); + return color; + } - infotext += "<table border='0.1'>"; - infotext += "<tr><td bgcolor=#CCCCCC><b>" + EXTENT - + "</b></td><td><b>" + XMIN + "</b></td><td>" - + df.format(extent.getMinX()) + "</td><td>"; - infotext += "<tr><td></td> <td><b>" + XMAX + "</b></td><td>" - + df.format(extent.getMaxX()) + "</td><td>"; - infotext += "<tr><td></td> <td><b>" + YMIN + "</b></td><td>" - + df.format(extent.getMinY()) + "</td><td>"; - infotext += "<tr><td></td> <td><b>" + YMAX + "</b></td><td>" - + df.format(extent.getMaxY()) + "</td><td>"; - infotext += "<tr><td></td> <td><b>" + AREA + "</b></td><td>" + area - + " (" + width + " X " + height + ")" + "</td></tr>";// Extension - infotext += "<tr><td></td> <td><b>" + CELL_SIZE + "</b></td><td>" - + cellSizeX + ", " + cellSizeY + "</td></tr>"; // Extension fo a cell - infotext += "<tr><td></td> <td><b>" + CELL_NUM + "</td><td>" - + cellnumber + "</td></tr>"; // Number of cells - infotext += "</table>"; + /* + * Gets cell size + */ + public double cellSizeX(RasterImageLayer layer) throws IOException { + Raster m_Raster = layer.getRasterData(null); + Envelope env = layer.getWholeImageEnvelope(); + double cellSize = env.getWidth() / (double) m_Raster.getWidth(); + return cellSize; + } - infotext += "</DIV></BODY></HTML>"; + public double cellSizeY(RasterImageLayer layer) throws IOException { + Raster m_Raster = layer.getRasterData(null); + Envelope env = layer.getWholeImageEnvelope(); + double cellSize = env.getHeight() / (double) m_Raster.getHeight(); + return cellSize; - } - return infotext; + } - } + /* + * Gets number of columns + */ + public int getNumColumns(RasterImageLayer layer) throws IOException { + Raster m_Raster = layer.getRasterData(null); + int x = m_Raster.getWidth(); + return x; + } - public String StatisticsText(PlugInContext context, RasterImageLayer rLayer) - throws NoninvertibleTransformException, TiffReadingException, - Exception { - /* - * Overwrite Locale to UK Decimal format ####.## - */ - Locale locale = new Locale("en", "UK"); - String pattern = "###.########"; - DecimalFormat df = (DecimalFormat) NumberFormat - .getNumberInstance(locale); - df.applyPattern(pattern); + /* + * Gets number of rows + */ + public int getNumRows(RasterImageLayer layer) throws IOException { + Raster m_Raster = layer.getRasterData(null); + int x = m_Raster.getHeight(); + return x; - String infotext = null; - OpenJUMPSextanteRasterLayer rstLayer = new OpenJUMPSextanteRasterLayer(); - rstLayer.create(rLayer); - Envelope layerEnv = rLayer.getWholeImageEnvelope(); - // Get the statistics - int numBands = rLayer.getNumBands(); + } - String bandstring = ": " + String.valueOf(numBands); - df.format(rstLayer.getMinValue()); - df.format(rstLayer.getMaxValue()); - df.format(rstLayer.getMeanValue()); - int X = rstLayer.getNX(); // Number of columns - int Y = rstLayer.getNY(); // Number of rows - df.format(rstLayer.getMeanValue() * (X * Y - nodata(context, rstLayer))); - // String nodata = df.format(rstLayer.getNoDataValue());// No data - String nodata; - nodata = df.format(rLayer.getNoDataValue());// No data - df.format(rstLayer.getVariance()); - double var = rstLayer.getVariance();// Variance as double - df.format(Math.sqrt(var)); - df.format(var / rstLayer.getMeanValue()); - int validcells = X * Y - nodata(context, rstLayer);// Number of - // valid cells + /* + * Counts the number of no data cells. This code is deactivated + */ + public int getNodataCellsNumber(RasterImageLayer rLayer) throws IOException { + OpenJUMPSextanteRasterLayer rstLayer = new OpenJUMPSextanteRasterLayer(); + rstLayer.create(rLayer); + int counter = 0; + GridWrapperNotInterpolated gwrapper = new GridWrapperNotInterpolated( + rstLayer, rstLayer.getLayerGridExtent()); + int nx = rstLayer.getLayerGridExtent().getNX(); + int ny = rstLayer.getLayerGridExtent().getNY(); + for (int y = 0; y < ny; y++) { + for (int x = 0; x < nx; x++) { + double value = gwrapper.getCellValueAsDouble(x, y, 0); + if (value == rstLayer.getNoDataValue()) + counter++; + } + } + return counter; + } - int nodatacells = nodata(context, rstLayer);// number of no data - // cells + /* + * Counts the number of valid cells. This code is deactivated + */ + public int getValidCellsNumber(RasterImageLayer rLayer) throws IOException { + int number = getNumColumns(rLayer) * getNumRows(rLayer) + - getNodataCellsNumber(rLayer); + return number; + } - infotext = "<HTML><BODY>"; - infotext += "<table border='0.1'>"; - infotext += "<tr><td><b>" + LAYER_NAME + "</b> </td><td>" - + rLayer.getName() + "</td></tr>"; - infotext += "</table><br>"; - - infotext += "<table border='0.1'>"; - infotext += "<tr><td><b>" + ENV + "</b> </td><td>" - + layerEnv.toString() + "</td></tr>"; - infotext += "<tr><td><b>" + BANDS + "</b> </td><td>" + bandstring - + "</td></tr>"; - infotext += "<tr><td><b>" + NODATA + "</b> </td><td>" + nodata - + "</td></tr>"; - infotext += "<tr><td><b>" + VALIDCELLS + "</b> </td><td>" - + Integer.toString(validcells) + "</td></tr>"; - infotext += "<tr><td><b>" + NODATACELLS + "</b> </td><td>" - + Integer.toString(nodatacells) + "</td></tr>"; - infotext += "</table><br>"; - - infotext += "<table border='1'>"; - infotext += "<tr><td bgcolor=#CCCCCC align='center'> " + BAND - + "</td><td bgcolor=#CCCCCC align='center'> " + MIN - + "</td><td bgcolor=#CCCCCC align='center'> " + MAX - + "</td><td bgcolor=#CCCCCC align='center'> " + MEAN - + "</td><td bgcolor=#CCCCCC align='center'> " + SUM - + "</td><td bgcolor=#CCCCCC align='center'> " + VARIANCE - + "</td><td bgcolor=#CCCCCC align='center'> " + STD - + "</td><td bgcolor=#CCCCCC align='center'> " + CVAR - - + "</td></tr>"; - for (int b = 0; b < numBands; b++) { - int numerobanda = b + 1; - infotext += "</td><td align='right'>" - + numerobanda - + "</td><td align='right'>" - + df.format(rstLayer.getMinValue(b))// min - + "</td><td align='right'>" - + df.format(rstLayer.getMaxValue(b))// max - + "</td><td align='right'>" - + df.format(rstLayer.getMeanValue(b))// mean - + "</td><td align='right'>" - + df.format(rstLayer.getMeanValue(b) - * (X * Y - nodata(context, rstLayer)))// sum - - + "</td><td align='right'>" - + df.format(rstLayer.getVariance(b))// variance - + "</td><td align='right'>" - + df.format(Math.sqrt(rstLayer.getVariance(b)))// std - + "</td><td align='right'>" - + df.format(rstLayer.getVariance(b) - / rstLayer.getMeanValue(b))// cvar - - + "</td></tr>"; - } - infotext += "</table>"; - infotext += "</DIV></BODY></HTML>"; - - return infotext; - } - - public boolean execute(PlugInContext context) throws Exception { - - RasterImageLayer rLayer = (RasterImageLayer) LayerTools - .getSelectedLayerable(context, RasterImageLayer.class); - - final WorkbenchContext wbcontext = context.getWorkbenchContext(); - - // HTMLFrame out = context.getOutputFrame(); - final JInternalFrame frame = new JInternalFrame(INFO); - - // First panel Info general - HTMLPanel info = new HTMLPanel(); - info.getRecordPanel().removeAll(); - info.createNewDocument(); - info.addHeader(1, INFO); - info.append(InfoText(context, rLayer)); - - // Second panel Statistics - HTMLPanel statistics = new HTMLPanel(); - statistics.getRecordPanel().removeAll(); - statistics.createNewDocument(); - statistics.addHeader(1, STATISTICS); - statistics.append(StatisticsText(context, rLayer)); - - // -- OK button Panel - JPanel okPanel = new JPanel(); - final JButton okButton = new JButton(CANCEL) { - @Override - public Dimension getPreferredSize() { - return new Dimension(100, 25); - } - }; - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - frame.dispose(); - return; - } - }); - okPanel.add(okButton); - // -- End of OK Buttom - - /* - * JTabbedPane tabbedPane = new JTabbedPane(); Border - * mainComponentBorder = BorderFactory.createCompoundBorder( - * BorderFactory.createEtchedBorder(), - * BorderFactory.createEmptyBorder(5, 5, 5, 5)); - * tabbedPane.setBorder(mainComponentBorder); tabbedPane.add(out, - * LAYER_STATISTICS); frame.add(tabbedPane, BorderLayout.CENTER); - */ - - JTabbedPane tabbedPane = new JTabbedPane(); - Border mainComponentBorder = BorderFactory.createCompoundBorder( - BorderFactory.createEtchedBorder(), - BorderFactory.createEmptyBorder(5, 5, 5, 5)); - tabbedPane.setBorder(mainComponentBorder); - // tabbedPane.add(info, INFO); - // tabbedPane.add(statistics,ICON_STAT, STATISTICS); - tabbedPane.addTab(INFO, getIcon(), info, ""); - tabbedPane.addTab(STATISTICS, ICON_STAT, statistics, ""); - frame.add(tabbedPane, BorderLayout.CENTER); - frame.add(okPanel, BorderLayout.SOUTH); - - frame.setClosable(true); - frame.setResizable(true); - frame.setMaximizable(true); - frame.setSize(800, 450); - frame.setVisible(true); - context.getWorkbenchFrame().addInternalFrame(frame); - - return true; - } - } Added: core/trunk/src/org/openjump/core/ui/util/ProjUtils.java =================================================================== --- core/trunk/src/org/openjump/core/ui/util/ProjUtils.java (rev 0) +++ core/trunk/src/org/openjump/core/ui/util/ProjUtils.java 2016-03-23 17:52:32 UTC (rev 4859) @@ -0,0 +1,339 @@ +package org.openjump.core.ui.util; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Scanner; + +import org.apache.commons.imaging.formats.tiff.TiffField; +import org.apache.commons.imaging.formats.tiff.TiffImageMetadata; +import org.apache.commons.imaging.formats.tiff.TiffImageParser; +import org.openjump.core.rasterimage.GeoTiffConstants; + +import com.sun.media.jai.codec.FileSeekableStream; +import com.sun.media.jai.codec.TIFFDirectory; +import com.sun.media.jai.codec.TIFFField; +import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.util.FileUtil; + +public class ProjUtils { + + private static final String PROJECTION_UNSPECIFIED = I18N + .get("org.openjump.core.ui.plugin.raster.RasterImageLayerPropertiesPlugIn.unknown_projection"); + + /* + * Giuseppe Aruta <23_3_2015> This class is used to recognize file + * projection. It first scans the file to find projection metadata + * (currently only GeoTIFF). If the Geotiff file has not projection tag or + * it is not a Geotiff file, it scans to find projection info - first to an + * <file>.aux.xml - than to <file>.proj file. This class only checks the + * presence of defined projection sub-codes located at the beginning of + * OGC.WKT or ESRI.WKT projection codes. Currently this code works only + * with: org.openjump.core.ui.plugin.raster.RasterImageLayerProperty.class + */ + + /** + * It gets projection metadata from a geotiff file + * + * @param fileSourcePath + * @return <String> projection code as string + * @throws IOException + */ + @SuppressWarnings("static-access") + public static String getGeoTiffProjection(String fileSourcePath) + throws IOException { + String prjname = ""; + File tiffFile = new File(fileSourcePath); + try { + TiffImageParser parser = new TiffImageParser(); + TiffImageMetadata metadata = (TiffImageMetadata) parser + .getMetadata(tiffFile); + if (metadata != null) { + List<TiffField> tiffFields = metadata.getAllFields(); + GeoTiffConstants constants = new GeoTiffConstants(); + for (TiffField tiffField : tiffFields) { + if (tiffField.getTag() == constants.GeoAsciiParamsTag) { + prjname = tiffField.getStringValue().replaceAll( + "[\\t\\n\\r\\_\\|]", " "); + break; + } + } + } else { + prjname = getFileProjection(fileSourcePath); + } + } catch (Exception ex) { + prjname = getFileProjection(fileSourcePath); + } + return prjname; + } + + /** + * It gets projection code as string from an auxiliary file (AUX.XML or PRJ + * file) + * + * @param fileSourcePath + * @return <String> projection code as string + * @throws IOException + */ + public static String getFileProjection(String fileSourcePath) + throws IOException { + String projectSourceFilePrj = ""; + String projectSourceFileAux = ""; + String textProj = ""; + String prjname = ""; + Scanner scanner; + int pos = fileSourcePath.lastIndexOf('.'); + projectSourceFilePrj = fileSourcePath.substring(0, pos) + ".prj"; + projectSourceFileAux = fileSourcePath + ".aux.xml"; + if ((new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + int start = textProj.indexOf('['); + int end = textProj.indexOf(',', start); + prjname = textProj.substring(start + 2, end - 1).replaceAll( + "[\\t\\n\\r\\_]", " "); + } else { + scanner = new Scanner(new File(projectSourceFilePrj)); + textProj = scanner.nextLine(); + scanner.close(); + int start = textProj.indexOf('['); + int end = textProj.indexOf(',', start); + prjname = textProj.substring(start + 2, end - 1).replaceAll( + "[\\t\\n\\r\\_]", " "); + } + } else if ((new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + int start = textProj.indexOf('['); + int end = textProj.indexOf(',', start); + prjname = textProj.substring(start + 2, end - 1).replaceAll( + "[\\t\\n\\r\\_]", " "); + } else { + prjname = PROJECTION_UNSPECIFIED; + } + } else if (!(new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFilePrj)); + textProj = scanner.nextLine(); + scanner.close(); + int start = textProj.indexOf('['); + int end = textProj.indexOf(',', start); + prjname = textProj.substring(start + 2, end - 1).replaceAll( + "[\\t\\n\\r\\_]", " "); + } else if (!(new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + prjname = PROJECTION_UNSPECIFIED; + } + return prjname; + } + + /** + * It returns the path name of the auxiliary file where a projection code is + * located + * + * @param fileSourcePath + * @return <String> path name of projection auxiliary file + * @throws IOException + */ + public static String getFileProjectionPath(String fileSourcePath) + throws IOException { + String projectSourceFilePrj = ""; + String projectSourceFileAux = ""; + String textProj = ""; + String filename = ""; + Scanner scanner; + int pos = fileSourcePath.lastIndexOf('.'); + projectSourceFilePrj = fileSourcePath.substring(0, pos) + ".prj"; + projectSourceFileAux = fileSourcePath + ".aux.xml"; + if ((new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + filename = projectSourceFileAux; + } else { + filename = projectSourceFilePrj; + } + } else if ((new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + filename = projectSourceFileAux; + } else { + filename = ""; + } + } else if (!(new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + filename = projectSourceFilePrj; + } else if (!(new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + filename = ""; + } + return filename; + } + + /** + * Check if selected file is a GeoTIFF. This java code comes from Deegree + * project + * + * @param fileSourcePath + * @return + * @throws IOException + */ + + public static boolean isGeoTIFF(String fileSourcePath) throws IOException { + FileSeekableStream fileSeekableStream = new FileSeekableStream( + fileSourcePath); + TIFFDirectory tifDir = new TIFFDirectory(fileSeekableStream, 0); + // definition of a geotiff + if (tifDir.getField(GeoTiffConstants.ModelPixelScaleTag) == null + && tifDir.getField(GeoTiffConstants.ModelTransformationTag) == null + && tifDir.getField(GeoTiffConstants.ModelTiepointTag) == null + && tifDir.getField(GeoTiffConstants.GeoKeyDirectoryTag) == null + && tifDir.getField(GeoTiffConstants.GeoDoubleParamsTag) == null + && tifDir.getField(GeoTiffConstants.GeoAsciiParamsTag) == null) { + return false; + } else { + // is a geotiff and possibly might need to be treated as raw data + TIFFField bitsPerSample = tifDir.getField(258); + if (bitsPerSample != null) { + int samples = bitsPerSample.getAsInt(0); + if (samples == 16) + new Integer(16); + } + // check the EPSG number + TIFFField ff = tifDir.getField(GeoTiffConstants.GeoKeyDirectoryTag); + if (ff == null) { + return false; + } + char[] ch = ff.getAsChars(); + // resulting HashMap, containing the key and the array of values + HashMap<Integer, int[]> geoKeyDirectoryTag = new HashMap<Integer, int[]>( + ff.getCount() / 4); + // array of values. size is 4-1. + int keydirversion, keyrevision, minorrevision, numberofkeys = -99; + for (int i = 0; i < ch.length; i = i + 4) { + int[] keys = new int[3]; + keydirversion = ch[i]; + keyrevision = ch[i + 1]; + minorrevision = ch[i + 2]; + numberofkeys = ch[i + 3]; + keys[0] = keyrevision; + keys[1] = minorrevision; + keys[2] = numberofkeys; + geoKeyDirectoryTag.put(new Integer(keydirversion), keys); + } + int[] content = new int[3]; + if (geoKeyDirectoryTag.containsKey(new Integer( + GeoTiffConstants.ModelTiepointTag))) { + content = (int[]) geoKeyDirectoryTag.get(new Integer( + GeoTiffConstants.ModelTiepointTag)); + // TIFFTagLocation + if (content[0] == 0) { + // return Value_Offset key = content[2]; + } else { + // TODO other TIFFTagLocation that GeoKeyDirectoryTag + } + } else { + System.out + .println("Can't check EPSG codes, make sure it is ok!"); + } + return true; + } + } + + /** + * Check if selected auxiliary (AUX.XML or PRJ) file has projection code + * + * @param fileSourcePath + * @return + * @throws IOException + */ + public static boolean hasProjectionFile(String fileSourcePath) + throws IOException { + String projectSourceFilePrj = ""; + String projectSourceFileAux = ""; + String textProj = ""; + Scanner scanner; + int pos = fileSourcePath.lastIndexOf('.'); + projectSourceFilePrj = fileSourcePath.substring(0, pos) + ".prj"; + projectSourceFileAux = fileSourcePath + ".aux.xml"; + if ((new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + return true; + + } else { + + scanner = new Scanner(new File(projectSourceFilePrj)); + textProj = scanner.nextLine(); + scanner.close(); + if (textProj.contains("PROJCS") || textProj.contains("GEOGCS")) + return true; + } + } else if ((new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFileAux)); + textProj = scanner.useDelimiter("\\A").next(); + scanner.close(); + if (textProj.contains("<WKT>") || textProj.contains("<SRS>")) { + return true; + + } else { + return false; + } + } else if (!(new File(projectSourceFileAux).exists()) + & (new File(projectSourceFilePrj).exists())) { + scanner = new Scanner(new File(projectSourceFilePrj)); + textProj = scanner.nextLine(); + scanner.close(); + if (textProj.contains("PROJCS") || textProj.contains("GEOGCS")) { + return true; + } else { + return false; + } + + } else if (!(new File(projectSourceFileAux).exists()) + & !(new File(projectSourceFilePrj).exists())) { + return false; + } + return false; + } + + /** + * Check if selected file has a projection code somewhere (as a GeoTIFF tag + * or included into an AUX.XML or PRJ auziliary files) + * + * @param fileSourcePath + * @return + * @throws IOException + */ + public static boolean hasProjection(String fileSourcePath) + throws IOException { + String extension = FileUtil.getExtension(fileSourcePath); + if ((extension.equals("tif") || extension.equals("tiff") + || extension.equals("TIF") || extension.equals("TIFF"))) { + if (isGeoTIFF(fileSourcePath)) { + return true; + } else { + if (hasProjectionFile(fileSourcePath)) + return true; + } + } else if (hasProjectionFile(fileSourcePath)) + return true; + return false; + } +} Property changes on: core/trunk/src/org/openjump/core/ui/util/ProjUtils.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140 _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel