Revision 1371
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster.osm</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<version>2.2.246</version> |
|
8 |
<name>org.gvsig.raster.osm</name> |
|
9 |
<description>OSM adapter</description> |
|
10 |
<inceptionYear>2011</inceptionYear> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.449</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<repositories> |
|
18 |
<repository> |
|
19 |
<id>gvsig-public-http-repository</id> |
|
20 |
<name>gvSIG maven public HTTP repository</name> |
|
21 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
22 |
<releases> |
|
23 |
<enabled>true</enabled> |
|
24 |
<updatePolicy>daily</updatePolicy> |
|
25 |
<checksumPolicy>warn</checksumPolicy> |
|
26 |
</releases> |
|
27 |
<snapshots> |
|
28 |
<enabled>true</enabled> |
|
29 |
<updatePolicy>daily</updatePolicy> |
|
30 |
<checksumPolicy>warn</checksumPolicy> |
|
31 |
</snapshots> |
|
32 |
</repository> |
|
33 |
</repositories> |
|
34 |
|
|
35 |
<scm> |
|
36 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-osm/org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246</connection> |
|
37 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-osm/org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246</developerConnection> |
|
38 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-osm/repository/show/org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246</url> |
|
39 |
</scm> |
|
40 |
<properties> |
|
41 |
<org.gvsig.raster.version>2.2.269</org.gvsig.raster.version> |
|
42 |
</properties> |
|
43 |
|
|
44 |
<dependencyManagement> |
|
45 |
<dependencies> |
|
46 |
<dependency> |
|
47 |
<groupId>org.gvsig</groupId> |
|
48 |
<artifactId>org.gvsig.raster</artifactId> |
|
49 |
<version>${org.gvsig.raster.version}</version> |
|
50 |
<type>pom</type> |
|
51 |
<scope>import</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.raster.osm.swing.api</artifactId> |
|
57 |
<version>2.2.246</version> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.raster.osm.swing.impl</artifactId> |
|
62 |
<version>2.2.246</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.raster.osm.io</artifactId> |
|
67 |
<version>2.2.246</version> |
|
68 |
</dependency> |
|
69 |
|
|
70 |
<dependency> |
|
71 |
<groupId>org.apache.httpcomponents</groupId> |
|
72 |
<artifactId>httpclient</artifactId> |
|
73 |
<version>4.5.13</version> |
|
74 |
<!-- <type>jar</type>--> |
|
75 |
</dependency> |
|
76 |
|
|
77 |
</dependencies> |
|
78 |
</dependencyManagement> |
|
79 |
|
|
80 |
<build> |
|
81 |
<plugins> |
|
82 |
<plugin> |
|
83 |
<groupId>org.apache.maven.plugins</groupId> |
|
84 |
<artifactId>maven-release-plugin</artifactId> |
|
85 |
<configuration> |
|
86 |
<tagBase>https://devel.gvsig.org/svn/gvsig-osm/org.gvsig.raster.osm/tags/</tagBase> |
|
87 |
<goals>deploy</goals> |
|
88 |
</configuration> |
|
89 |
</plugin> |
|
90 |
</plugins> |
|
91 |
</build> |
|
92 |
<modules> |
|
93 |
<module>org.gvsig.raster.osm.io</module> |
|
94 |
<module>org.gvsig.raster.osm.swing</module> |
|
95 |
<module>org.gvsig.raster.osm.app.osmclient</module> |
|
96 |
</modules> |
|
97 |
</project> |
|
98 |
|
|
0 | 99 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/buildNumber.properties | ||
---|---|---|
1 |
#Fri Jun 14 07:32:06 CEST 2024 |
|
2 |
buildNumber=299 |
|
0 | 3 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/about/osm-about.html | ||
---|---|---|
1 |
<html> |
|
2 |
<head> |
|
3 |
<style type="text/css"> |
|
4 |
BODY { background-image: url(logo.png); background-repeat: no-repeat; background-position: 100% 0% } |
|
5 |
</style> |
|
6 |
</head> |
|
7 |
<body> |
|
8 |
<h2>Soporte Open Street Map para gvSIG</h2> |
|
9 |
<p><b>Nacho Brodin (nachobrodin@gmail.com)</b> ha incorporado el soporte para <b>OSM</b> en gvSIG</p> |
|
10 |
|
|
11 |
<p>Licencia datos:</p> |
|
12 |
<ul> |
|
13 |
CC-BY-SA-2.0 ? Contribuidores de OpenStreetMap |
|
14 |
</ul> |
|
15 |
|
|
16 |
</body> |
|
17 |
</html> |
|
0 | 18 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/text.properties | ||
---|---|---|
1 |
error_creating_the_view=Error creando una vista nueva. Pruebe creando una manualmente. |
|
2 |
error_creating_parameters=Error creando los par\u00e1metros |
|
3 |
server_not_selected=No hay un servidor seleccionado |
|
4 |
error_loading_epsg=Error cargando el EPSG:3785 desde el plugin de OSM.\n Comprueba que la extensi\u00f3n JCRS est\u00e1 instalada y funcionando. \n Esta proyecci\u00f3n no estar\u00e1 disponible aunque la \n carga de tiles deber\u00eda funcionar correctamente. |
|
5 |
dont_remind_me_anymore=No me lo recuerdes m\u00e1s |
|
6 |
ok=OK |
|
7 |
|
|
8 |
_crs_warning=La proyecci\u00f3n de la vista no es la adecuada para cargar capas de este servicio. |
|
0 | 9 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/text_en.properties | ||
---|---|---|
1 |
error_creating_the_view=Error creating a new view |
|
2 |
error_creating_parameters=Error creating the parameters |
|
3 |
server_not_selected=There is not a server selected |
|
4 |
error_loading_epsg=Error loading EPSG:3785 in database from OSM plug-in.\n Checks if JCRS plug-in is installed and running. \nThis projection is not available. |
|
5 |
dont_remind_me_anymore=Don't remind me anymore |
|
6 |
ok=OK |
|
7 |
|
|
8 |
_crs_warning=The projection of the view is not appropriate to load layers of this service. |
|
0 | 9 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/osmservers.properties | ||
---|---|---|
1 |
#Fri Jun 30 15:01:55 CEST 2017 |
|
2 |
Stamen_Terrain=Stamen Terrain*http\://tile.stamen.com/terrain*17*jpg |
|
3 |
OSM_France=OSM France*http\://a.tile.openstreetmap.fr/osmfr*18*png |
|
4 |
Carto_Dark_(Map_tiles_by_Carto)=Carto Dark (Map tiles by Carto)*http\://a.basemaps.cartocdn.com/dark_all/*18*png |
|
5 |
Hillshading=Hillshading*http\://c.tiles.wmflabs.org/hillshading/*18*png |
|
6 |
Open_Sea_Map=Open Sea Map*http\://tiles.openseamap.org/seamark/*18*png |
|
7 |
Stamen_Watercolor=Stamen Watercolor*http\://tile.stamen.com/watercolor*17*jpg |
|
8 |
Carto_Light_(Map_tiles_by_Carto)=Carto Light (Map tiles by Carto)*http\://a.basemaps.cartocdn.com/light_all/*18*png |
|
9 |
Stamen_Toner=Stamen Toner*http\://tile.stamen.com/toner*17*png |
|
10 |
HOT_Style=HOT Style*http\://a.tile.openstreetmap.fr/hot/*18*png |
|
11 |
Open_Railway_Map=Open Railway Map*http\://a.tiles.openrailwaymap.org/standard/*17*png |
|
12 |
Mapnik=Mapnik*http\://tile.openstreetmap.org/*18*png |
|
13 |
OSM_Black_&_White=OSM Black & White*http\://tiles.wmflabs.org/bw-mapnik/*18*png |
|
0 | 14 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.raster.tilecache.app" /> |
|
4 |
<libraries library-dir="lib"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.raster.osm.app.osmclient.OSMClientExtension" |
|
8 |
description="M?dulo de OpenStreetMap." |
|
9 |
active="true" |
|
10 |
priority="1"> |
|
11 |
</extension> |
|
12 |
</extensions> |
|
13 |
</plugin-config> |
|
0 | 14 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.osm.io:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.osm.swing.api:jar</include> |
|
34 |
<include>org.gvsig:org.gvsig.raster.osm.swing.impl:jar</include> |
|
35 |
</includes> |
|
36 |
</dependencySet> |
|
37 |
</dependencySets> |
|
38 |
</assembly> |
|
0 | 39 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/java/org/gvsig/raster/osm/app/osmclient/layer/FLyrOSM.java | ||
---|---|---|
1 |
/* OSM layers for gvSIG. |
|
2 |
* Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2012 Nacho Brodin |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.raster.osm.app.osmclient.layer; |
|
24 |
|
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Image; |
|
28 |
import java.awt.Point; |
|
29 |
import java.awt.geom.Point2D; |
|
30 |
import java.awt.image.BufferedImage; |
|
31 |
import java.lang.ref.WeakReference; |
|
32 |
import java.net.URI; |
|
33 |
import java.util.ArrayList; |
|
34 |
import java.util.HashMap; |
|
35 |
import java.util.Iterator; |
|
36 |
import java.util.List; |
|
37 |
|
|
38 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
39 |
|
|
40 |
import org.cresques.cts.ICoordTrans; |
|
41 |
|
|
42 |
import org.gvsig.andami.PluginServices; |
|
43 |
import org.gvsig.fmap.dal.DALLocator; |
|
44 |
import org.gvsig.fmap.dal.DataParameters; |
|
45 |
import org.gvsig.fmap.dal.DataStore; |
|
46 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
47 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
48 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
49 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
50 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
51 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
|
52 |
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException; |
|
53 |
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException; |
|
54 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
55 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
56 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
57 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
58 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
59 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
60 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
61 |
import org.gvsig.fmap.dal.exception.DataException; |
|
62 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
63 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
64 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
65 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
66 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
67 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
68 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
69 |
import org.gvsig.fmap.geom.GeometryManager; |
|
70 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
71 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
72 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
73 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
74 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
75 |
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend; |
|
76 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
77 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
78 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
79 |
import org.gvsig.raster.fmap.layers.NotAvailableStateException; |
|
80 |
import org.gvsig.raster.osm.io.OSMDataParameters; |
|
81 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
82 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
83 |
import org.gvsig.tools.ToolsLocator; |
|
84 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
85 |
import org.gvsig.tools.dynobject.DynStruct; |
|
86 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
87 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
88 |
import org.gvsig.tools.task.TaskStatusManager; |
|
89 |
|
|
90 |
import org.slf4j.Logger; |
|
91 |
import org.slf4j.LoggerFactory; |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* Open Street Map layer class. |
|
96 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
97 |
*/ |
|
98 |
public class FLyrOSM extends DefaultFLyrRaster implements IHasImageLegend { |
|
99 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
100 |
private static final Logger logger = LoggerFactory.getLogger(FLyrOSM.class); |
|
101 |
private List<WeakReference<Thread>> disableUpdateDrawVersion; |
|
102 |
private boolean firstLoad = false; |
|
103 |
private RasterManager rManager = RasterLocator.getManager(); |
|
104 |
private boolean deleteCache = false; |
|
105 |
|
|
106 |
public static void registerPersistent() { |
|
107 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
108 |
DynStruct definition = manager.getDefinition("FLyrOSM_Persistent"); |
|
109 |
if( definition == null ) { |
|
110 |
if (manager.getDefinition(DefaultFLyrRaster.class) == null) { |
|
111 |
DefaultFLyrRaster.registerPersistence(); |
|
112 |
} |
|
113 |
|
|
114 |
definition = manager.addDefinition( |
|
115 |
FLyrOSM.class, |
|
116 |
"FLyrOSM_Persistent", |
|
117 |
"FLyrOSM Persistent Definition", |
|
118 |
null, |
|
119 |
null |
|
120 |
); |
|
121 |
|
|
122 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
public FLyrOSM() { |
|
127 |
super(); |
|
128 |
this.updateDrawVersion(); |
|
129 |
try { |
|
130 |
enableAwake(); |
|
131 |
} catch (NotAvailableStateException e) { |
|
132 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
public static DataStore createDataStore(URI host) throws InitializeException { |
|
137 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
138 |
RasterDataParameters params = null; |
|
139 |
try { |
|
140 |
params = (RasterDataParameters)dataman.createStoreParameters("OSM Raster"); |
|
141 |
} catch (InitializeException e) { |
|
142 |
RasterSwingLibrary.messageBoxInfo("error_creating_parameters", PluginServices.getMDIManager().getActiveWindow(), e); |
|
143 |
} catch (ProviderNotRegisteredException e) { |
|
144 |
RasterSwingLibrary.messageBoxInfo("error_creating_parameters", PluginServices.getMDIManager().getActiveWindow(), e); |
|
145 |
} |
|
146 |
params.setURI(host); |
|
147 |
|
|
148 |
try { |
|
149 |
return dataman.openStore(params.getDataStoreName(), params); |
|
150 |
} catch (ValidateDataParametersException e) { |
|
151 |
throw new InitializeException(e); |
|
152 |
} catch (ProviderNotRegisteredException e) { |
|
153 |
throw new InitializeException(e); |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
public void setDataStore(DataStore dataStore) throws LoadLayerException { |
|
158 |
this.dataStore = (RasterDataStore) dataStore; |
|
159 |
try { |
|
160 |
enableOpen(); |
|
161 |
} catch (NotAvailableStateException e) { |
|
162 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e); |
|
163 |
} |
|
164 |
setProjection(this.dataStore.getProjection()); |
|
165 |
//setFullExtent(this.dataStore.getExtent().toRectangle2D()); |
|
166 |
} |
|
167 |
|
|
168 |
@SuppressWarnings("deprecation") |
|
169 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
170 |
org.gvsig.tools.task.Cancellable cancel, double scale) throws ReadException { |
|
171 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
|
172 |
SimpleTaskStatus taskStatus = new RasterTaskStatus("Drawing " + getName() + "...", cancel); |
|
173 |
manager.add(taskStatus); |
|
174 |
taskStatus.setAutoremove(true); |
|
175 |
|
|
176 |
//Solo el zoom normal recalcula el nivel dependiendo de la escala. El zoom por niveles asigna |
|
177 |
//?l el nivel de zoom por lo que no habr? que recalcularlo. |
|
178 |
if(recalcLevel) { |
|
179 |
double pixelSize = viewPort.getExtent().getWidth() / (double)viewPort.getImageWidth(); |
|
180 |
zoomLevel = dataStore.getNearestLevel(pixelSize); |
|
181 |
} |
|
182 |
recalcLevel = true; |
|
183 |
|
|
184 |
if(!firstLoad) { |
|
185 |
try { |
|
186 |
initFilters(); |
|
187 |
try { |
|
188 |
if(!isOpen()) |
|
189 |
enableOpen(); |
|
190 |
} catch (NotAvailableStateException e) { |
|
191 |
throw new ReadException("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), e); |
|
192 |
} |
|
193 |
} catch (FilePaletteException e) { |
|
194 |
throw new ReadException(e.getMessage(), e); |
|
195 |
} |
|
196 |
firstLoad = true; |
|
197 |
} |
|
198 |
|
|
199 |
enableStopped(); |
|
200 |
|
|
201 |
if (isWithinScale(scale)) { |
|
202 |
if (!viewPort.getAdjustedExtent().intersects(getFullEnvelope())) |
|
203 |
return; |
|
204 |
Envelope adjustedExtent = viewPort.getAdjustedEnvelope(); |
|
205 |
Extent ext = rManager.getDataStructFactory().createExtent( |
|
206 |
adjustedExtent.getLowerCorner().getX(), |
|
207 |
adjustedExtent.getUpperCorner().getY(), |
|
208 |
adjustedExtent.getUpperCorner().getX(), |
|
209 |
adjustedExtent.getLowerCorner().getY()); |
|
210 |
Dimension imgSz = viewPort.getImageSize(); |
|
211 |
ViewPortData vp2 = rManager.getDataStructFactory().createViewPortData(viewPort.getProjection(), ext, imgSz ); |
|
212 |
vp2.setMat(viewPort.getAffineTransform()); |
|
213 |
vp2.setDPI((int)viewPort.getDPI()); |
|
214 |
|
|
215 |
try { |
|
216 |
OSMDataParameters par = getOSMParameters(getDataStore().getParameters()); |
|
217 |
par.setWidth((int)viewPort.getImageSize().getWidth()); |
|
218 |
par.setHeight((int)viewPort.getImageSize().getHeight()); |
|
219 |
|
|
220 |
getRender().drawTiledService(g, vp2, viewPort.getImageSize(), taskStatus); |
|
221 |
} catch (ProcessInterruptedException e) { |
|
222 |
throw new ReadException("Problems drawing this layer: " + e.getMessage(), e); |
|
223 |
} catch (QueryException e) { |
|
224 |
throw new ReadException("Problems drawing this layer: " + e.getMessage(), e); |
|
225 |
} finally { |
|
226 |
taskStatus.terminate(); |
|
227 |
} |
|
228 |
} |
|
229 |
disableStopped(); |
|
230 |
} |
|
231 |
|
|
232 |
|
|
233 |
/** |
|
234 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, |
|
235 |
* com.iver.cit.gvsig.fmap.ViewPort, |
|
236 |
* com.iver.cit.gvsig.fmap.operations.Cancellable) |
|
237 |
*/ |
|
238 |
@SuppressWarnings("deprecation") |
|
239 |
public void print(Graphics2D g, ViewPort viewPort, org.gvsig.tools.task.Cancellable cancel, |
|
240 |
double scale, PrintRequestAttributeSet properties) throws ReadException { |
|
241 |
|
|
242 |
} |
|
243 |
|
|
244 |
@SuppressWarnings("deprecation") |
|
245 |
public void _print(Graphics2D g, ViewPort viewPort, org.gvsig.tools.task.Cancellable cancel, |
|
246 |
double scale) throws ReadException { |
|
247 |
draw(null, g, viewPort, cancel,scale); |
|
248 |
} |
|
249 |
|
|
250 |
public HashMap<String, Object> getProperties() { |
|
251 |
HashMap<String, Object> info = new HashMap<String, Object>(); |
|
252 |
OSMDataParameters par = getOSMParameters(getDataStore().getParameters()); |
|
253 |
String layerName = getName(); |
|
254 |
try { |
|
255 |
info.put("selectedLayer", layerName); |
|
256 |
info.put("host", par.getURI()); |
|
257 |
info.put("srs", dataStore.getProjection().getAbrev()); |
|
258 |
return info; |
|
259 |
} catch (Exception e) { |
|
260 |
e.printStackTrace(); |
|
261 |
} |
|
262 |
return null; |
|
263 |
} |
|
264 |
|
|
265 |
|
|
266 |
public String getTocImageIcon() { |
|
267 |
return "icon-layer-osm"; |
|
268 |
} |
|
269 |
|
|
270 |
public boolean isActionEnabled(int action) { |
|
271 |
switch (action) { |
|
272 |
case IRasterLayerActions.ZOOM_PIXEL_RESOLUTION: |
|
273 |
case IRasterLayerActions.FLYRASTER_BAR_TOOLS: |
|
274 |
case IRasterLayerActions.BANDS_FILE_LIST: |
|
275 |
case IRasterLayerActions.GEOLOCATION: |
|
276 |
case IRasterLayerActions.PANSHARPENING: |
|
277 |
case IRasterLayerActions.SAVE_COLORINTERP: |
|
278 |
case IRasterLayerActions.SAVEAS: |
|
279 |
case IRasterLayerActions.BANDS_RGB: |
|
280 |
case IRasterLayerActions.CLIPPING: |
|
281 |
case IRasterLayerActions.ENHANCED: |
|
282 |
case IRasterLayerActions.STATS: |
|
283 |
case IRasterLayerActions.NODATA: |
|
284 |
case IRasterLayerActions.HISTOGRAM: |
|
285 |
return false; |
|
286 |
case IRasterLayerActions.COLOR_TABLE: |
|
287 |
case IRasterLayerActions.REMOTE_ACTIONS: |
|
288 |
return true; |
|
289 |
} |
|
290 |
|
|
291 |
return super.isActionEnabled(action); |
|
292 |
} |
|
293 |
|
|
294 |
public ILegend getLegend() { |
|
295 |
return null; |
|
296 |
} |
|
297 |
|
|
298 |
public boolean isRemote() { |
|
299 |
return true; |
|
300 |
} |
|
301 |
|
|
302 |
public boolean overviewsSupport() { |
|
303 |
return false; |
|
304 |
} |
|
305 |
|
|
306 |
protected void updateDrawVersion() { |
|
307 |
if (this.disableUpdateDrawVersion != null){ |
|
308 |
|
|
309 |
Thread curThread = Thread.currentThread(); |
|
310 |
|
|
311 |
Thread aThread; |
|
312 |
|
|
313 |
Iterator<WeakReference<Thread>> iter = this.disableUpdateDrawVersion.iterator(); |
|
314 |
while (iter.hasNext()){ |
|
315 |
aThread = (Thread) ((WeakReference<?>)iter.next()).get(); |
|
316 |
if (aThread == null){ |
|
317 |
iter.remove(); |
|
318 |
} else if(aThread.equals(curThread)){ |
|
319 |
return; |
|
320 |
} |
|
321 |
} |
|
322 |
} |
|
323 |
super.updateDrawVersion(); |
|
324 |
} |
|
325 |
|
|
326 |
protected void disableUpdateDrawVersion() { |
|
327 |
if (this.disableUpdateDrawVersion == null) { |
|
328 |
this.disableUpdateDrawVersion = new ArrayList<WeakReference<Thread>>(); |
|
329 |
} |
|
330 |
this.disableUpdateDrawVersion.add(new WeakReference<Thread>(Thread.currentThread())); |
|
331 |
} |
|
332 |
|
|
333 |
protected void enableUpdateDrawVersion() { |
|
334 |
if (this.disableUpdateDrawVersion == null) { |
|
335 |
return; |
|
336 |
} |
|
337 |
Thread curThread = Thread.currentThread(); |
|
338 |
Thread aThread; |
|
339 |
|
|
340 |
Iterator<WeakReference<Thread>> iter = this.disableUpdateDrawVersion.iterator(); |
|
341 |
while (iter.hasNext()) { |
|
342 |
aThread = (Thread) ((WeakReference<?>)iter.next()).get(); |
|
343 |
if (aThread == null) { |
|
344 |
iter.remove(); |
|
345 |
} else if(aThread.equals(curThread)) { |
|
346 |
iter.remove(); |
|
347 |
break; |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
} |
|
352 |
|
|
353 |
/*private Rectangle2D.Double getRectable2DFromEnvelope(Envelope env) { |
|
354 |
return new Rectangle2D.Double(env.getMinimum(0), env.getMinimum(1), env |
|
355 |
.getLength(0), env.getLength(1)); |
|
356 |
} |
|
357 |
|
|
358 |
private Envelope getEnvelopeFromRectable2D(Rectangle2D rect) { |
|
359 |
try { |
|
360 |
return geomManager.createEnvelope(rect.getMinX(), rect.getMinY(), |
|
361 |
rect.getMaxX(), rect.getMaxY(), |
|
362 |
SUBTYPES.GEOM2D); |
|
363 |
} catch (CreateEnvelopeException e) { |
|
364 |
logger.error("Error creating the envelope", e); |
|
365 |
} |
|
366 |
return null; |
|
367 |
}*/ |
|
368 |
|
|
369 |
@Override |
|
370 |
public String getFileFormat() { |
|
371 |
return "OSM"; |
|
372 |
} |
|
373 |
|
|
374 |
|
|
375 |
/** |
|
376 |
* Devuelve el envelope en la proyeccion de la vista |
|
377 |
*/ |
|
378 |
public Envelope getFullEnvelope() { |
|
379 |
Extent e1 = getDataStore().getExtent(); |
|
380 |
Envelope rAux = null; |
|
381 |
try { |
|
382 |
rAux = geomManager.createEnvelope(e1.getMin().getX(), e1.getMin().getY(), e1.getMax().getX(), e1.getMax().getY(), SUBTYPES.GEOM2D); |
|
383 |
} catch (CreateEnvelopeException exc) { |
|
384 |
logger.error("Error creating the envelope", exc); |
|
385 |
} |
|
386 |
|
|
387 |
// Esto es para cuando se crea una capa nueva con el fullExtent de ancho |
|
388 |
// y alto 0. |
|
389 |
if (rAux == null || rAux.getMaximum(0) - rAux.getMinimum(0) == 0 |
|
390 |
&& rAux.getMaximum(1) - rAux.getMinimum(1) == 0) { |
|
391 |
try { |
|
392 |
rAux = geomManager.createEnvelope(0, 0, 100, 100, SUBTYPES.GEOM2D); |
|
393 |
} catch (CreateEnvelopeException e) { |
|
394 |
logger.error("Error creating the envelope", e); |
|
395 |
} |
|
396 |
} |
|
397 |
// Si existe reproyecci?n, reproyectar el extent |
|
398 |
ICoordTrans ct = getCoordTrans(); |
|
399 |
if (ct != null) { |
|
400 |
Point2D pt1 = new Point2D.Double(rAux.getMinimum(0), rAux |
|
401 |
.getMinimum(1)); |
|
402 |
Point2D pt2 = new Point2D.Double(rAux.getMaximum(0), rAux |
|
403 |
.getMaximum(1)); |
|
404 |
pt1 = ct.convert(pt1, null); |
|
405 |
pt2 = ct.convert(pt2, null); |
|
406 |
try { |
|
407 |
rAux = geomManager.createEnvelope(pt1.getX(), pt1.getY(), pt2 |
|
408 |
.getX(), pt2.getY(), SUBTYPES.GEOM2D); |
|
409 |
} catch (CreateEnvelopeException e) { |
|
410 |
logger.error("Error creating the envelope", e); |
|
411 |
}// new |
|
412 |
// Rectangle2D.Double(); |
|
413 |
} |
|
414 |
return rAux; |
|
415 |
|
|
416 |
} |
|
417 |
|
|
418 |
public Extent getFullRasterExtent() { |
|
419 |
Envelope env = getFullEnvelope(); |
|
420 |
double minx = env.getMinimum(0); |
|
421 |
double miny = env.getMinimum(1); |
|
422 |
double maxx = env.getMaximum(0); |
|
423 |
double maxy = env.getMaximum(1); |
|
424 |
Point2D ul = new Point2D.Double(minx, maxy); |
|
425 |
Point2D ur = new Point2D.Double(maxx, maxy); |
|
426 |
Point2D ll = new Point2D.Double(minx, miny); |
|
427 |
Point2D lr = new Point2D.Double(maxx, miny); |
|
428 |
return rManager.getDataStructFactory().createExtent(ul, lr, ur, ll); |
|
429 |
} |
|
430 |
|
|
431 |
@SuppressWarnings("deprecation") |
|
432 |
public DynObjectSet getInfo(Point p, double tolerance, org.gvsig.tools.task.Cancellable cancel) |
|
433 |
throws LoadLayerException, DataException { |
|
434 |
|
|
435 |
return null; |
|
436 |
} |
|
437 |
|
|
438 |
@SuppressWarnings("deprecation") |
|
439 |
public DynObjectSet getInfo(Point p, double tolerance, org.gvsig.tools.task.Cancellable cancel, boolean fast) |
|
440 |
throws LoadLayerException, DataException { |
|
441 |
|
|
442 |
Point2D pReal = getMapContext().getViewPort().toMapPoint(p); |
|
443 |
@SuppressWarnings("unused") |
|
444 |
String fInfo = null; |
|
445 |
try { |
|
446 |
fInfo = getDataStore().getInfoByPoint(pReal.getX(), pReal.getY(), new CancelTaskImpl(cancel)); |
|
447 |
} catch (InfoByPointException e) { |
|
448 |
throw new LoadLayerException("Error in getInfoByPoint", e); |
|
449 |
} |
|
450 |
return null; |
|
451 |
//return new DynObjectSetWMTSInfo(fInfo, type); |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* Sets the data store parameters |
|
456 |
* @param params |
|
457 |
* @throws InitializeException |
|
458 |
*/ |
|
459 |
public void setParameters(DataStoreParameters params) throws InitializeException { |
|
460 |
if(params instanceof TileDataParameters) { |
|
461 |
((TileDataParameters)params).deleteCache(deleteCache); |
|
462 |
} |
|
463 |
|
|
464 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
465 |
try { |
|
466 |
DataStore dStore = dataman.openStore(params.getDataStoreName(), params); |
|
467 |
this.setDataStore(dStore); |
|
468 |
|
|
469 |
if(params instanceof OSMDataParameters) { |
|
470 |
this.setName(((OSMDataParameters) params).getURI().getPath()); |
|
471 |
} |
|
472 |
|
|
473 |
if(params instanceof TileDataParameters) { |
|
474 |
DataParameters p = ((TileDataParameters) params).getDataParameters(); |
|
475 |
if(p instanceof OSMDataParameters) { |
|
476 |
this.setName(((OSMDataParameters) p).getURI().getPath()); |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
480 |
} catch (ValidateDataParametersException e) { |
|
481 |
throw new InitializeException(e); |
|
482 |
} catch (ProviderNotRegisteredException e) { |
|
483 |
throw new InitializeException(e); |
|
484 |
} catch (InitializeException e) { |
|
485 |
throw new InitializeException(e); |
|
486 |
} catch (LoadLayerException e) { |
|
487 |
throw new InitializeException(e); |
|
488 |
} |
|
489 |
} |
|
490 |
|
|
491 |
/** |
|
492 |
* Gets <code>WMTSDataParameters</code> |
|
493 |
* @param parameters |
|
494 |
* @return |
|
495 |
*/ |
|
496 |
private OSMDataParameters getOSMParameters(DataStoreParameters parameters) { |
|
497 |
OSMDataParameters params = null; |
|
498 |
if(parameters instanceof OSMDataParameters) { |
|
499 |
params = (OSMDataParameters) parameters; |
|
500 |
} |
|
501 |
|
|
502 |
if(parameters instanceof TileDataParameters) { |
|
503 |
DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
|
504 |
if(p instanceof OSMDataParameters) { |
|
505 |
params = (OSMDataParameters) p; |
|
506 |
} |
|
507 |
} |
|
508 |
return params; |
|
509 |
} |
|
510 |
|
|
511 |
public Image getImageLegend() { |
|
512 |
return null; |
|
513 |
} |
|
514 |
|
|
515 |
public String getPathImage() { |
|
516 |
return null; |
|
517 |
} |
|
518 |
|
|
519 |
public FLayer cloneLayer() throws Exception { |
|
520 |
RasterDataStore ds = dataStore.cloneDataStore(); |
|
521 |
FLyrOSM newLayer = new FLyrOSM(); |
|
522 |
newLayer.setName(getName()); |
|
523 |
newLayer.setOpenRasterStore(ds); |
|
524 |
newLayer.firstLoad = firstLoad; |
|
525 |
|
|
526 |
List<RasterFilter> filters = getRender().getFilterList().getStatusCloned(); |
|
527 |
|
|
528 |
//Hacemos una copia de las bandas a renderizar |
|
529 |
ColorInterpretation ci = getRender().getRenderColorInterpretation(); |
|
530 |
if(ci != null) { |
|
531 |
newLayer.getRender().setRenderColorInterpretation(ci.cloneColorInterpretation()); |
|
532 |
} |
|
533 |
|
|
534 |
//Asignamos el entorno |
|
535 |
if(newLayer.getRender().getFilterList() == null) |
|
536 |
newLayer.getRender().setFilterList(RasterLocator.getManager().createEmptyFilterList(getRender().getFilterList().getInitDataType())); |
|
537 |
newLayer.getRender().getFilterList().setEnv(getRender().getFilterList().getEnv()); |
|
538 |
newLayer.getRender().getFilterList().setStatus(filters); |
|
539 |
|
|
540 |
// Asignamos los valores noData del original |
|
541 |
NoData nd = (NoData)getNoDataValue().clone(); |
|
542 |
newLayer.setNoDataValue(nd); |
|
543 |
newLayer.enableOpen(); |
|
544 |
|
|
545 |
return newLayer; |
|
546 |
} |
|
547 |
|
|
548 |
/** |
|
549 |
* Assigns the flag to delete this layer from the cache |
|
550 |
* @param selected |
|
551 |
*/ |
|
552 |
public void deleteCache(boolean deleteCache) { |
|
553 |
this.deleteCache = deleteCache; |
|
554 |
} |
|
555 |
} |
|
0 | 556 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/java/org/gvsig/raster/osm/app/osmclient/AddOSMLayerWizard.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.osm.app.osmclient; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.awt.Insets; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.event.MouseListener; |
|
30 |
import java.beans.PropertyVetoException; |
|
31 |
import java.io.File; |
|
32 |
import java.io.FileNotFoundException; |
|
33 |
import java.io.IOException; |
|
34 |
import java.net.MalformedURLException; |
|
35 |
import java.net.URISyntaxException; |
|
36 |
import java.net.URL; |
|
37 |
|
|
38 |
import javax.swing.JOptionPane; |
|
39 |
import javax.swing.JPanel; |
|
40 |
|
|
41 |
import org.cresques.cts.IProjection; |
|
42 |
|
|
43 |
import org.gvsig.andami.Launcher; |
|
44 |
import org.gvsig.andami.PluginServices; |
|
45 |
import org.gvsig.andami.PluginsLocator; |
|
46 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
47 |
import org.gvsig.app.ApplicationLocator; |
|
48 |
import org.gvsig.app.ApplicationManager; |
|
49 |
import org.gvsig.app.gui.WizardPanel; |
|
50 |
import org.gvsig.app.gui.wizards.WizardListener; |
|
51 |
import org.gvsig.app.gui.wizards.WizardListenerSupport; |
|
52 |
import org.gvsig.app.project.ProjectManager; |
|
53 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
54 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
55 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
56 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
57 |
import org.gvsig.fmap.crs.CRSFactory; |
|
58 |
import org.gvsig.fmap.dal.DALLocator; |
|
59 |
import org.gvsig.fmap.dal.DataParameters; |
|
60 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
61 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
62 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
63 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
|
64 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
65 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
66 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
67 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
68 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
69 |
import org.gvsig.raster.osm.app.osmclient.layer.FLyrOSM; |
|
70 |
import org.gvsig.raster.osm.io.OSMDataParameters; |
|
71 |
import org.gvsig.raster.osm.io.OSMProvider; |
|
72 |
import org.gvsig.raster.osm.swing.AddOSMLayerPanel; |
|
73 |
import org.gvsig.raster.osm.swing.OSMSwingLocator; |
|
74 |
|
|
75 |
import org.slf4j.Logger; |
|
76 |
import org.slf4j.LoggerFactory; |
|
77 |
|
|
78 |
/** |
|
79 |
* Wizard panel to add a new OSM raster layer |
|
80 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
81 |
*/ |
|
82 |
public class AddOSMLayerWizard extends WizardPanel implements MouseListener { |
|
83 |
private static final long serialVersionUID = 1L; |
|
84 |
private static final String TAB_NAME = "OSM"; |
|
85 |
private static Logger logger = LoggerFactory.getLogger(AddOSMLayerWizard.class.getName()); |
|
86 |
private AddOSMLayerPanel apiUI = null; |
|
87 |
private WizardListenerSupport listenerSupport = null; |
|
88 |
|
|
89 |
public AddOSMLayerWizard() { |
|
90 |
super(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* This method initializes this |
|
95 |
* |
|
96 |
* @return void |
|
97 |
*/ |
|
98 |
private void initialize() { |
|
99 |
setTabName(PluginServices.getText(this, TAB_NAME)); |
|
100 |
setLayout(new GridBagLayout()); |
|
101 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
102 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
103 |
gridBagConstraints.weightx = 1.0; |
|
104 |
gridBagConstraints.weighty = 1.0; |
|
105 |
gridBagConstraints.insets = new Insets(6, 6, 6, 6); |
|
106 |
|
|
107 |
boolean showCrsWarning = false; |
|
108 |
IProjection osmProjection = CRSFactory.getCRS("EPSG:3857"); |
|
109 |
if(getMapCtrl()!=null && !(getMapCtrl().getProjection().equals(osmProjection))){ |
|
110 |
showCrsWarning = true; |
|
111 |
} |
|
112 |
apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()),showCrsWarning); |
|
113 |
|
|
114 |
//Copying osmservers.properties |
|
115 |
if(!new File(apiUI.getPropertiesFilePath()).exists()) { |
|
116 |
File pluginFolder = PluginsLocator.getManager().getPluginsFolder(); |
|
117 |
File f = new File(pluginFolder.getAbsolutePath() + |
|
118 |
File.separator + |
|
119 |
"org.gvsig.raster.osm.app.osmclient" + |
|
120 |
File.separator + |
|
121 |
apiUI.getPropertiesFileName()); |
|
122 |
FileUtils utils = RasterLocator.getManager().getFileUtils(); |
|
123 |
try { |
|
124 |
utils.copyFile(f.getAbsolutePath(), Launcher.getAppHomeDir() + File.separator); |
|
125 |
apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()),showCrsWarning); |
|
126 |
} catch (FileNotFoundException e) { |
|
127 |
logger.info("File not found copying osmservers.properties", e); |
|
128 |
} catch (IOException e) { |
|
129 |
logger.info("Error copying osmservers.properties", e); |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
apiUI.addMouseListener(this); |
|
134 |
|
|
135 |
JPanel mainPanel = (JPanel)apiUI.getComponent(); |
|
136 |
add(mainPanel, gridBagConstraints); |
|
137 |
} |
|
138 |
|
|
139 |
private WizardListenerSupport getWizardListenerSupport() { |
|
140 |
if(listenerSupport == null) |
|
141 |
listenerSupport = new WizardListenerSupport(); |
|
142 |
return listenerSupport; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* This method checks for the options selected within the configuration |
|
147 |
* dialog are correct. |
|
148 |
* |
|
149 |
* @return true if you're done, false if not. |
|
150 |
*/ |
|
151 |
public boolean areSettingsValid() { |
|
152 |
return apiUI.areSettingsValid(); |
|
153 |
} |
|
154 |
|
|
155 |
public void addWizardListener(WizardListener listener) { |
|
156 |
getWizardListenerSupport().addWizardListener(listener); |
|
157 |
getWizardListenerSupport().callStateChanged(false); |
|
158 |
} |
|
159 |
|
|
160 |
public void removeWizardListener(WizardListener listener) { |
|
161 |
getWizardListenerSupport().removeWizardListener(listener); |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public void close() { |
|
166 |
|
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public void execute() { |
|
171 |
if(!apiUI.areSettingsValid()) { |
|
172 |
messageBoxInfo("server_not_selected", PluginServices.getMDIManager().getActiveWindow(), null); |
|
173 |
return; |
|
174 |
} |
|
175 |
|
|
176 |
try { |
|
177 |
TileDataParameters tileParams = createDataParameters(); |
|
178 |
|
|
179 |
//Getting the MapContext |
|
180 |
MapContext mapContext = getMapContext(); |
|
181 |
|
|
182 |
if(mapContext == null) { |
|
183 |
mapContext = createViewWindow(); |
|
184 |
} |
|
185 |
|
|
186 |
//Adding the layer |
|
187 |
FLyrOSM layer = buildLayer(tileParams); |
|
188 |
addLayerToMapContext(mapContext, layer); |
|
189 |
} catch (InitializeException e) { |
|
190 |
messageBoxInfo("error_creating_parameters", PluginServices.getMDIManager().getActiveWindow(), e); |
|
191 |
} catch (ProviderNotRegisteredException e) { |
|
192 |
messageBoxInfo("error_creating_parameters", PluginServices.getMDIManager().getActiveWindow(), e); |
|
193 |
} catch (LoadLayerException e) { |
|
194 |
messageBoxInfo("error_creating_the_view", PluginServices.getMDIManager().getActiveWindow(), e); |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
198 |
/** |
|
199 |
* Create the parameters to the provider |
|
200 |
* @return |
|
201 |
* @throws InitializeException |
|
202 |
* @throws ProviderNotRegisteredException |
|
203 |
*/ |
|
204 |
private TileDataParameters createDataParameters() throws InitializeException, ProviderNotRegisteredException { |
|
205 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
206 |
OSMDataParameters parameters = (OSMDataParameters)dataman.createStoreParameters(OSMProvider.NAME); |
|
207 |
URL selectedURL = null; |
|
208 |
try { |
|
209 |
selectedURL = apiUI.getSelectedURL(); |
|
210 |
} catch (MalformedURLException e) { |
|
211 |
throw new InitializeException(e); |
|
212 |
} |
|
213 |
try { |
|
214 |
parameters.setURI(selectedURL.toURI()); |
|
215 |
} catch (URISyntaxException e1) { |
|
216 |
logger.warn("Can't convert URI from "+selectedURL.toString(), e1); |
|
217 |
throw new InitializeException(e1); |
|
218 |
} |
|
219 |
parameters.setTileSuffix(apiUI.getSelectedFormat()); |
|
220 |
parameters.setOSMLayerName(apiUI.getSelectedName()); |
|
221 |
try { |
|
222 |
parameters.setNumberOfLevels(new Integer(apiUI.getSelectedLevel())); |
|
223 |
} catch (NumberFormatException e) { |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
TileDataParameters tileParams = (TileDataParameters) dataman.createStoreParameters("Tile Store"); |
|
228 |
tileParams.setDataParameters((DataParameters)parameters); |
|
229 |
return tileParams; |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* Adds the layer to the MapContext selected |
|
234 |
* @param mapContext |
|
235 |
* @param layer |
|
236 |
*/ |
|
237 |
private void addLayerToMapContext(MapContext mapContext, FLyrOSM layer) { |
|
238 |
mapContext.beginAtomicEvent(); |
|
239 |
layer.setVisible(true); |
|
240 |
mapContext.getLayers().addLayer(layer); |
|
241 |
mapContext.callLegendChanged(); |
|
242 |
mapContext.endAtomicEvent(); |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* Builds the OSM layer |
|
247 |
* @param tileParams |
|
248 |
* @return |
|
249 |
*/ |
|
250 |
private FLyrOSM buildLayer(TileDataParameters tileParams) { |
|
251 |
FLyrOSM layer = new FLyrOSM(); |
|
252 |
layer.deleteCache(false); //Esto es parametrizable |
|
253 |
try { |
|
254 |
layer.setParameters(tileParams); |
|
255 |
layer.setName(apiUI.getSelectedName()); |
|
256 |
} catch (InitializeException e) { |
|
257 |
messageBoxInfo("error_initializing_layer", PluginServices.getMDIManager().getActiveWindow(), e); |
|
258 |
} |
|
259 |
return layer; |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* Gets the active view or the first view opened if there is not |
|
264 |
* any with the focus |
|
265 |
* @return |
|
266 |
*/ |
|
267 |
public MapContext getMapContext() { |
|
268 |
IWindow window = PluginServices.getMDIManager().getFocusWindow(); |
|
269 |
if(window instanceof AbstractViewPanel) { |
|
270 |
return ((AbstractViewPanel)window).getMapControl().getMapContext(); |
|
271 |
} |
|
272 |
|
|
273 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
274 |
for (int i = 0; i < w.length; i++) { |
|
275 |
if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) { |
|
276 |
return ((AbstractViewPanel)w[i]).getMapControl().getMapContext(); |
|
277 |
} |
|
278 |
} |
|
279 |
return null; |
|
280 |
} |
|
281 |
|
|
282 |
private void messageBoxInfo(String msg, Object parentWindow, Exception exception) { |
|
283 |
LoggerFactory.getLogger(getClass()).debug(msg, exception); |
|
284 |
String string = PluginServices.getText(parentWindow, "accept"); |
|
285 |
Object[] options = {string}; |
|
286 |
JOptionPane.showOptionDialog((Component)/*PluginServices.getMainFrame()*/parentWindow, |
|
287 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>", |
|
288 |
PluginServices.getText(parentWindow, "confirmacion"), |
|
289 |
JOptionPane.OK_OPTION, |
|
290 |
JOptionPane.INFORMATION_MESSAGE, |
|
291 |
null, |
|
292 |
options, |
|
293 |
string); |
|
294 |
} |
|
295 |
|
|
296 |
/** |
|
297 |
* Create the view in the project. Add the blocks layer |
|
298 |
* to the view, and register the tool for get info of the |
|
299 |
* blocks. |
|
300 |
*/ |
|
301 |
@SuppressWarnings("deprecation") |
|
302 |
private MapContext createViewWindow() throws LoadLayerException { |
|
303 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
304 |
|
|
305 |
ProjectManager projectManager = application.getProjectManager(); |
|
306 |
|
|
307 |
// 1. Create a new view and set the name. |
|
308 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManagers(ViewManager.TYPENAME); |
|
309 |
ViewDocument view = (ViewDocument) viewManager.createDocument(); |
|
310 |
view.setName("OpenStreetMap View"); |
|
311 |
|
|
312 |
// 4. Add the view to the current project. |
|
313 |
projectManager.getCurrentProject().add(view); |
|
314 |
|
|
315 |
// 5. Force to show the view's window. |
|
316 |
IView viewWindow = (IView) viewManager.getMainWindow(view); |
|
317 |
|
|
318 |
application.getUIManager().addWindow(viewWindow, GridBagConstraints.CENTER); |
|
319 |
try { |
|
320 |
application.getUIManager().setMaximum((IWindow) viewWindow, true); |
|
321 |
} catch (PropertyVetoException e) { |
|
322 |
} |
|
323 |
|
|
324 |
if(viewWindow != null) { |
|
325 |
IProjection proj = CRSFactory.getCRS("EPSG:3857"); |
|
326 |
if(proj != null) |
|
327 |
viewWindow.getMapControl().setProjection(proj); |
|
328 |
return viewWindow.getMapControl().getMapContext(); |
|
329 |
} |
|
330 |
return null; |
|
331 |
} |
|
332 |
|
|
333 |
@Override |
|
334 |
public DataStoreParameters[] getParameters() { |
|
335 |
return null; |
|
336 |
} |
|
337 |
|
|
338 |
@Override |
|
339 |
public void initWizard() { |
|
340 |
initialize(); |
|
341 |
} |
|
342 |
|
|
343 |
public void mouseClicked(MouseEvent e) { |
|
344 |
|
|
345 |
} |
|
346 |
|
|
347 |
public void mouseEntered(MouseEvent e) { |
|
348 |
|
|
349 |
} |
|
350 |
|
|
351 |
public void mouseExited(MouseEvent e) { |
|
352 |
|
|
353 |
} |
|
354 |
|
|
355 |
public void mousePressed(MouseEvent e) { |
|
356 |
getWizardListenerSupport().callStateChanged(true); |
|
357 |
} |
|
358 |
|
|
359 |
public void mouseReleased(MouseEvent e) { |
|
360 |
|
|
361 |
} |
|
362 |
} |
|
0 | 363 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/java/org/gvsig/raster/osm/app/osmclient/OSMServer.java | ||
---|---|---|
1 |
/* OSM layers for gvSIG. |
|
2 |
* Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2012 Nacho Brodin |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.osm.app.osmclient; |
|
23 |
|
|
24 |
/** |
|
25 |
* Fixed parameters for a Open Street Map server. These parameters |
|
26 |
* are known for each server added. |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class OSMServer { |
|
31 |
private String serverURL = null; |
|
32 |
private int levels = 0; |
|
33 |
private String name = null; |
|
34 |
private String suffix = null; |
|
35 |
|
|
36 |
/** |
|
37 |
* Constructor |
|
38 |
* @param server |
|
39 |
* The server URL |
|
40 |
* @param levels |
|
41 |
* The number of resolution levels |
|
42 |
* @param name |
|
43 |
* Layer's name |
|
44 |
* @param suffix |
|
45 |
* The suffix of the image file. |
|
46 |
* |
|
47 |
*/ |
|
48 |
public OSMServer(String server, int levels, String name, String suffix) { |
|
49 |
this.serverURL = server; |
|
50 |
this.levels = levels; |
|
51 |
this.name = name; |
|
52 |
this.suffix = suffix; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Gets the server URL |
|
57 |
* @return |
|
58 |
*/ |
|
59 |
public String getServerURL() { |
|
60 |
return serverURL; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Gets the number of resolution levels |
|
65 |
* @return |
|
66 |
*/ |
|
67 |
public int getLevels() { |
|
68 |
return levels; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Gets the layer's name |
|
73 |
* @return |
|
74 |
*/ |
|
75 |
public String getName() { |
|
76 |
return name; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the suffix of the image file. |
|
81 |
* This suffix depends on the kind of the image (tif, png, jpg,...) |
|
82 |
* @return |
|
83 |
*/ |
|
84 |
public String getSuffix() { |
|
85 |
return suffix; |
|
86 |
} |
|
87 |
|
|
88 |
public String toString() { |
|
89 |
return name; |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.raster.osm/tags/org.gvsig.raster.osm-2.2.246/org.gvsig.raster.osm.app.osmclient/src/main/java/org/gvsig/raster/osm/app/osmclient/OSMClientExtension.java | ||
---|---|---|
1 |
/* OSM layers for gvSIG. |
|
2 |
* Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2012 Nacho Brodin |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.osm.app.osmclient; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import javax.swing.JOptionPane; |
|
27 |
import org.gvsig.andami.IconThemeHelper; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.app.extension.AddLayer; |
|
30 |
import org.gvsig.fmap.dal.DataParameters; |
|
31 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
32 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
33 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
34 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
35 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
37 |
import org.gvsig.i18n.Messages; |
|
38 |
import org.gvsig.raster.osm.app.osmclient.layer.FLyrOSM; |
|
39 |
import org.gvsig.raster.osm.io.OSMDataParameters; |
|
40 |
import org.gvsig.tools.util.Factory; |
|
41 |
|
|
42 |
/** |
|
43 |
* Extension for adding open street map support to gvSIG. |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
*/ |
|
46 |
public class OSMClientExtension extends Extension { |
|
47 |
// private Logger log = LoggerFactory.getLogger(OSMClientExtension.class); |
|
48 |
private String fileCheck = System.getProperty("user.home") + File.separator + "gvSIG" + File.separator + "osm_epsg_error"; |
|
49 |
private String epsgCode = "3857"; |
|
50 |
|
|
51 |
public void initialize() { |
|
52 |
/* |
|
53 |
#Thu May 23 15:49:23 CEST 2013 |
|
54 |
Map_Quest=Map Quest*http\://oatile1.mqcdn.com/tiles/1.0.0/map*20*png |
|
55 |
Stamen=Stamen*http\://a.tile.stamen.com/terrain*17*jpg |
|
56 |
Open_Cycle_Map=Open Cycle Map*http\://tile.opencyclemap.org/cycle/*16*png |
|
57 |
Stamen_Toner=Stamen Toner*http\://tile.stamen.com/toner*17*jpg |
|
58 |
Map_Quest_Open_Aerial=Map Quest Open Aerial*http\://otile1.mqcdn.com/tiles/1.0.0/sat*20*jpg |
|
59 |
Mapnik=Mapnik*http\://tile.openstreetmap.org/*18*png |
|
60 |
Stamen_Water_Color=Stamen Water Color*http\://tile.stamen.com/watercolor*17*jpg |
|
61 |
*/ |
|
62 |
|
|
63 |
IconThemeHelper.registerIcon(null, "icon-layer-osm", this); |
|
64 |
} |
|
65 |
|
|
66 |
private static class OSMLayerFactory implements Factory<FLayer> { |
|
67 |
@Override |
|
68 |
public String getName() { |
|
69 |
return FLyrOSM.class.getName(); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public FLayer create(Object... os) { |
|
74 |
try { |
|
75 |
DataStoreParameters parameters = (DataStoreParameters) os[0]; |
|
76 |
if (parameters instanceof OSMDataParameters) { |
|
77 |
FLyrOSM layer = new FLyrOSM(); |
|
78 |
layer.setParameters(parameters); |
|
79 |
return layer; |
|
80 |
} |
|
81 |
if (parameters instanceof TileDataParameters) { |
|
82 |
DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
|
83 |
if (p instanceof OSMDataParameters) { |
|
84 |
FLyrOSM layer = new FLyrOSM(); |
|
85 |
layer.setParameters(parameters); |
|
86 |
return layer; |
|
87 |
} |
|
88 |
} |
|
89 |
} catch (InitializeException ex) { |
|
90 |
logger.warn("Can't initialize OSMLayer", ex); |
|
91 |
} |
|
92 |
return null; |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
public void postInitialize() { |
|
98 |
FLyrOSM.registerPersistent(); |
|
99 |
// addAboutInfo(); |
|
100 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
|
101 |
mapContextManager.registerLayer(new OSMLayerFactory()); |
|
102 |
|
|
103 |
AddLayer.addWizard(AddOSMLayerWizard.class); |
|
104 |
// loadEpsgCodeInJCRSUserDatabase(); |
|
105 |
} |
|
106 |
|
|
107 |
/* |
|
108 |
private void loadEpsgCodeInJCRSUserDatabase() { |
|
109 |
IProjection proj = null; |
|
110 |
try { |
|
111 |
proj = CRSFactory.getCRS("EPSG:" + epsgCode); |
|
112 |
} catch(Exception e) { |
|
113 |
} |
|
114 |
|
|
115 |
if(proj != null) |
|
116 |
return; |
|
117 |
|
|
118 |
String wkt = "'PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"Popular Visualisation CRS\",DATUM[\"D_Popular_Visualisation_Datum\",SPHEROID[\"Popular_Visualisation_Sphere\",6378137,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Mercator\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]'"; |
|
119 |
try { |
|
120 |
es.idr.teledeteccion.connection.EpsgConnection conn = new es.idr.teledeteccion.connection.EpsgConnection(); |
|
121 |
conn.setConnectionUsr(); |
|
122 |
|
|
123 |
String query = "SELECT usr_code FROM USR WHERE usr_code='" + epsgCode + "'"; |
|
124 |
ResultSet result = es.idr.teledeteccion.connection.Query.select(query, conn.getConnection()); |
|
125 |
|
|
126 |
//Si no existe en c�digo se inserta para que la proyecci�n est� disponible |
|
127 |
|
|
128 |
if(result == null || !result.next()) { |
|
129 |
String sentence = "INSERT INTO USR VALUES(" + epsgCode + ", " + wkt + ",'WGS 84 / Pseudo-Mercator','Usuario2','Popular_Visualisation_Datum')"; |
|
130 |
conn.update(sentence); |
|
131 |
conn.shutdown(); |
|
132 |
} |
|
133 |
} catch (Throwable e) { |
|
134 |
File f = new File(fileCheck); |
|
135 |
if(!f.exists()) |
|
136 |
messageErrorEpsg("error_loading_epsg", f); |
|
137 |
log.info("Error accediendo a JCRS", e); |
|
138 |
return; |
|
139 |
} |
|
140 |
} |
|
141 |
*/ |
|
142 |
|
|
143 |
public void messageErrorEpsg(String msg, File f) { |
|
144 |
String string1 = Messages.getText("dont_remind_me_anymore"); |
|
145 |
String string2 = Messages.getText("ok"); |
|
146 |
Object[] options = {string1, string2}; |
|
147 |
int n = JOptionPane.showOptionDialog(null, |
|
148 |
"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>", |
|
149 |
Messages.getText("confirmacion"), |
|
150 |
JOptionPane.YES_NO_OPTION, |
|
151 |
JOptionPane.QUESTION_MESSAGE, |
|
152 |
null, |
|
153 |
options, |
|
154 |
string1); |
|
155 |
if (n == 0) { |
|
156 |
try { |
|
157 |
f.createNewFile(); |
|
158 |
} catch (IOException e) { |
|
159 |
} |
Also available in: Unified diff