|
From: <jum...@li...> - 2015-04-10 09:24:03
|
Revision: 4393
http://sourceforge.net/p/jump-pilot/code/4393
Author: ma15569
Date: 2015-04-10 09:24:00 +0000 (Fri, 10 Apr 2015)
Log Message:
-----------
Modified Sextante Raster wizard in order to save image proportion for file with no world parameters.
Modified Paths:
--------------
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_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/rasterimage/AddRasterImageLayerWizard.java
core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/RasterImageWizardPanel.java
Modified: core/trunk/src/language/jump.properties
===================================================================
--- core/trunk/src/language/jump.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -495,6 +495,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante Raster Image
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = can not determine image dimensions
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = no worldfile found
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Select Raster Image
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = supported raster image formats
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Charset
Modified: core/trunk/src/language/jump_cz.properties
===================================================================
--- core/trunk/src/language/jump_cz.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_cz.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -480,6 +480,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante Raster Image
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = nemohu zjistit rozm\u011Bry obr\u00E1zku
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = nenalezen worldfile
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Vybrat rastrov\u00FD obr\u00E1zek
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = podporovan\u00E9 rastrov\u00E9 form\u00E1ty
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Znakov\u00E1 sada
Modified: core/trunk/src/language/jump_de.properties
===================================================================
--- core/trunk/src/language/jump_de.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_de.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -480,6 +480,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante Raster
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = Rasterdimensionen konnten nicht bestimmt werden
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = Kein worldfile gefunden
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Rasterbild ausw\u00e4hlen
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = unterst\u00fctzte Rasterformate
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Zeichensatz
Modified: core/trunk/src/language/jump_es.properties
===================================================================
--- core/trunk/src/language/jump_es.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_es.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -476,6 +476,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions=No puedo determinar los tama\u00F1o de la imagen
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found=Ningun worldfile encontrado
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image=Imagen Raster (Sextante)
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=Worldfile creado por el fichero:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image=Seleccionar Imagen Raster
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats=Imagenes Raster
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset=Codificaci\u00F3n de caracteres
Modified: core/trunk/src/language/jump_fi.properties
===================================================================
--- core/trunk/src/language/jump_fi.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_fi.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -495,6 +495,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions=Kuvan ulottuvuuksia ei voida p\u00E4\u00E4tell\u00E4
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found=Ei l\u00F6ytynyt worldfile\:\u00E4
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image=Sextante-rasterikuva
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image=Valitse rasterikuva
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats=Tuetut rasterikuvien tiedostomuodot
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset=Merkist\u00F6\:
Modified: core/trunk/src/language/jump_fr.properties
===================================================================
--- core/trunk/src/language/jump_fr.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_fr.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -483,6 +483,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Image raster (Sextante)
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = Les dimensions de l'image ne peuvent \u00eatre d\u00e9termin\u00e9es
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = Fichier worldfile non trouv\u00e9
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = S\u00e9lectionner l'image raster
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = Formats d'images reconnus
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Jeu de caract\u00e8res
Modified: core/trunk/src/language/jump_hu.properties
===================================================================
--- core/trunk/src/language/jump_hu.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_hu.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -481,6 +481,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante raszter k\u00E9p
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = a k\u00E9p m\u00E9reteit nem tudom meg\u00E1llap\u00EDtani
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = nem tal\u00E1lom a vil\u00E1gf\u00E1jlt
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = V\u00E1lassz ki egy raszter k\u00E9pet
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = t\u00E1mogatott raszter form\u00E1tumok
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Karakterk\u00E9szlet
Modified: core/trunk/src/language/jump_it.properties
===================================================================
--- core/trunk/src/language/jump_it.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_it.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -475,6 +475,7 @@
model.StandardCategoryNames.working=Progetto
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions=Impossibile determinare le dimensioni della immagine
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found=Nessun worldfile trovato
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=Worldfile creato per il file:''{0}''
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image=Immagine Raster (Sextante)
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image=Seleziona Immagine Raster
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats=Immagini Raster
Modified: core/trunk/src/language/jump_ml.properties
===================================================================
--- core/trunk/src/language/jump_ml.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_ml.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -649,6 +649,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante \u0d30\u0d3e\u0d38\u0d4d\u0d1f\u0d30\u0d4d\u200d
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = \u0d1a\u0d3f\u0d24\u0d4d\u0d30\u0d24\u0d4d\u0d24\u0d3f\u0d28\u0d4d\u0d31\u0d46 \u0d05\u0d33\u0d35\u0d4d \u0d24\u0d3f\u0d30\u0d3f\u0d1a\u0d4d\u0d1a\u0d31\u0d3f\u0d2f\u0d3e\u0d28\u0d4d\u200d \u0d38\u0d3e\u0d27\u0d3f\u0d15\u0d4d\u0d15\u0d41\u0d28\u0d4d\u0d28\u0d3f\u0d32\u0d4d\u0d32
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = \u0d35\u0d47\u0d33\u0d4d\u200d\u0d21\u0d4d \u0d2b\u0d2f\u0d32\u0d4d\u200d \u0d15\u0d3e\u0d23\u0d4d\u0d2e\u0d3e\u0d28\u0d3f\u0d32\u0d4d\u0d32
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = \u0d30\u0d3e\u0d38\u0d4d\u0d1f\u0d30\u0d4d\u200d \u0d24\u0d3f\u0d30\u0d1e\u0d4d\u0d1e\u0d46\u0d1f\u0d41\u0d15\u0d4d\u0d15\u0d41\u0d15
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = \u0d2a\u0d3f\u0d28\u0d4d\u0d24\u0d41\u0d23\u0d2f\u0d41\u0d33\u0d4d\u0d33 \u0d30\u0d3e\u0d38\u0d4d\u0d1f\u0d30\u0d4d\u200d \u0d30\u0d42\u0d2a\u0d15\u0d32\u0d4d\u0d2a\u0d28\u0d15\u0d33\u0d4d\u200d
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Jeu de caract\u00e8res
Modified: core/trunk/src/language/jump_pt.properties
===================================================================
--- core/trunk/src/language/jump_pt.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_pt.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -480,6 +480,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Imagem rastar do Sextante
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = N\u00e3o foi poss\u00edvel determinar as dimens\u00f5es da imagem
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = Nenhum arquivo world encontrado
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Selecionar imagem Raster
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = Formato de imagens suportados
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = T\:Charset
Modified: core/trunk/src/language/jump_pt_BR.properties
===================================================================
--- core/trunk/src/language/jump_pt_BR.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_pt_BR.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -480,6 +480,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Imagem rastar do Sextante
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = N\u00e3o foi poss\u00edvel determinar as dimens\u00f5es da imagem
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = Nenhum arquivo world encontrado
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Selecionar imagem Raster
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = Formato de imagens suportados
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = T\:Charset
Modified: core/trunk/src/language/jump_ta_IN.properties
===================================================================
--- core/trunk/src/language/jump_ta_IN.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_ta_IN.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -478,6 +478,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante Raster Image
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = \u0BAA\u0B9F\u0BA4\u0BCD\u0BA4\u0BC8 \u0BAA\u0BB0\u0BBF\u0BAE\u0BBE\u0BA3\u0B99\u0BCD\u0B95\u0BB3\u0BC8 \u0BA8\u0BBF\u0BB0\u0BCD\u0BA3\u0BAF\u0BBF\u0B95\u0BCD\u0B95 \u0BAE\u0BC1\u0B9F\u0BBF\u0BAF\u0BBE\u0BA4\u0BC1
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = no worldfile found
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = Select Raster Image
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = supported raster image formats
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = Charset
Modified: core/trunk/src/language/jump_te.properties
===================================================================
--- core/trunk/src/language/jump_te.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_te.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -480,6 +480,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = \#T\:Sextante Raster Image
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = \#T\:can not determine image dimensions
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = \#T\:no worldfile found
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = \#T\:Select Raster Image
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = \#T\:supported raster image formats
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = \#T\:Charset
Modified: core/trunk/src/language/jump_zh_CN.properties
===================================================================
--- core/trunk/src/language/jump_zh_CN.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_zh_CN.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -478,6 +478,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante\u5149\u6805\u56fe\u50cf
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = \u65e0\u6cd5\u786e\u5b9a\u56fe\u7247\u5c3a\u5bf8
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = \u6ca1\u6709\u627e\u5230worldfile
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = \u9009\u62e9\u5149\u6805\u56fe\u50cf
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = \u652f\u6301\u7684\u5149\u6805\u56fe\u50cf\u683c\u5f0f
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = \u5b57\u7b26\u96c6
Modified: core/trunk/src/language/jump_zh_HK.properties
===================================================================
--- core/trunk/src/language/jump_zh_HK.properties 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/language/jump_zh_HK.properties 2015-04-10 09:24:00 UTC (rev 4393)
@@ -478,6 +478,7 @@
org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image = Sextante\u5149\u67F5\u5716\u50CF
org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions = \u7121\u6CD5\u78BA\u5B9A\u5716\u7247\u5C3A\u5BF8
org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found = \u6C92\u6709\u627E\u5230worldfile
+org.openjump.core.rasterimage.AddRasterImageLayerWizard.message=\#T\:Worldfile created for file:''{0}''
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.Select-Raster-Image = \u9078\u64C7\u5149\u67F5\u5716\u50CF
org.openjump.core.rasterimage.SelectRasterImageFilesPanel.supported-raster-image-formats = \u652F\u6301\u7684\u5149\u67F5\u5716\u50CF\u683C\u5F0F
org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset = \u5B57\u7B26\u96C6
Modified: core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/org/openjump/core/rasterimage/AddRasterImageLayerWizard.java 2015-04-10 09:24:00 UTC (rev 4393)
@@ -3,9 +3,12 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.NoninvertibleTransformException;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
+import javax.imageio.ImageIO;
+
import org.openjump.core.ui.plugin.file.OpenRecentPlugIn;
import org.openjump.core.ui.plugin.file.open.ChooseProjectPanel;
import org.openjump.core.ui.plugin.layer.pirolraster.LoadSextanteRasterImagePlugIn;
@@ -33,339 +36,449 @@
public class AddRasterImageLayerWizard extends AbstractWizardGroup {
- public static final String KEY = AddRasterImageLayerWizard.class.getName();
+ public static final String KEY = AddRasterImageLayerWizard.class.getName();
- private WorkbenchContext workbenchContext;
- private ChooseProjectPanel chooseProjectPanel;
- private SelectRasterImageFilesPanel selectFilesPanel;
-
- private File[] files;
-
- //--- pirol image variables ----
- protected PropertiesHandler properties = null;
- protected WorldFileHandler worldFileHandler = null;
- protected static String propertiesFile = "RasterImage.properties";
- protected String KEY_ALLWAYSACCEPT_TWF_EXT = "allwaysCheckForTWFExtension";
- protected String KEY_ZOOM_TO_INSERTED_IMAGE = "zoomToImage";
- protected boolean allwaysLookForTFWExtension = true;
- protected boolean zoomToInsertedImage = false;
- private String imageFileName = "";
- private String cachedLayer = "default-layer-name";
- //------
-
- public AddRasterImageLayerWizard(WorkbenchContext workbenchContext) {
- super(
- I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image"),
- IconLoader.icon("mapSv2_13.png"), SelectRasterImageFilesPanel.KEY);
- this.workbenchContext = workbenchContext;
- RasterImageLayer.setWorkbenchContext(workbenchContext);
- }
+ private WorkbenchContext workbenchContext;
+ private ChooseProjectPanel chooseProjectPanel;
+ private SelectRasterImageFilesPanel selectFilesPanel;
+ private File[] files;
- public AddRasterImageLayerWizard(final WorkbenchContext workbenchContext,
- final File[] files) {
- this.workbenchContext = workbenchContext;
- this.files = files;
- //initPanels(workbenchContext);
- }
+ // --- pirol image variables ----
+ protected PropertiesHandler properties = null;
+ protected WorldFileHandler worldFileHandler = null;
+ protected static String propertiesFile = "RasterImage.properties";
+ protected String KEY_ALLWAYSACCEPT_TWF_EXT = "allwaysCheckForTWFExtension";
+ protected String KEY_ZOOM_TO_INSERTED_IMAGE = "zoomToImage";
+ protected boolean allwaysLookForTFWExtension = true;
+ protected boolean zoomToInsertedImage = false;
+ private String imageFileName = "";
+ private String cachedLayer = "default-layer-name";
-
- public void initialize(WorkbenchContext workbenchContext, WizardDialog dialog) {
- initPanels(workbenchContext);
- selectFilesPanel.setDialog(dialog);
+ // ------
- }
-
- private void initPanels(final WorkbenchContext workbenchContext) {
- // [mmichaud 2012-05-11] bug #3521266 : create selectFilesPanel only once
- if (selectFilesPanel == null) {
- selectFilesPanel = new SelectRasterImageFilesPanel(workbenchContext);
- addPanel(selectFilesPanel);
- }
- }
-
- /**
- * Load the files selected in the wizard.
- *
- * @param monitor The task monitor.
- */
- public void run(WizardDialog dialog, TaskMonitor monitor) {
- this.properties = new PropertiesHandler(AddRasterImageLayerWizard.propertiesFile);
- if (files == null) {
- File[] selectedFiles = selectFilesPanel.getSelectedFiles();
- open(selectedFiles, monitor);
- } else {
- open(files, monitor);
- }
- }
-
- private void open(File[] files, TaskMonitor monitor) {
- for (File file : files) {
- open(file, monitor);
- }
- }
+ public AddRasterImageLayerWizard(WorkbenchContext workbenchContext) {
+ super(
+ I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image"),
+ IconLoader.icon("mapSv2_13.png"),
+ SelectRasterImageFilesPanel.KEY);
+ this.workbenchContext = workbenchContext;
+ RasterImageLayer.setWorkbenchContext(workbenchContext);
+ }
- public void open(File file, TaskMonitor monitor) {
- try {
- //workbenchContext.getWorkbench().getFrame().warnUser("would load: " + file.getName());
+ public AddRasterImageLayerWizard(final WorkbenchContext workbenchContext,
+ final File[] files) {
+ this.workbenchContext = workbenchContext;
+ this.files = files;
+ // initPanels(workbenchContext);
+ }
- try {
- this.properties.setProperty(LoadSextanteRasterImagePlugIn.KEY_PATH, file.getPath());
-
- this.properties.store(" " + this.KEY_ZOOM_TO_INSERTED_IMAGE + I18N.get("RasterImagePlugIn.28") + this.KEY_ALLWAYSACCEPT_TWF_EXT + I18N.get("RasterImagePlugIn.29") + LoadSextanteRasterImagePlugIn.KEY_PATH + I18N.get("RasterImagePlugIn.30"));
-
- String selectedFilename = file.getPath();
- this.imageFileName = selectedFilename;
- this.cachedLayer = selectedFilename.substring(selectedFilename
- .lastIndexOf(File.separator) + 1, selectedFilename
- .lastIndexOf("."));
-
- boolean imageAdded = false;
-
- Point imageDimensions = RasterImageIO.getImageDimensions(selectedFilename);
- Envelope env = this.getGeoReferencing(selectedFilename, this.allwaysLookForTFWExtension, imageDimensions, this.workbenchContext);
-
-
- if (env != null){
- imageAdded = this.addImage(workbenchContext, env, imageDimensions);
- }
-
- OpenRecentPlugIn.get(workbenchContext).addRecentFile(file);
+ public void initialize(WorkbenchContext workbenchContext,
+ WizardDialog dialog) {
+ initPanels(workbenchContext);
+ selectFilesPanel.setDialog(dialog);
- } finally {
- //reader.close();
- }
- } catch (Exception e) {
- monitor.report(e);
- }
- }
-
- private boolean addImage(WorkbenchContext context, Envelope envelope, Point imageDimensions) {
+ }
- String newLayerName = context.getLayerManager().uniqueLayerName(cachedLayer);
+ private void initPanels(final WorkbenchContext workbenchContext) {
+ // [mmichaud 2012-05-11] bug #3521266 : create selectFilesPanel only
+ // once
+ if (selectFilesPanel == null) {
+ selectFilesPanel = new SelectRasterImageFilesPanel(workbenchContext);
+ addPanel(selectFilesPanel);
+ }
+ }
- String catName = StandardCategoryNames.WORKING;
+ /**
+ * Load the files selected in the wizard.
+ *
+ * @param monitor
+ * The task monitor.
+ */
+ public void run(WizardDialog dialog, TaskMonitor monitor) {
+ this.properties = new PropertiesHandler(
+ AddRasterImageLayerWizard.propertiesFile);
+ if (files == null) {
+ File[] selectedFiles = selectFilesPanel.getSelectedFiles();
+ open(selectedFiles, monitor);
+ } else {
+ open(files, monitor);
+ }
+ }
- try {
- catName = ((Category) context.createPlugInContext()
- .getLayerNamePanel().getSelectedCategories().toArray()[0])
- .getName();
- } catch (RuntimeException e1) {
- //logger.printDebug(e1.getMessage());
- }
-
+ private void open(File[] files, TaskMonitor monitor) {
+ for (File file : files) {
+ open(file, monitor);
+ }
+ }
- int layersAsideImage = context.getLayerManager().getLayerables(Layerable.class).size();
-
- RasterImageLayer rLayer = new RasterImageLayer(newLayerName, context.getLayerManager(), imageFileName, null, envelope);
-
- // #################################
-
- MetaInformationHandler mih = new MetaInformationHandler(rLayer);
- // [sstein 28.Feb.2009] -- not sure if these keys should be translated
- mih.addMetaInformation("file-name", this.imageFileName);
- mih.addMetaInformation("resolution", imageDimensions.x + " (px) x " + imageDimensions.y + " (px)");
- mih.addMetaInformation("real-world-width", new Double(envelope.getWidth()));
- mih.addMetaInformation("real-world-height", new Double(envelope.getHeight()));
-
- // ###################################
+ public void open(File file, TaskMonitor monitor) {
+ try {
+ // workbenchContext.getWorkbench().getFrame().warnUser("would load: "
+ // + file.getName());
-
- context.getLayerManager().addLayerable( catName, rLayer );
+ try {
+ this.properties.setProperty(
+ LoadSextanteRasterImagePlugIn.KEY_PATH, file.getPath());
+ this.properties.store(" " + this.KEY_ZOOM_TO_INSERTED_IMAGE
+ + I18N.get("RasterImagePlugIn.28")
+ + this.KEY_ALLWAYSACCEPT_TWF_EXT
+ + I18N.get("RasterImagePlugIn.29")
+ + LoadSextanteRasterImagePlugIn.KEY_PATH
+ + I18N.get("RasterImagePlugIn.30"));
- if (zoomToInsertedImage || layersAsideImage==0){
- //logger.printDebug("zooming to image, layers: " + layersAsideImage);
- try {
- context.getLayerViewPanel().getViewport().zoom(envelope);
- } catch (NoninvertibleTransformException e) {
- //logger.printDebug(e.getMessage());
- }
- }
+ String selectedFilename = file.getPath();
+ this.imageFileName = selectedFilename;
+ this.cachedLayer = selectedFilename.substring(
+ selectedFilename.lastIndexOf(File.separator) + 1,
+ selectedFilename.lastIndexOf("."));
+ boolean imageAdded = false;
- return true;
- }
+ Point imageDimensions = RasterImageIO
+ .getImageDimensions(selectedFilename);
+ Envelope env = this.getGeoReferencing(selectedFilename,
+ this.allwaysLookForTFWExtension, imageDimensions,
+ this.workbenchContext);
- /**
- * TODO: [sstein] Feb.2009 - I discovered a 0.5px offset towards south-east for
- * the envelope, in comparison with images loaded with Jon's/VividSolutions implementation,
- * if the envelope is obtained from a worldfile.
- * Not sure what is correct. I.e. this implementation seems to assume that the worldfile
- * coordinate system origin is the corner of the first pixel and not the center.
- * I have corrected this in WorldFileHandler.readWorldFile()
- * @param fileName
- * @param allwaysLookForTFWExtension
- * @param imageDimensions
- * @param context
- * @return the RasterImage Envelope
- * @throws IOException
- * @throws NoninvertibleTransformException
- */
- protected Envelope getGeoReferencing(String fileName, boolean allwaysLookForTFWExtension, Point imageDimensions, WorkbenchContext context) throws IOException, NoninvertibleTransformException{
- double minx, maxx, miny, maxy;
- Envelope env = null;
-
- this.worldFileHandler = new WorldFileHandler(fileName, allwaysLookForTFWExtension);
-
- if (imageDimensions == null){
- //logger.printError("can not determine image dimensions");
- context.getWorkbench().getFrame().warnUser(I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions"));
- return null;
- }
-
- if (this.worldFileHandler.isWorldFileExistentForImage()!=null) {
- //logger.printDebug(PirolPlugInMessages.getString("worldfile-found"));
- env = this.worldFileHandler.readWorldFile(imageDimensions.x, imageDimensions.y);
- }
-
- if (env == null) {
-
- boolean isGeoTiff = false;
-
- if ( fileName.toLowerCase().endsWith(".tif") || fileName.toLowerCase().endsWith(".tiff") ) {
- //logger.printDebug("checking for GeoTIFF");
-
- Coordinate tiePoint = null, pixelOffset = null, pixelScale = null;
- double[] doubles = null;
-
- FileSeekableStream fileSeekableStream = new FileSeekableStream(fileName);
- TIFFDirectory tiffDirectory = new TIFFDirectory(fileSeekableStream, 0);
-
- TIFFField[] availTags = tiffDirectory.getFields();
-
- for (int i=0; i<availTags.length; i++){
- if (availTags[i].getTag() == GeoTiffConstants.ModelTiepointTag){
- doubles = availTags[i].getAsDoubles();
-
- if (doubles.length != 6){
- //logger.printError("unsupported value for ModelTiepointTag (" + GeoTiffConstants.ModelTiepointTag + ")");
- context.getWorkbench().getFrame().warnUser("unsupported value for ModelTiepointTag (" + GeoTiffConstants.ModelTiepointTag + ")");
- break;
- }
-
- if (doubles[0]!=0 || doubles[1]!=0 || doubles[2]!=0){
- if (doubles[2]==0)
- pixelOffset = new Coordinate(doubles[0],doubles[1]);
- else
- pixelOffset = new Coordinate(doubles[0],doubles[1],doubles[2]);
- }
-
- if (doubles[5]==0)
- tiePoint = new Coordinate(doubles[3],doubles[4]);
- else
- tiePoint = new Coordinate(doubles[3],doubles[4],doubles[5]);
-
- //logger.printDebug("ModelTiepointTag (po): " + pixelOffset);
- //logger.printDebug("ModelTiepointTag (tp): " + tiePoint);
- } else if (availTags[i].getTag() == GeoTiffConstants.ModelPixelScaleTag){
- // Karteneinheiten pro pixel x bzw. y
-
- doubles = availTags[i].getAsDoubles();
-
- if (doubles.length == 2 || doubles[2] == 0) {
- pixelScale = new Coordinate(doubles[0],doubles[1]);
- } else {
- pixelScale = new Coordinate(doubles[0],doubles[1],doubles[2]);
- }
- //logger.printDebug("ModelPixelScaleTag (ps): " + pixelScale);
- } else {
- //logger.printDebug("tiff field: " + availTags[i].getType() + ", "+ availTags[i].getTag() + ", "+ availTags[i].getCount());
- }
-
- }
-
- fileSeekableStream.close();
-
- if (tiePoint!=null && pixelScale!=null){
- isGeoTiff = true;
- Coordinate upperLeft = null, lowerRight = null;
-
- if (pixelOffset==null){
- upperLeft = tiePoint;
- } else {
- upperLeft = new Coordinate( tiePoint.x - (pixelOffset.x * pixelScale.x), tiePoint.y - (pixelOffset.y * pixelScale.y));
- }
-
- lowerRight = new Coordinate( upperLeft.x + (imageDimensions.x * pixelScale.x), upperLeft.y - (imageDimensions.y * pixelScale.y));
-
- //logger.printDebug("upperLeft: " + upperLeft);
- //logger.printDebug("lowerRight: " + lowerRight);
-
- env = new Envelope(upperLeft, lowerRight);
- }
-
- }else if(fileName.toLowerCase().endsWith(".flt")){
+ if (env != null) {
+ imageAdded = this.addImage(workbenchContext, env,
+ imageDimensions);
+ }
+
+ OpenRecentPlugIn.get(workbenchContext).addRecentFile(file);
+
+ } finally {
+ // reader.close();
+ }
+ } catch (Exception e) {
+ monitor.report(e);
+ }
+ }
+
+ private boolean addImage(WorkbenchContext context, Envelope envelope,
+ Point imageDimensions) {
+
+ String newLayerName = context.getLayerManager().uniqueLayerName(
+ cachedLayer);
+
+ String catName = StandardCategoryNames.WORKING;
+
+ try {
+ catName = ((Category) context.createPlugInContext()
+ .getLayerNamePanel().getSelectedCategories().toArray()[0])
+ .getName();
+ } catch (RuntimeException e1) {
+ // logger.printDebug(e1.getMessage());
+ }
+
+ int layersAsideImage = context.getLayerManager()
+ .getLayerables(Layerable.class).size();
+
+ RasterImageLayer rLayer = new RasterImageLayer(newLayerName,
+ context.getLayerManager(), imageFileName, null, envelope);
+
+ // #################################
+
+ MetaInformationHandler mih = new MetaInformationHandler(rLayer);
+ // [sstein 28.Feb.2009] -- not sure if these keys should be translated
+ mih.addMetaInformation("file-name", this.imageFileName);
+ mih.addMetaInformation("resolution", imageDimensions.x + " (px) x "
+ + imageDimensions.y + " (px)");
+ // mih.addMetaInformation("real-world-width", new
+ // Double(envelope.getWidth()));
+ // mih.addMetaInformation("real-world-height", new
+ // Double(envelope.getHeight()));
+ mih.addMetaInformation("real-world-width",
+ new Double(envelope.getWidth()));
+ mih.addMetaInformation("real-world-height",
+ new Double(envelope.getHeight()));
+
+ // ###################################
+
+ context.getLayerManager().addLayerable(catName, rLayer);
+
+ if (zoomToInsertedImage || layersAsideImage == 0) {
+ // logger.printDebug("zooming to image, layers: " +
+ // layersAsideImage);
+ try {
+ context.getLayerViewPanel().getViewport().zoom(envelope);
+ } catch (NoninvertibleTransformException e) {
+ // logger.printDebug(e.getMessage());
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * TODO: [sstein] Feb.2009 - I discovered a 0.5px offset towards south-east
+ * for the envelope, in comparison with images loaded with
+ * Jon's/VividSolutions implementation, if the envelope is obtained from a
+ * worldfile. Not sure what is correct. I.e. this implementation seems to
+ * assume that the worldfile coordinate system origin is the corner of the
+ * first pixel and not the center. I have corrected this in
+ * WorldFileHandler.readWorldFile()
+ *
+ * @param fileName
+ * @param allwaysLookForTFWExtension
+ * @param imageDimensions
+ * @param context
+ * @return the RasterImage Envelope
+ * @throws IOException
+ * @throws NoninvertibleTransformException
+ */
+ protected Envelope getGeoReferencing(String fileName,
+ boolean allwaysLookForTFWExtension, Point imageDimensions,
+ WorkbenchContext context) throws IOException,
+ NoninvertibleTransformException {
+ double minx, maxx, miny, maxy;
+ Envelope env = null;
+
+ this.worldFileHandler = new WorldFileHandler(fileName,
+ allwaysLookForTFWExtension);
+ // 2015-04-10 [Giuseppe Aruta] Calculate Image dimension
+ File fil = new File(fileName);
+ BufferedImage bufImg = ImageIO.read(fil);
+ int width = bufImg.getWidth();
+ int height = bufImg.getHeight();
+ if (imageDimensions == null) {
+ // logger.printError("can not determine image dimensions");
+ context.getWorkbench()
+ .getFrame()
+ .warnUser(
+ I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.can-not-determine-image-dimensions"));
+ return null;
+ }
+
+ if (this.worldFileHandler.isWorldFileExistentForImage() != null) {
+ // logger.printDebug(PirolPlugInMessages.getString("worldfile-found"));
+ env = this.worldFileHandler.readWorldFile(imageDimensions.x,
+ imageDimensions.y);
+ }
+
+ if (env == null) {
+
+ boolean isGeoTiff = false;
+
+ if (fileName.toLowerCase().endsWith(".tif")
+ || fileName.toLowerCase().endsWith(".tiff")) {
+ // logger.printDebug("checking for GeoTIFF");
+
+ Coordinate tiePoint = null, pixelOffset = null, pixelScale = null;
+ double[] doubles = null;
+
+ FileSeekableStream fileSeekableStream = new FileSeekableStream(
+ fileName);
+ TIFFDirectory tiffDirectory = new TIFFDirectory(
+ fileSeekableStream, 0);
+
+ TIFFField[] availTags = tiffDirectory.getFields();
+
+ for (int i = 0; i < availTags.length; i++) {
+ if (availTags[i].getTag() == GeoTiffConstants.ModelTiepointTag) {
+ doubles = availTags[i].getAsDoubles();
+
+ if (doubles.length != 6) {
+ // logger.printError("unsupported value for ModelTiepointTag ("
+ // + GeoTiffConstants.ModelTiepointTag + ")");
+ context.getWorkbench()
+ .getFrame()
+ .warnUser(
+ "unsupported value for ModelTiepointTag ("
+ + GeoTiffConstants.ModelTiepointTag
+ + ")");
+ break;
+ }
+
+ if (doubles[0] != 0 || doubles[1] != 0
+ || doubles[2] != 0) {
+ if (doubles[2] == 0)
+ pixelOffset = new Coordinate(doubles[0],
+ doubles[1]);
+ else
+ pixelOffset = new Coordinate(doubles[0],
+ doubles[1], doubles[2]);
+ }
+
+ if (doubles[5] == 0)
+ tiePoint = new Coordinate(doubles[3], doubles[4]);
+ else
+ tiePoint = new Coordinate(doubles[3], doubles[4],
+ doubles[5]);
+
+ // logger.printDebug("ModelTiepointTag (po): " +
+ // pixelOffset);
+ // logger.printDebug("ModelTiepointTag (tp): " +
+ // tiePoint);
+ } else if (availTags[i].getTag() == GeoTiffConstants.ModelPixelScaleTag) {
+ // Karteneinheiten pro pixel x bzw. y
+
+ doubles = availTags[i].getAsDoubles();
+
+ if (doubles.length == 2 || doubles[2] == 0) {
+ pixelScale = new Coordinate(doubles[0], doubles[1]);
+ } else {
+ pixelScale = new Coordinate(doubles[0], doubles[1],
+ doubles[2]);
+ }
+ // logger.printDebug("ModelPixelScaleTag (ps): " +
+ // pixelScale);
+ } else {
+ // logger.printDebug("tiff field: " +
+ // availTags[i].getType() + ", "+ availTags[i].getTag()
+ // + ", "+ availTags[i].getCount());
+ }
+
+ }
+
+ fileSeekableStream.close();
+
+ if (tiePoint != null && pixelScale != null) {
+ isGeoTiff = true;
+ Coordinate upperLeft = null, lowerRight = null;
+
+ if (pixelOffset == null) {
+ upperLeft = tiePoint;
+ } else {
+ upperLeft = new Coordinate(tiePoint.x
+ - (pixelOffset.x * pixelScale.x), tiePoint.y
+ - (pixelOffset.y * pixelScale.y));
+ }
+
+ lowerRight = new Coordinate(upperLeft.x
+ + (imageDimensions.x * pixelScale.x), upperLeft.y
+ - (imageDimensions.y * pixelScale.y));
+
+ // logger.printDebug("upperLeft: " + upperLeft);
+ // logger.printDebug("lowerRight: " + lowerRight);
+
+ env = new Envelope(upperLeft, lowerRight);
+ }
+
+ } else if (fileName.toLowerCase().endsWith(".flt")) {
isGeoTiff = true;
GridFloat gf = new GridFloat(fileName);
- Coordinate upperLeft = new Coordinate(gf.getXllCorner(), gf.getYllCorner() + gf.getnRows() * gf.getCellSize());
- Coordinate lowerRight = new Coordinate(gf.getXllCorner() + gf.getnCols() * gf.getCellSize(), gf.getYllCorner());
+ Coordinate upperLeft = new Coordinate(gf.getXllCorner(),
+ gf.getYllCorner() + gf.getnRows() * gf.getCellSize());
+ Coordinate lowerRight = new Coordinate(gf.getXllCorner()
+ + gf.getnCols() * gf.getCellSize(), gf.getYllCorner());
env = new Envelope(upperLeft, lowerRight);
- }else if(fileName.toLowerCase().endsWith(".asc")){
+ } else if (fileName.toLowerCase().endsWith(".asc")) {
isGeoTiff = true;
GridAscii ga = new GridAscii(fileName);
- Coordinate upperLeft = new Coordinate(ga.getXllCorner(), ga.getYllCorner() + ga.getnRows() * ga.getCellSize());
- Coordinate lowerRight = new Coordinate(ga.getXllCorner() + ga.getnCols() * ga.getCellSize(), ga.getYllCorner());
+ Coordinate upperLeft = new Coordinate(ga.getXllCorner(),
+ ga.getYllCorner() + ga.getnRows() * ga.getCellSize());
+ Coordinate lowerRight = new Coordinate(ga.getXllCorner()
+ + ga.getnCols() * ga.getCellSize(), ga.getYllCorner());
env = new Envelope(upperLeft, lowerRight);
}
-
- if (!isGeoTiff || env==null){
- //logger.printDebug(PirolPlugInMessages.getString("no-worldfile-found"));
- context.getWorkbench().getFrame().warnUser(I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found"));
- WizardDialog d = new WizardDialog(
- context.getWorkbench().getFrame(),
- I18N.get("RasterImagePlugIn.34")
- + this.worldFileHandler.getWorldFileName()
- + I18N.get("RasterImagePlugIn.35"),
- context.getErrorHandler());
- d.init(new WizardPanel[] { new RasterImageWizardPanel() });
- //Set size after #init, because #init calls #pack. [Jon Aquino]
- d.setSize(500, 400);
- GUIUtil.centreOnWindow(d);
- d.setVisible(true);
-
- if (!d.wasFinishPressed()) {
- //logger.printWarning("user canceled");
- return null;
- }
- try {
- minx = Double.parseDouble((String) d
- .getData(RasterImageWizardPanel.MINX_KEY));
- maxx = Double.parseDouble((String) d
- .getData(RasterImageWizardPanel.MAXX_KEY));
- miny = Double.parseDouble((String) d
- .getData(RasterImageWizardPanel.MINY_KEY));
- maxy = Double.parseDouble((String) d
- .getData(RasterImageWizardPanel.MAXY_KEY));
-
- env = new Envelope(minx, maxx, miny, maxy);
- }
- catch(java.lang.NumberFormatException e) {
- Viewport viewport = context.getLayerViewPanel().getViewport();
- Rectangle visibleRect = viewport.getPanel().getVisibleRect();
-
- int visibleX1 = visibleRect.x;
- int visibleY1 = visibleRect.y;
- int visibleX2 = visibleX1 + visibleRect.width;
- int visibleY2 = visibleY1 + visibleRect.height;
- Coordinate upperLeftVisible = viewport.toModelCoordinate(new Point(0,0));
- Coordinate lowerRightVisible = viewport.toModelCoordinate(new Point(visibleX2, visibleY2));
- env = new Envelope(upperLeftVisible.x, lowerRightVisible.x, upperLeftVisible.y, lowerRightVisible.y);
- }
-
- }
-
- // creating world file
- this.worldFileHandler = new WorldFileHandler(fileName, this.allwaysLookForTFWExtension);
- this.worldFileHandler.writeWorldFile(env, imageDimensions.x, imageDimensions.y);
- }
-
- return env;
- }
+ if (!isGeoTiff || env == null) {
+ // logger.printDebug(PirolPlugInMessages.getString("no-worldfile-found"));
+
+ Viewport viewport = context.getLayerViewPanel().getViewport();
+ Rectangle visibleRect = viewport.getPanel().getVisibleRect();
+
+ // 015-04-10 [Giuseppe Aruta] Calculate local coordinates
+ // as if the image is anchored to the view
+ int visibleX1 = visibleRect.x;
+ int visibleY1 = visibleRect.y;
+ int visibleX2 = visibleX1 + width;// visibleRect.width;
+ int visibleY2 = visibleY1 + height;// visibleRect.height;
+ Coordinate upperLeftVisible = viewport
+ .toModelCoordinate(new Point(0, 0));
+ Coordinate lowerRightVisible = viewport
+ .toModelCoordinate(new Point(visibleX2, visibleY2));
+
+ context.getWorkbench()
+ .getFrame()
+ .warnUser(
+ I18N.get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.no-worldfile-found"));
+ WizardDialog d = new WizardDialog(context.getWorkbench()
+ .getFrame(), I18N.get("RasterImagePlugIn.34")
+ + this.worldFileHandler.getWorldFileName()
+ + I18N.get("RasterImagePlugIn.35"),
+ context.getErrorHandler());
+ d.init(new WizardPanel[] { new RasterImageWizardPanel() });
+
+ // 2015-04-10 [Giuseppe Aruta]wizard dialog now shows local
+ // coordinates if the image is anchored to /local view
+ RasterImageWizardPanel.minxTextField.setText(Double
+ .toString(upperLeftVisible.x));
+ RasterImageWizardPanel.maxxTextField.setText(Double
+ .toString(lowerRightVisible.x));
+ RasterImageWizardPanel.minyTextField.setText(Double
+ .toString(upperLeftVisible.y));
+ RasterImageWizardPanel.maxyTextField.setText(Double
+ .toString(lowerRightVisible.y));
+
+ // Set size after #init, because #init calls #pack. [Jon Aquino]
+ d.setSize(650, 450);
+ GUIUtil.centreOnWindow(d);
+ d.setVisible(true);
+
+ if (!d.wasFinishPressed()) {
+ // logger.printWarning("user canceled");
+ return null;
+ }
+
+ try {
+
+ minx = Double.parseDouble((String) d
+ .getData(RasterImageWizardPanel.MINX_KEY));
+ maxx = Double.parseDouble((String) d
+ .getData(RasterImageWizardPanel.MAXX_KEY));
+ miny = Double.parseDouble((String) d
+ .getData(RasterImageWizardPanel.MINY_KEY));
+ maxy = Double.parseDouble((String) d
+ .getData(RasterImageWizardPanel.MAXY_KEY));
+
+ env = new Envelope(minx, maxx, miny, maxy);
+ } catch (java.lang.NumberFormatException e) {
+ /*
+ * Viewport viewport = context.getLayerViewPanel()
+ * .getViewport(); Rectangle visibleRect =
+ * viewport.getPanel() .getVisibleRect();
+ *
+ * BufferedImage bimg = ImageIO.read(new File(fileName));
+ * int width = bimg.getWidth(); int height =
+ * bimg.getHeight();
+ *
+ * int visibleX1 = visibleRect.x; int visibleY1 =
+ * visibleRect.y; int visibleX2 = visibleX1 + width;//
+ * visibleRect.width; int visibleY2 = visibleY1 + height;//
+ * visibleRect.height; Coordinate upperLeftVisible =
+ * viewport .toModelCoordinate(new Point(0, 0)); Coordinate
+ * lowerRightVisible = viewport .toModelCoordinate(new
+ * Point(visibleX2, visibleY2));
+ */
+ env = new Envelope(upperLeftVisible.x, lowerRightVisible.x,
+ upperLeftVisible.y, lowerRightVisible.y);
+ }
+
+ }
+
+ // creating world file
+ this.worldFileHandler = new WorldFileHandler(fileName,
+ this.allwaysLookForTFWExtension);
+ this.worldFileHandler.writeWorldFile(env, imageDimensions.x,
+ imageDimensions.y);
+ String MSG = I18N
+ .getMessage(
+ "org.openjump.core.rasterimage.AddRasterImageLayerWizard.message",
+ new Object[] { fil.getName() });
+ context.getWorkbench().getFrame().setStatusMessage(MSG);
+
+ }
+
+ return env;
+ }
+
}
Modified: core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/RasterImageWizardPanel.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/RasterImageWizardPanel.java 2015-04-09 11:26:42 UTC (rev 4392)
+++ core/trunk/src/org/openjump/core/ui/plugin/layer/pirolraster/RasterImageWizardPanel.java 2015-04-10 09:24:00 UTC (rev 4393)
@@ -56,19 +56,25 @@
import com.vividsolutions.jump.workbench.ui.InputChangedListener;
import com.vividsolutions.jump.workbench.ui.wizard.WizardPanel;
-
/**
-* Panel for setting properties for viewed image.
-* @author jan...@vs...
-*/
-public class RasterImageWizardPanel extends JPanel implements WizardPanel, ActionListener {
+ * Panel for setting properties for viewed image.
+ *
+ * @author jan...@vs...
+ */
+public class RasterImageWizardPanel extends JPanel implements WizardPanel,
+ ActionListener {
- private static final long serialVersionUID = -6644440388147608621L;
-
- public static final String MINX_KEY = I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.minx"); //$NON-NLS-1$
- public static final String MAXX_KEY = I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxx"); //$NON-NLS-1$
- public static final String MINY_KEY = I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.miny"); //$NON-NLS-1$
- public static final String MAXY_KEY = I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxy"); //$NON-NLS-1$
+ private static final long serialVersionUID = -6644440388147608621L;
+ public static final String WRITE_WORLDFILE = I18N
+ .get("ui.plugin.SaveImageAsPlugIn.write-world-file");
+ public static final String MINX_KEY = I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.minx"); //$NON-NLS-1$
+ public static final String MAXX_KEY = I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxx"); //$NON-NLS-1$
+ public static final String MINY_KEY = I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.miny"); //$NON-NLS-1$
+ public static final String MAXY_KEY = I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxy"); //$NON-NLS-1$
private InputChangedFirer inputChangedFirer = new InputChangedFirer();
private Map dataMap;
@@ -76,28 +82,34 @@
private JPanel fillerPanel = new JPanel();
private JLabel minxLabel = new JLabel();
- private JTextField minxTextField = new JTextField();
+ public static JTextField minxTextField = new JTextField();
private JLabel maxxLabel = new JLabel();
- private JTextField maxxTextField = new JTextField();
+ public static JTextField maxxTextField = new JTextField();
private JLabel minyLabel = new JLabel();
- private JTextField minyTextField = new JTextField();
+ public static JTextField minyTextField = new JTextField();
private JLabel maxyLabel = new JLabel();
- private JTextField maxyTextField = new JTextField();
+ public static JTextField maxyTextField = new JTextField();
public RasterImageWizardPanel() {
try {
jbInit();
- minxTextField.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.west-coordinate")); //$NON-NLS-1$
- maxxTextField.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.east-coordinate")); //$NON-NLS-1$
- minyTextField.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.south-coordinate")); //$NON-NLS-1$
- maxyTextField.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.north-coordinate")); //$NON-NLS-1$
+ minxTextField
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.west-coordinate")); //$NON-NLS-1$
+ maxxTextField
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.east-coordinate")); //$NON-NLS-1$
+ minyTextField
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.south-coordinate")); //$NON-NLS-1$
+ maxyTextField
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.north-coordinate")); //$NON-NLS-1$
} catch (Exception ex) {
ex.printStackTrace();
}
}
-
-
public void add(InputChangedListener listener) {
inputChangedFirer.add(listener);
}
@@ -107,83 +119,86 @@
}
/**
- * Creates UI on JPanel
- */
+ * Creates UI on JPanel
+ */
void jbInit() throws Exception {
- minxLabel.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.minx")); //$NON-NLS-1$
- maxxLabel.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxx")); //$NON-NLS-1$
- minyLabel.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.miny")); //$NON-NLS-1$
- maxyLabel.setText(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxy")); //$NON-NLS-1$
+ minxLabel
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.minx")); //$NON-NLS-1$
+ maxxLabel
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxx")); //$NON-NLS-1$
+ minyLabel
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.miny")); //$NON-NLS-1$
+ maxyLabel
+ .setText(I18N
+ .get("org.openjump.core.ui.plugin.layer.pirolraster.RasterImageWizardPanel.maxy")); //$NON-NLS-1$
this.setLayout(gridBagLayout1);
minxTextField.setPreferredSize(new Dimension(270, 21));
minxTextField.setCaretPosition(minxTextField.getText().length());
- maxxTextField.setPreferredSize(new Dimension(270, 21));
+ maxxTextField.setPreferredSize(new Dimension(270, 21));
maxxTextField.setCaretPosition(maxxTextField.getText().length());
- minyTextField.setPreferredSize(new Dimension(270, 21));
+ minyTextField.setPreferredSize(new Dimension(270, 21));
minyTextField.setCaretPosition(minyTextField.getText().length());
- maxyTextField.setPreferredSize(new Dimension(270, 21));
+ maxyTextField.setPreferredSize(new Dimension(270, 21));
maxyTextField.setCaretPosition(maxyTextField.getText().le...
[truncated message content] |