Revision 9689
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/buildNumber.properties | ||
---|---|---|
1 |
#Fri Jul 12 18:09:33 CEST 2019 |
|
2 |
buildNumber=129 |
|
0 | 3 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/test/java/org/gvsig/raster/app/extension/wmtsclient/gui/dialog/TestPropsDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.app.extension.wmtsclient.gui.dialog; |
|
20 |
|
|
21 |
import javax.swing.JFrame; |
|
22 |
|
|
23 |
import org.gvsig.raster.wmts.app.wmtsclient.gui.wizard.WMTSPropsDialog; |
|
24 |
|
|
25 |
public class TestPropsDialog { |
|
26 |
private int w = 510; |
|
27 |
private int h = 610; |
|
28 |
private JFrame frame = new JFrame(); |
|
29 |
private WMTSPropsDialog desc = null; |
|
30 |
|
|
31 |
public TestPropsDialog() { |
|
32 |
desc = new WMTSPropsDialog(); |
|
33 |
frame.getContentPane().add(desc); |
|
34 |
frame.setSize(w, h); |
|
35 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
36 |
frame.setVisible(true); |
|
37 |
} |
|
38 |
|
|
39 |
public static void main(String[] args) { |
|
40 |
new TestPropsDialog(); |
|
41 |
} |
|
42 |
} |
|
0 | 43 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/test/java/org/gvsig/raster/wmts/io/TestWMTSDriver.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.wmts.io; |
|
23 |
|
|
24 |
import java.net.MalformedURLException; |
|
25 |
import java.net.URL; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
28 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
29 |
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceIdentification; |
|
30 |
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceProvider; |
|
31 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
35 |
*/ |
|
36 |
public class TestWMTSDriver extends AbstractLibraryAutoInitTestCase { |
|
37 |
|
|
38 |
protected void doSetUp() throws Exception { |
|
39 |
System.err.println("TestWMTSDriver running..."); |
|
40 |
} |
|
41 |
|
|
42 |
public void testStack() { |
|
43 |
|
|
44 |
URL url = null; |
|
45 |
try { |
|
46 |
url = new URL("http://v2.suite.opengeo.org/geoserver/gwc/service/wmts/"); |
|
47 |
|
|
48 |
//Crea el manejador para la versi?n del servidor y devuelve la versi?n |
|
49 |
//WMTSConnector conn = WMTSDriver.getConnectorFromURL(url); |
|
50 |
//String version = conn.getVersion(); |
|
51 |
|
|
52 |
//Creamos un explorer para obtener los datos del servidor |
|
53 |
WMTSServerExplorerParameters.registerDynClass(); |
|
54 |
WMTSServerExplorerParameters param = new WMTSServerExplorerParameters(); |
|
55 |
param.setHost(url.toString()); |
|
56 |
WMTSServerExplorer explorer = new WMTSServerExplorer(param, null); |
|
57 |
explorer.connect(null); |
|
58 |
|
|
59 |
WMTSServiceIdentification id = explorer.getOGCClient().getServiceIdentification(); |
|
60 |
String title = id.getTitle(); |
|
61 |
String version = id.getServiceTypeVersion(); |
|
62 |
String type = id.getServiceType(); |
|
63 |
|
|
64 |
WMTSServiceProvider prov = explorer.getOGCClient().getServiceProvider(); |
|
65 |
String pN = prov.getProviderName(); |
|
66 |
String pS = prov.getProviderSite(); |
|
67 |
String pC = prov.getServiceContact(); |
|
68 |
|
|
69 |
//WMTSThemes themes = explorer.getThemes(); |
|
70 |
System.out.println("Title: " + title); |
|
71 |
System.out.println("Version: " + version); |
|
72 |
System.out.println("Type: " + type); |
|
73 |
System.out.println("Provider Name: " + pN); |
|
74 |
System.out.println("Provider Site: " + pS); |
|
75 |
System.out.println("Service Contact: " + pC); |
|
76 |
|
|
77 |
//En este caso solo hay una lista de temas con una capa por cada uno |
|
78 |
//pero en un caso corriente seria un ?rbol de themas con una capa asociada a cada uno |
|
79 |
/*for (int i = 0; i < themes.size(); i++) { |
|
80 |
WMTSLayer layer = ((WMTSTheme)themes.get(i)).getLayer(); |
|
81 |
if(layer != null) |
|
82 |
layer.print(); |
|
83 |
}*/ |
|
84 |
|
|
85 |
} catch (MalformedURLException e) { |
|
86 |
e.printStackTrace(); |
|
87 |
} catch (InitializeException e) { |
|
88 |
e.printStackTrace(); |
|
89 |
} catch (ConnectException e) { |
|
90 |
e.printStackTrace(); |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
94 |
} |
|
0 | 95 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/resources-plugin/text_en.properties | ||
---|---|---|
1 |
WMTSLayer=WMTS Layer |
|
2 |
select_info_formats=Select text formats for Info by point |
|
3 |
wmts_properties=WMTS Properties |
|
4 |
wmts_cant_connect=The connection cannot be established |
|
5 |
wmts_not_queryable=This server does not accept this kind of requests |
|
6 |
wmts_server_error=Error in WMTS Server |
|
7 |
wmts_transparency=Transparency |
|
8 |
WMTSLayer=WMTS Layer |
|
9 |
fit_WMTS_layer=Fits to WTMS layer |
|
10 |
invert_axis_order=Invert the order of the axes |
|
11 |
cache_refresh=This check has to be enabled before press the connect button.\n If the layer was loaded with this check in other status it is possible that the cache not to be correct. \n. Clean the cache before continue. |
|
12 |
view_type=View type |
|
13 |
layerlist_view_selection=View as layers list |
|
14 |
themes_view_selection=View as themes |
|
15 |
view_not_disposable=There are not themes defined in this server |
|
16 |
theme_without_reference=Theme without layer referenced.\n Select from the list of layers. |
|
17 |
host_unreachable=The host is unreachable. Maybe the network is not connected or the host off. |
|
18 |
ip_unknown=IP address unknown |
|
19 |
network_error=Error with the network connection |
|
0 | 20 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/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.wmts.app.wmtsclient.WMTSClientExtension" |
|
8 |
description="Support to access WMTS" |
|
9 |
active="true" |
|
10 |
priority="1"> |
|
11 |
<!-- Estas tools se pusieron para pruebas. |
|
12 |
Habilitan dos botones para llevar al siguiente/anterior nivel de resoluci?n |
|
13 |
<tool-bar name="ZoomMas" position="5"> |
|
14 |
<action-tool icon="level-plus" action-command="NEXT_LEVEL" tooltip="Zoom_next_level" position="1"/> |
|
15 |
</tool-bar> |
|
16 |
<tool-bar name="ZoomMenos" position="5"> |
|
17 |
<action-tool icon="level-less" action-command="PREV_LEVEL" tooltip="Zoom_prev_level" position="2"/> |
|
18 |
</tool-bar> |
|
19 |
--> |
|
20 |
</extension> |
|
21 |
</extensions> |
|
22 |
</plugin-config> |
|
0 | 23 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/resources-plugin/servers.properties | ||
---|---|---|
1 |
server[0]=http://v2.suite.opengeo.org/geoserver/gwc/service/wmts/ |
|
2 |
server[1]=http://maps.opengeo.org/geowebcache/service/wmts |
|
0 | 3 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/resources-plugin/about/wmts-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 WMTS para gvSIG</h2> |
|
9 |
<p><b>Prodevelop S.L.</b> ha incorporado el soporte al formato WMTS para el proyecto de Espa?a Virtual</p> |
|
10 |
|
|
11 |
<p><b>Desarrollo:</b></p> |
|
12 |
|
|
13 |
<p>Director del proyecto:</p> |
|
14 |
<ul> |
|
15 |
<li>Miguel Montesinos Lajara</li> |
|
16 |
</ul> |
|
17 |
<p>Equipo de desarrollo:</p> |
|
18 |
<ul> |
|
19 |
<li>Nacho Brodin</li> |
|
20 |
</ul> |
|
21 |
|
|
22 |
<p>Build Number de la extensión: 1</p> |
|
23 |
<center> |
|
24 |
<p><b><a href="http://www.prodevelop.es" title="Prodevelop">http://www.prodevelop.es</a></b></p> |
|
25 |
</center> |
|
26 |
|
|
27 |
</body> |
|
28 |
</html> |
|
0 | 29 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.raster.wmts.app.wmstclient. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.raster.wmts.app.wmtsclient"> |
|
9 |
<description>Persistence definition for the WMTS client plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="servers" type="object" classOfValue="org.gvsig.andami.persistence.serverData.ServerDataPersistence" mandatory="false"> |
|
12 |
<description>List of WMTS servers</description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
</classes> |
|
17 |
</definitions> |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/resources-plugin/text.properties | ||
---|---|---|
1 |
WMTSLayer=Capa WMTS |
|
2 |
select_info_formats=Seleccionar formatos de texto (Info) |
|
3 |
wmts_properties=Propiedades WMTS |
|
4 |
wmts_cant_connect=No ha sido posible realizar la conexi\u00f3n con el servidor WMTS |
|
5 |
wmts_not_queryable=Este servidor no acepta peticiones de este tipo |
|
6 |
wmts_server_error=Error del servidor WMTS |
|
7 |
wmts_transparency=Transparencia |
|
8 |
WMTSLayer=Capa WMTS |
|
9 |
fit_WMTS_layer=Ajustar capa WMTS |
|
10 |
invert_axis_order=Invertir orden de los ejes |
|
11 |
cache_refresh=Este check debe estar activado antes de pulsar el bot?n de conectar.\n Si la capa fue cargada previamente con este check box\n en distinta posici?n es posible que el contenido de la cach? sea erroneo \n. Limpiela antes de continuar. |
|
12 |
view_type=Tipo de vista |
|
13 |
layerlist_view_selection=Ver como lista de capas |
|
14 |
themes_view_selection=Ver como temas |
|
15 |
view_not_disposable=No hay themas definidos en este servidor |
|
16 |
theme_without_reference=Tema sin capa referenciada. \n Selecciona desde la lista de capas. |
|
17 |
host_unreachable=No se puede conectar con el servidor. Tal vez la red est? desconectada o el servidor apagado. |
|
18 |
ip_unknown=Direcci?n IP desconocida |
|
19 |
network_error=Error en la conexi?n a red |
|
0 | 20 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/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.wmts.app.wmtsclient:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.wmts.io:jar</include> |
|
34 |
<include>org.gvsig:org.gvsig.raster.wmts.ogc.api:jar</include> |
|
35 |
<include>org.gvsig:org.gvsig.raster.wmts.ogc.impl:jar</include> |
|
36 |
<include>org.gvsig:org.gvsig.raster.wmts.swing.api:jar</include> |
|
37 |
<include>org.gvsig:org.gvsig.raster.wmts.swing.impl:jar</include> |
|
38 |
</includes> |
|
39 |
</dependencySet> |
|
40 |
</dependencySets> |
|
41 |
</assembly> |
|
0 | 42 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/gui/wizard/WMTSWizard.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 |
|
|
23 |
package org.gvsig.raster.wmts.app.wmtsclient.gui.wizard; |
|
24 |
|
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.io.File; |
|
30 |
import java.io.FileInputStream; |
|
31 |
import java.io.FileNotFoundException; |
|
32 |
import java.io.IOException; |
|
33 |
import java.net.MalformedURLException; |
|
34 |
import java.net.URL; |
|
35 |
import java.util.ArrayList; |
|
36 |
import java.util.List; |
|
37 |
import java.util.Properties; |
|
38 |
import java.util.prefs.Preferences; |
|
39 |
|
|
40 |
import javax.swing.JOptionPane; |
|
41 |
|
|
42 |
import org.apache.commons.io.IOUtils; |
|
43 |
import org.cresques.cts.IProjection; |
|
44 |
import org.gvsig.andami.PluginServices; |
|
45 |
import org.gvsig.andami.PluginsLocator; |
|
46 |
import org.gvsig.andami.PluginsManager; |
|
47 |
import org.gvsig.andami.persistence.serverData.ServerDataPersistence; |
|
48 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
49 |
import org.gvsig.app.gui.WizardPanel; |
|
50 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
51 |
import org.gvsig.compat.net.ICancellable; |
|
52 |
import org.gvsig.fmap.dal.DALLocator; |
|
53 |
import org.gvsig.fmap.dal.DataManager; |
|
54 |
import org.gvsig.fmap.dal.DataParameters; |
|
55 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
56 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
57 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
58 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
59 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
60 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
61 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
62 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
63 |
import org.gvsig.gui.beans.Messages; |
|
64 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
65 |
import org.gvsig.raster.wmts.app.wmtsclient.WMTSClientExtension; |
|
66 |
import org.gvsig.raster.wmts.app.wmtsclient.layer.FLyrWMTS; |
|
67 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
68 |
import org.gvsig.raster.wmts.io.WMTSServerExplorer; |
|
69 |
import org.gvsig.raster.wmts.io.WMTSServerExplorerParameters; |
|
70 |
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceIdentification; |
|
71 |
import org.gvsig.raster.wmts.swing.AddServerPanel; |
|
72 |
import org.gvsig.raster.wmts.swing.NextPrevPanel; |
|
73 |
import org.gvsig.raster.wmts.swing.WMTSSwingLocator; |
|
74 |
import org.gvsig.raster.wmts.swing.WMTSWizardListener; |
|
75 |
import org.gvsig.raster.wmts.swing.WmtsGUI; |
|
76 |
import org.gvsig.tools.dynobject.DynObject; |
|
77 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
78 |
import org.slf4j.Logger; |
|
79 |
import org.slf4j.LoggerFactory; |
|
80 |
|
|
81 |
/** |
|
82 |
* The WMTS properties container panel. |
|
83 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
84 |
*/ |
|
85 |
@SuppressWarnings({ "unused", "deprecation" }) |
|
86 |
public class WMTSWizard extends WizardPanel implements ActionListener { |
|
87 |
private static final long serialVersionUID = 1L; |
|
88 |
private static Logger logger = LoggerFactory.getLogger(WMTSWizard.class); |
|
89 |
private String pluginName = "org.gvsig.raster.wmts.app.wmtsclient"; |
|
90 |
private File pluginPersistenceFile = null; |
|
91 |
private File serverPropertiesFile = null; |
|
92 |
private ServerDataPersistence serverDataPersistence = null; |
|
93 |
private String serversPropsFilename = "servers.properties"; |
|
94 |
|
|
95 |
protected int page = 0; |
|
96 |
protected boolean connected = false; |
|
97 |
private AddServerPanel serverPanel = null; |
|
98 |
private NextPrevPanel nextPrevPanel = null; |
|
99 |
protected WmtsGUI wmtsParamsPanel = null; |
|
100 |
|
|
101 |
private WMTSWizardListenerImpl listenerSupport = null; |
|
102 |
private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wmts-wizard" ); |
|
103 |
private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false); |
|
104 |
protected int firstPage = 0; |
|
105 |
private IProjection proj = null; |
|
106 |
private ICancellable cancel = null; |
|
107 |
private WMTSDataParameters storeParams = null; |
|
108 |
private WMTSServerExplorer explorer = null; |
|
109 |
|
|
110 |
private PluginServices plugin = null; |
|
111 |
|
|
112 |
public class WMTSWizardListenerImpl implements WMTSWizardListener { |
|
113 |
|
|
114 |
public void correctlyConfiguredEvent(boolean finishable) { |
|
115 |
callStateChanged(finishable); |
|
116 |
} |
|
117 |
|
|
118 |
public void addLayerEvent() { |
|
119 |
activarVisualizarBotones(); |
|
120 |
} |
|
121 |
|
|
122 |
public void removeLayerEvent() { |
|
123 |
activarVisualizarBotones(); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* This is the default constructor |
|
129 |
*/ |
|
130 |
public WMTSWizard() { |
|
131 |
super(); |
|
132 |
firstPage = 0; |
|
133 |
page = firstPage; |
|
134 |
initialize(); |
|
135 |
|
|
136 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
|
137 |
for (int i = 0; i < windows.length; i++) { |
|
138 |
if(windows[i] instanceof AbstractViewPanel) |
|
139 |
proj = ((AbstractViewPanel)windows[i]).getProjection(); |
|
140 |
} |
|
141 |
cancel = new CancelTaskImpl(); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* This method initializes this |
|
146 |
*/ |
|
147 |
private void initialize() { |
|
148 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
149 |
this.plugin = pluginsManager.getPlugin(WMTSClientExtension.class); |
|
150 |
|
|
151 |
setTabName("WMTS"); |
|
152 |
setLayout(new GridBagLayout()); |
|
153 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
154 |
gridBagConstraints1.fill = GridBagConstraints.BOTH; |
|
155 |
gridBagConstraints1.weightx = 1.0; |
|
156 |
gridBagConstraints1.weighty = 1.0; |
|
157 |
gridBagConstraints1.insets = new java.awt.Insets(2, 12, 10, 12); |
|
158 |
|
|
159 |
setVisible(true); |
|
160 |
add(getIserverPanel(), gridBagConstraints1); |
|
161 |
|
|
162 |
gridBagConstraints1.insets = new java.awt.Insets(2, 0, 10, 0); |
|
163 |
add(getPanelPage2(), gridBagConstraints1); |
|
164 |
gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; |
|
165 |
gridBagConstraints1.anchor = GridBagConstraints.EAST; |
|
166 |
gridBagConstraints1.weighty = 0; |
|
167 |
gridBagConstraints1.gridy = 1; |
|
168 |
add(getNextPrevPanel(), gridBagConstraints1); |
|
169 |
activarVisualizarBotones(); |
|
170 |
getIserverPanel().getTxtHost().setServerList(getServerDataPersistence().getArrayOfServerData()); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* This method checks for the options selected within the configuration |
|
175 |
* dialog are correct. |
|
176 |
* |
|
177 |
* @return true if you're done, false if not. |
|
178 |
*/ |
|
179 |
public boolean areSettingsValid() { |
|
180 |
return getPanelPage2().isCorrectlyConfigured(); |
|
181 |
} |
|
182 |
|
|
183 |
private WMTSWizardListenerImpl getWizardListenerSupport() { |
|
184 |
if(listenerSupport == null) { |
|
185 |
listenerSupport = new WMTSWizardListenerImpl(); |
|
186 |
} |
|
187 |
return listenerSupport; |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Thread to connect to a WMTS server |
|
192 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
193 |
*/ |
|
194 |
public class ConnectThread extends Thread { |
|
195 |
private ICancellable cancel = null; |
|
196 |
private WMTSServerExplorer explorer = null; |
|
197 |
private WMTSWizard wizard = null; |
|
198 |
|
|
199 |
public ConnectThread(ICancellable cancel, WMTSServerExplorer explorer, WMTSWizard wizard) { |
|
200 |
this.cancel = cancel; |
|
201 |
this.explorer = explorer; |
|
202 |
this.wizard = wizard; |
|
203 |
} |
|
204 |
|
|
205 |
public void run() { |
|
206 |
if(!checkHostAndNetwork()) |
|
207 |
return; |
|
208 |
|
|
209 |
try { |
|
210 |
explorer.connect(cancel); |
|
211 |
saveServerListFromComboBox(); |
|
212 |
} catch (ConnectException e) { |
|
213 |
getIserverPanel().setTextInfo("Connection closed... \n" + e.getMessage()); |
|
214 |
JOptionPane.showMessageDialog(null, Messages.getText("wmts_cant_connect"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
|
215 |
return; |
|
216 |
} finally { |
|
217 |
((CancelTaskImpl)cancel).setCanceled(false); |
|
218 |
} |
|
219 |
|
|
220 |
DataStoreParameters parameters = explorer.getStoredParameters(); |
|
221 |
if(parameters instanceof WMTSDataParameters) { |
|
222 |
storeParams = (WMTSDataParameters) parameters; |
|
223 |
} |
|
224 |
|
|
225 |
if(parameters instanceof TileDataParameters) { |
|
226 |
DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
|
227 |
if(p instanceof WMTSDataParameters) |
|
228 |
storeParams = (WMTSDataParameters) p; |
|
229 |
} |
|
230 |
|
|
231 |
wizard.rellenarControles(); |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Checks if the network and host are reachable |
|
237 |
* @return true if both are reachable and false if they are not |
|
238 |
*/ |
|
239 |
private boolean checkHostAndNetwork() { |
|
240 |
if(!explorer.isHostReachable()) { |
|
241 |
JOptionPane.showMessageDialog(null, Messages.getText("host_unreachable"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
|
242 |
getIserverPanel().setTextInfo("Connection closed... \n"); |
|
243 |
return false; |
|
244 |
} |
|
245 |
return true; |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* DOCUMENT ME! |
|
250 |
*/ |
|
251 |
private void rellenarControles() { |
|
252 |
try { |
|
253 |
String host = getIserverPanel().getTxtHost().getModel().getSelectedItem().toString(); |
|
254 |
WMTSServiceIdentification id = explorer.getOGCClient().getServiceIdentification(); |
|
255 |
|
|
256 |
getIserverPanel().setTitle(id.getTitle()); |
|
257 |
getNextPrevPanel().getJLabelServerTypeValue().setText(id.getServiceType()); |
|
258 |
getIserverPanel().setTextInfo(id.getAbstract()); |
|
259 |
|
|
260 |
getPanelPage2().setWizardData(explorer); |
|
261 |
connected = true; |
|
262 |
activarVisualizarBotones(); |
|
263 |
} catch (Exception e) { |
|
264 |
if (e.getMessage() == null) { |
|
265 |
getIserverPanel().setTextInfo(Messages.getText("error")); |
|
266 |
} else { |
|
267 |
getIserverPanel().setTextInfo(e.getMessage()); |
|
268 |
} |
|
269 |
getNextPrevPanel().getBtnNext().setEnabled(false); |
|
270 |
getNextPrevPanel().getBtnPrev().setEnabled(true); |
|
271 |
} finally { |
|
272 |
getIserverPanel().getBtnCancel().setEnabled(false); |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
public void actionPerformed(ActionEvent e) { |
|
277 |
if(e.getSource() == getIserverPanel().getBtnConnect()) { |
|
278 |
getIserverPanel().getBtnCancel().setEnabled(true); |
|
279 |
getIserverPanel().setTextInfo("Trying to connect..."); |
|
280 |
|
|
281 |
String host = getIserverPanel().getTxtHost().getModel().getSelectedItem().toString(); |
|
282 |
try { |
|
283 |
DataManager datamanager = DALLocator.getDataManager(); |
|
284 |
WMTSServerExplorerParameters explorerParams = (WMTSServerExplorerParameters) datamanager.createServerExplorerParameters(WMTSServerExplorer.NAME); |
|
285 |
explorerParams.setHost(host); |
|
286 |
explorerParams.setLongitudeFirst(getIserverPanel().getChkInvertAxisOrder().isSelected()); |
|
287 |
|
|
288 |
explorer = (WMTSServerExplorer) datamanager.createServerExplorer(explorerParams); |
|
289 |
|
|
290 |
((CancelTaskImpl)cancel).setCanceled(false); |
|
291 |
new ConnectThread(cancel, explorer, this).start(); |
|
292 |
|
|
293 |
} catch (InitializeException e1) { |
|
294 |
getIserverPanel().setTextInfo("Error creating WMTS layer"); |
|
295 |
} catch (ProviderNotRegisteredException e1) { |
|
296 |
getIserverPanel().setTextInfo("Provider not registered. I cannot connect."); |
|
297 |
} catch (ValidateDataParametersException e1) { |
|
298 |
getIserverPanel().setTextInfo("Parameters not valid. I cannot connect."); |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
if(e.getSource() == getIserverPanel().getBtnCancel()) { |
|
303 |
getIserverPanel().setTextInfo("Cancelled..."); |
|
304 |
((CancelTaskImpl)cancel).setCanceled(true); |
|
305 |
getIserverPanel().getBtnCancel().setEnabled(false); |
|
306 |
} |
|
307 |
|
|
308 |
if(e.getSource() == getNextPrevPanel().getBtnPrev()) { |
|
309 |
page --; |
|
310 |
if (page > firstPage) { |
|
311 |
getPanelPage2().setPreviousTab(); |
|
312 |
page = getPanelPage2().currentPage() + 1; |
|
313 |
activarVisualizarBotones(); |
|
314 |
} else if (page == firstPage){ |
|
315 |
activarVisualizarBotones(); |
|
316 |
page = firstPage +1; |
|
317 |
getIserverPanel().setTitle("-"); |
|
318 |
getIserverPanel().setTextInfo(""); |
|
319 |
getPanelPage2().setPreviousTab(); |
|
320 |
getIserverPanel().setVisible(true); |
|
321 |
getPanelPage2().setVisible(false); |
|
322 |
getNextPrevPanel().getBtnNext().setEnabled(false); |
|
323 |
connected = false; |
|
324 |
} |
|
325 |
//getWizardListenerSupport().callStateChanged(getPanelPage2().isCorrectlyConfigured()); |
|
326 |
} |
|
327 |
|
|
328 |
if(e.getSource() == getNextPrevPanel().getBtnNext()) { |
|
329 |
if (page > firstPage) { |
|
330 |
// si page es mayor que cero, vamos enfocando las |
|
331 |
// sucesivas SOLAPAS del WMTSParamsPanel |
|
332 |
getPanelPage2().setNextTab(); |
|
333 |
page = getPanelPage2().currentPage(); |
|
334 |
} |
|
335 |
page++; |
|
336 |
getIserverPanel().setVisible(false); |
|
337 |
getPanelPage2().setVisible(true); |
|
338 |
activarVisualizarBotones(); |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
private AddServerPanel getIserverPanel() { |
|
343 |
if (serverPanel == null) { |
|
344 |
serverPanel = WMTSSwingLocator.getSwingManager().createAddServerPanel(); |
|
345 |
serverPanel.getBtnCancel().addActionListener(this); |
|
346 |
serverPanel.getBtnConnect().addActionListener(this); |
|
347 |
} |
|
348 |
return serverPanel; |
|
349 |
} |
|
350 |
|
|
351 |
/** |
|
352 |
* This method initializes jPanel |
|
353 |
* |
|
354 |
* @return javax.swing.JPanel |
|
355 |
*/ |
|
356 |
public NextPrevPanel getNextPrevPanel() { |
|
357 |
if (nextPrevPanel == null) { |
|
358 |
nextPrevPanel = WMTSSwingLocator.getSwingManager().createNextPrevPanel(); |
|
359 |
nextPrevPanel.getBtnNext().addActionListener(this); |
|
360 |
nextPrevPanel.getBtnPrev().addActionListener(this); |
|
361 |
} |
|
362 |
return nextPrevPanel; |
|
363 |
} |
|
364 |
|
|
365 |
|
|
366 |
protected WmtsGUI getPanelPage2() { |
|
367 |
if (wmtsParamsPanel == null){ |
|
368 |
wmtsParamsPanel = WMTSSwingLocator.getSwingManager().createMainWizard(getWizardListenerSupport()); |
|
369 |
wmtsParamsPanel.addChangeTabListener(new java.awt.event.MouseAdapter() { |
|
370 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
|
371 |
page = wmtsParamsPanel.currentPage() + 1; |
|
372 |
activarVisualizarBotones(); |
|
373 |
} |
|
374 |
}); |
|
375 |
} |
|
376 |
return wmtsParamsPanel; |
|
377 |
} |
|
378 |
|
|
379 |
/** |
|
380 |
* DOCUMENT ME! |
|
381 |
*/ |
|
382 |
protected void activarVisualizarBotones() { |
|
383 |
if (page == firstPage) { |
|
384 |
getNextPrevPanel().getBtnPrev().setEnabled(false); |
|
385 |
|
|
386 |
if (connected) { |
|
387 |
getNextPrevPanel().getBtnNext().setEnabled(true); |
|
388 |
} else { |
|
389 |
getNextPrevPanel().getBtnNext().setEnabled(false); |
|
390 |
} |
|
391 |
} else if (page < getPanelPage2().getNumTabs()) { |
|
392 |
getNextPrevPanel().getBtnNext().setEnabled(true); |
|
393 |
getNextPrevPanel().getBtnPrev().setEnabled(true); |
|
394 |
if (getPanelPage2().nextEnabledPage() == -1) { |
|
395 |
getNextPrevPanel().getBtnNext().setEnabled(false); |
|
396 |
} |
|
397 |
//getWizardListenerSupport().callStateChanged(getPanelPage2().isCorrectlyConfigured()); |
|
398 |
} else if (page == getPanelPage2().getNumTabs()) { |
|
399 |
getNextPrevPanel().getBtnNext().setEnabled(false); |
|
400 |
//getWizardListenerSupport().callStateChanged(getPanelPage2().isCorrectlyConfigured()); |
|
401 |
} |
|
402 |
} |
|
403 |
|
|
404 |
/** |
|
405 |
* Gets the list of servers that have been persisted or added in the properties file |
|
406 |
* @return |
|
407 |
*/ |
|
408 |
private ServerDataPersistence getServerDataPersistence() { |
|
409 |
DynObject pluginProperties = this.plugin.getPluginProperties(); |
|
410 |
ServerDataPersistence servers = (ServerDataPersistence) pluginProperties.getDynValue("servers"); |
|
411 |
|
|
412 |
if( servers == null || servers.isEmpty() ) { |
|
413 |
if( servers == null ) { |
|
414 |
servers = new ServerDataPersistence(ServerData.SERVER_TYPE_WMTS); |
|
415 |
pluginProperties.setDynValue("servers", servers); |
|
416 |
} |
|
417 |
//Lee los servidores del properties y los mezcla con los que hay en la persistencia |
|
418 |
Properties prop = new Properties(); |
|
419 |
File propFile = new File(this.plugin.getPluginDirectory(),serversPropsFilename); |
|
420 |
FileInputStream fis = null; |
|
421 |
try { |
|
422 |
fis = new FileInputStream(propFile); |
|
423 |
prop.load(fis); |
|
424 |
} catch (FileNotFoundException e) { |
|
425 |
logger.info("Properties file '"+propFile.getAbsolutePath()+"' not found", e); |
|
426 |
} catch (IOException e) { |
|
427 |
logger.info("Error reading properties file '"+propFile.getAbsolutePath()+"'.", e); |
|
428 |
} finally { |
|
429 |
IOUtils.closeQuietly(fis); |
|
430 |
} |
|
431 |
|
|
432 |
for (int i = 0; i < prop.size(); i++) { |
|
433 |
Object value = prop.get("server[" + i + "]"); |
|
434 |
servers.addServerData(new ServerData(value.toString(), ServerData.SERVER_TYPE_WMTS)); |
|
435 |
} |
|
436 |
|
|
437 |
} |
|
438 |
return servers; |
|
439 |
|
|
440 |
|
|
441 |
} |
|
442 |
|
|
443 |
/** |
|
444 |
* Saves the list of server reading from the <code>ComboBox</code> |
|
445 |
*/ |
|
446 |
private void saveServerListFromComboBox() { |
|
447 |
ServerDataPersistence persistence = getServerDataPersistence(); |
|
448 |
String urlSelected = getIserverPanel().getTxtHost().getModel().getSelectedItem().toString(); |
|
449 |
|
|
450 |
boolean isSelectedInModel = false; |
|
451 |
for (int i = 0; i < getIserverPanel().getTxtHost().getItemCount(); i++) { |
|
452 |
String url = getIserverPanel().getTxtHost().getItemAt(i).toString(); |
|
453 |
persistence.addServerData(new ServerData(url, ServerData.SERVER_TYPE_WMTS)); |
|
454 |
if(url.equals(urlSelected)) { |
|
455 |
isSelectedInModel = true; |
|
456 |
} |
|
457 |
} |
|
458 |
|
|
459 |
if(!isSelectedInModel) |
|
460 |
persistence.addServerData(new ServerData(urlSelected, ServerData.SERVER_TYPE_WMTS)); |
|
461 |
|
|
462 |
} |
|
463 |
|
|
464 |
/** |
|
465 |
* Devuelve el host que est๏ฟฝ escrito en el cuadro de texto del host o null |
|
466 |
* en caso de que no haya nada escrito o est๏ฟฝ mal escrito |
|
467 |
* |
|
468 |
* @return URL del host |
|
469 |
*/ |
|
470 |
public URL getHost() { |
|
471 |
try { |
|
472 |
if ((getIserverPanel().getTxtHost() == null)|| (getIserverPanel().getTxtHost().getModel().getSelectedItem() == null)) { |
|
473 |
return new URL(explorer.getHost()); |
|
474 |
} else { |
|
475 |
return new URL(getIserverPanel().getTxtHost().getModel().getSelectedItem().toString()); |
|
476 |
} |
|
477 |
} catch (MalformedURLException e) { |
|
478 |
return null; |
|
479 |
} |
|
480 |
} |
|
481 |
|
|
482 |
public void initWizard() { |
|
483 |
} |
|
484 |
|
|
485 |
@Override |
|
486 |
public DataStoreParameters[] getParameters() { |
|
487 |
return null; |
|
488 |
} |
|
489 |
|
|
490 |
@Override |
|
491 |
public void close() { |
|
492 |
} |
|
493 |
|
|
494 |
@Override |
|
495 |
public void execute() { |
|
496 |
try { |
|
497 |
getPanelPage2().setDeleteCache(getIserverPanel().getChkCaching().isSelected()); |
|
498 |
RasterDataParameters[] paramsList = getPanelPage2().getDataParameters(); |
|
499 |
List<FLyrWMTS> lyrList = getLayerList(paramsList); |
|
500 |
for (int i = 0; i < lyrList.size(); i++) { |
|
501 |
getMapCtrl().getMapContext().getLayers().addLayer(lyrList.get(i)); |
|
502 |
} |
|
503 |
} catch (LoadLayerException e) { |
|
504 |
logger.info("Persistence file not found for WMS plugin", e); |
|
505 |
} |
|
506 |
} |
|
507 |
|
|
508 |
public List<FLyrWMTS> getLayerList(RasterDataParameters[] paramsList) throws LoadLayerException { |
|
509 |
List<FLyrWMTS> layerList = new ArrayList<FLyrWMTS>(); |
|
510 |
for (int i = 0; i < paramsList.length; i++) { |
|
511 |
FLyrWMTS layer = new FLyrWMTS(); |
|
512 |
layer.deleteCache(getPanelPage2().getDeleteCache()); |
|
513 |
try { |
|
514 |
layer.setParameters(paramsList[i]); |
|
515 |
String title = null; |
|
516 |
if(paramsList[i] instanceof WMTSDataParameters) { |
|
517 |
title = ((WMTSDataParameters) paramsList[i]).getLayer().getTitle(); |
|
518 |
} else if(paramsList[i] instanceof TileDataParameters) { |
|
519 |
DataParameters p = ((TileDataParameters) paramsList[i]).getDataParameters(); |
|
520 |
if(p instanceof WMTSDataParameters) |
|
521 |
title = ((WMTSDataParameters) p).getLayer().getTitle(); |
|
522 |
} |
|
523 |
|
|
524 |
layer.setName(title); |
|
525 |
layer.setExplorer(explorer); |
|
526 |
//Ojo! Pruebas! |
|
527 |
//layer.setTileServer(FileTileServer.class); |
|
528 |
layerList.add(layer); |
|
529 |
} catch (InitializeException e) { |
|
530 |
throw new LoadLayerException("Error initializating layer", e); |
|
531 |
} |
|
532 |
} |
|
533 |
return layerList; |
|
534 |
} |
|
535 |
} |
|
0 | 536 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/gui/wizard/WMTSPropsDialog.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 |
|
|
23 |
package org.gvsig.raster.wmts.app.wmtsclient.gui.wizard; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.HashMap; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import javax.swing.JOptionPane; |
|
31 |
import javax.swing.JPanel; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
35 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
36 |
import org.gvsig.fmap.dal.DataParameters; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
38 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
40 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
42 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
43 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
44 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
45 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
46 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
|
47 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
48 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
49 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
50 |
import org.gvsig.raster.wmts.app.wmtsclient.layer.FLyrWMTS; |
|
51 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
52 |
import org.gvsig.raster.wmts.io.WMTSServerExplorer; |
|
53 |
import org.gvsig.raster.wmts.swing.WMTSSwingLocator; |
|
54 |
import org.gvsig.raster.wmts.swing.WMTSWizardListener; |
|
55 |
import org.gvsig.raster.wmts.swing.WmtsGUI; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* The TOC WMTS properties panel container. |
|
60 |
* |
|
61 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
62 |
*/ |
|
63 |
public class WMTSPropsDialog extends JPanel implements IWindow, ButtonsPanelListener { |
|
64 |
private static final long serialVersionUID = 1L; |
|
65 |
private FLyrWMTS fLayer = null; |
|
66 |
private WindowInfo m_ViewInfo = null; |
|
67 |
private ButtonsPanel buttonsPanel = null; |
|
68 |
private WmtsGUI wmtsGUIInterface = null; |
|
69 |
private WMTSServerExplorer explorer = null; |
|
70 |
|
|
71 |
public class WizardListenerImpl implements WMTSWizardListener { |
|
72 |
public void correctlyConfiguredEvent(boolean finishable) { |
|
73 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).setEnabled(finishable); |
|
74 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setEnabled(finishable); |
|
75 |
} |
|
76 |
|
|
77 |
public void addLayerEvent() { |
|
78 |
} |
|
79 |
|
|
80 |
public void removeLayerEvent() { |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
|
|
85 |
public WMTSPropsDialog() { |
|
86 |
initialize(null); |
|
87 |
} |
|
88 |
|
|
89 |
public WMTSPropsDialog(FLayer layer) { |
|
90 |
super(); |
|
91 |
if(layer instanceof FLyrWMTS) { |
|
92 |
fLayer = (FLyrWMTS)layer; |
|
93 |
initialize(fLayer); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
private void initialize(FLyrWMTS layer) { |
|
98 |
HashMap<String, Object> hash = layer != null ? layer.getProperties() : null; |
|
99 |
wmtsGUIInterface = getParamsPanel(hash); |
|
100 |
setLayout(new BorderLayout()); |
|
101 |
this.add(wmtsGUIInterface, BorderLayout.CENTER); |
|
102 |
this.add(getButtonsPanel(), BorderLayout.SOUTH); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* Gets the buttons panel |
|
107 |
* @return |
|
108 |
*/ |
|
109 |
public ButtonsPanel getButtonsPanel() { |
|
110 |
if(buttonsPanel == null) { |
|
111 |
buttonsPanel = new ButtonsPanel(); |
|
112 |
buttonsPanel.addApply(); |
|
113 |
buttonsPanel.addAccept(); |
|
114 |
buttonsPanel.addClose(); |
|
115 |
buttonsPanel.addButtonPressedListener(this); |
|
116 |
} |
|
117 |
return buttonsPanel; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* With getParamsPanel we have access to the map config TabbedPane. |
|
122 |
* If this panel doesn't exist yet (which can occur when an existing project is |
|
123 |
* recovered) it is been automatically constructed by connecting to the server, |
|
124 |
* reloading the necessary data, filling up the content and setting the selected |
|
125 |
* values that were selected when the projet was saved. |
|
126 |
* |
|
127 |
* |
|
128 |
* Since a connection to the server is needed when rebuiliding the panel, this |
|
129 |
* causes a delay for the panel's showing up or a nullPointer error if there is |
|
130 |
* no path to the server. |
|
131 |
* |
|
132 |
* |
|
133 |
* Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n |
|
134 |
* del mapa. Si este panel todav?a no existe (como puede ser cuando |
|
135 |
* recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando |
|
136 |
* al servidor, recuperando los datos necesarios, rellenando el contenido y |
|
137 |
* dejando seleccionados los valores que estaban seleccionados cuando se |
|
138 |
* guarda el proyecto. |
|
139 |
* |
|
140 |
* |
|
141 |
* Como para reconstruirse requiere una conexi?n con el servidor esto causa |
|
142 |
* un retardo en la aparici?n en el toc o un error de nullPointer si no |
|
143 |
* hay conexi?n hasta el servidor. |
|
144 |
* |
|
145 |
* |
|
146 |
* @return WMSParamsPanel |
|
147 |
*/ |
|
148 |
public WmtsGUI getParamsPanel(HashMap<String, Object> info) { |
|
149 |
if (info == null) { |
|
150 |
WmtsGUI toc = WMTSSwingLocator.getSwingManager().createMainWizard(new WizardListenerImpl()); |
|
151 |
return toc; |
|
152 |
} |
|
153 |
|
|
154 |
try { |
|
155 |
if(explorer == null) { |
|
156 |
explorer = ((FLyrWMTS)fLayer).getExplorer(); |
|
157 |
|
|
158 |
try { |
|
159 |
explorer.connect(new CancelTaskImpl()); |
|
160 |
} catch (ConnectException e) { |
|
161 |
RasterSwingLibrary.messageBoxError("The connection cannot be established", this, e); |
|
162 |
return null; |
|
163 |
} |
|
164 |
} |
|
165 |
} catch (Exception e) { |
|
166 |
explorer = null; |
|
167 |
JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE); |
|
168 |
} |
|
169 |
|
|
170 |
try { |
|
171 |
WmtsGUI toc = WMTSSwingLocator.getSwingManager().createMainWizard(new WizardListenerImpl()); |
|
172 |
toc.setWizardData(explorer); |
|
173 |
toc.updateSelectedInfo(info); |
|
174 |
return toc; |
|
175 |
} catch (Exception e) { |
|
176 |
JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE); |
|
177 |
} |
|
178 |
|
|
179 |
return null; |
|
180 |
} |
|
181 |
|
|
182 |
// @SuppressWarnings("unused") |
|
183 |
// private class CommandListener implements ActionListener { |
|
184 |
// |
|
185 |
// public CommandListener(WMTSPropsDialog tp) { |
|
186 |
// } |
|
187 |
// |
|
188 |
// public void actionPerformed(ActionEvent e) { |
|
189 |
// if (e.getActionCommand() == "CANCEL") { |
|
190 |
// close(); |
|
191 |
// } else { |
|
192 |
// MapControl mapCtrl = null; |
|
193 |
// |
|
194 |
// IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
195 |
// for (int i = 0; i < w.length; i++) { |
|
196 |
// if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) { |
|
197 |
// MapContext mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext(); |
|
198 |
// if(mapContext == fLayer.getMapContext()) |
|
199 |
// mapCtrl = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl(); |
|
200 |
// } |
|
201 |
// } |
|
202 |
// |
|
203 |
// try { |
|
204 |
// FLayer[] layerList = wmtsGUIInterface.getLayers(); |
|
205 |
// removeDuplicate(layerList, mapCtrl); |
|
206 |
// for (int i = 0; i < layerList.length; i++) { |
|
207 |
// mapCtrl.getMapContext().getLayers().addLayer(layerList[i]); |
|
208 |
// } |
|
209 |
// mapCtrl.getMapContext().invalidate(); |
|
210 |
// } catch (LoadLayerException exc) { |
|
211 |
// exc.printStackTrace(); |
|
212 |
// } |
|
213 |
// } |
|
214 |
// } |
|
215 |
// } |
|
216 |
|
|
217 |
// private void removeDuplicate(FLayer[] layerList, MapControl mapCtrl) { |
|
218 |
// FLayers lyrs = mapCtrl.getMapContext().getLayers(); |
|
219 |
// for (int i = 0; i < lyrs.getLayersCount(); i++) { |
|
220 |
// FLayer lyr = lyrs.getLayer(i); |
|
221 |
// for (int j = 0; j < layerList.length; j++) { |
|
222 |
// if(lyr.getName().compareTo(layerList[j].getName()) == 0) { |
|
223 |
// lyrs.removeLayer(lyr); |
|
224 |
// } |
|
225 |
// } |
|
226 |
// } |
|
227 |
// } |
|
228 |
|
|
229 |
|
|
230 |
public WindowInfo getWindowInfo() { |
|
231 |
if (m_ViewInfo == null) { |
|
232 |
m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
233 |
m_ViewInfo.setTitle(PluginServices.getText(this,"fit_WMTS_layer")); |
|
234 |
m_ViewInfo.setWidth(500); |
|
235 |
m_ViewInfo.setHeight(500); |
|
236 |
} |
|
237 |
return m_ViewInfo; |
|
238 |
} |
|
239 |
|
|
240 |
public void close() { |
|
241 |
PluginServices.getMDIManager().closeWindow(this); |
|
242 |
} |
|
243 |
|
|
244 |
public Object getWindowProfile() { |
|
245 |
return WindowInfo.DIALOG_PROFILE; |
|
246 |
} |
|
247 |
|
|
248 |
public List<FLyrWMTS> getLayerList(RasterDataParameters[] paramsList) throws LoadLayerException { |
|
249 |
List<FLyrWMTS> layerList = new ArrayList<FLyrWMTS>(); |
|
250 |
for (int i = 0; i < paramsList.length; i++) { |
|
251 |
FLyrWMTS layer = new FLyrWMTS(); |
|
252 |
layer.deleteCache(wmtsGUIInterface.getDeleteCache()); |
|
253 |
try { |
|
254 |
layer.setParameters(paramsList[i]); |
|
255 |
String title = null; |
|
256 |
if(paramsList[i] instanceof WMTSDataParameters) { |
|
257 |
title = ((WMTSDataParameters) paramsList[i]).getLayer().getTitle(); |
|
258 |
} else if(paramsList[i] instanceof TileDataParameters) { |
|
259 |
DataParameters p = ((TileDataParameters) paramsList[i]).getDataParameters(); |
|
260 |
if(p instanceof WMTSDataParameters) |
|
261 |
title = ((WMTSDataParameters) p).getLayer().getTitle(); |
|
262 |
} |
|
263 |
|
|
264 |
layer.setName(title); |
|
265 |
layer.setExplorer(explorer); |
|
266 |
layerList.add(layer); |
|
267 |
} catch (InitializeException e) { |
|
268 |
throw new LoadLayerException("Error initializating layer", e); |
|
269 |
} |
|
270 |
} |
|
271 |
return layerList; |
|
272 |
} |
|
273 |
|
|
274 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
275 |
if( e.getButton() == ButtonsPanel.BUTTON_APPLY || |
|
276 |
e.getButton() == ButtonsPanel.BUTTON_ACCEPT) { |
|
277 |
MapControl mapCtrl = null; |
|
278 |
|
|
279 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
280 |
for (int i = 0; i < w.length; i++) { |
|
281 |
if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) { |
|
282 |
MapContext mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext(); |
|
283 |
if(mapContext == fLayer.getMapContext()) |
|
284 |
mapCtrl = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl(); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
try { |
|
289 |
List<FLyrWMTS> layerList = getLayerList(wmtsGUIInterface.getDataParameters()); |
|
290 |
if(layerList.size() > 0 && layerList.get(0) != null) { |
|
291 |
for (int i = 0; i < layerList.size(); i++) { |
|
292 |
if(layerList.get(i) instanceof FLyrWMTS) { |
|
293 |
mapCtrl.getMapContext().getLayers().removeLayer(fLayer); |
|
294 |
mapCtrl.getMapContext().getLayers().addLayer(layerList.get(i)); |
|
295 |
fLayer = (FLyrWMTS)layerList.get(i); |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
//removeDuplicate(layerList, mapCtrl); |
|
300 |
mapCtrl.getMapContext().invalidate(); |
|
301 |
} catch (LoadLayerException exc) { |
|
302 |
exc.printStackTrace(); |
|
303 |
} |
|
304 |
} |
|
305 |
|
|
306 |
if( e.getButton() == ButtonsPanel.BUTTON_CLOSE || |
|
307 |
e.getButton() == ButtonsPanel.BUTTON_ACCEPT) { |
|
308 |
close(); |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
} |
|
0 | 313 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.77/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/WMTSClientExtension.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 |
|
|
23 |
package org.gvsig.raster.wmts.app.wmtsclient; |
|
24 |
|
|
25 |
import java.awt.Component; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
|
|
28 |
import javax.swing.JOptionPane; |
|
29 |
|
|
30 |
import org.gvsig.about.AboutManager; |
|
31 |
import org.gvsig.about.AboutParticipant; |
|
32 |
import org.gvsig.andami.IconThemeHelper; |
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.plugins.Extension; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.app.ApplicationLocator; |
|
37 |
import org.gvsig.app.ApplicationManager; |
|
38 |
import org.gvsig.app.extension.AddLayer; |
|
39 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
40 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
41 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
42 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
43 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
44 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
45 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
46 |
import org.gvsig.raster.fmap.layers.Multiresolution; |
|
47 |
import org.gvsig.raster.wmts.app.wmtsclient.gui.wizard.WMTSWizard; |
|
48 |
import org.gvsig.raster.wmts.app.wmtsclient.layer.DynObjectSetWMTSInfo; |
|
49 |
import org.gvsig.raster.wmts.app.wmtsclient.layer.FLyrWMTS; |
|
50 |
import org.gvsig.tools.ToolsLocator; |
|
51 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* Extension for adding WMTS support to gvSIG. |
|
56 |
* |
|
57 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
58 |
*/ |
|
59 |
public class WMTSClientExtension extends Extension { |
|
60 |
|
|
61 |
public void initialize() { |
|
62 |
// Adds an entry to the TOC's floating menu to those layers defined in this extension |
|
63 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("View_TocActions"); |
|
64 |
exPoint.append("WMTSPropsTocMenuEntry", "", new WMTSPropsTocMenuEntry()); |
|
65 |
|
|
66 |
// Adds a new tab to the "add layer" wizard for WMTS layer creation |
|
67 |
AddLayer.addWizard(WMTSWizard.class); |
|
68 |
|
|
69 |
//ToolsLocator.getExtensionPointManager().add("CatalogLayers").append("OGC:WMTS", "", FLyrWMTS.class); |
|
70 |
initilizeIcons(); |
|
71 |
DynObjectSetWMTSInfo.registerDynClass(); |
|
72 |
} |
|
73 |
|
|
74 |
public void postInitialize() { |
|
75 |
FLyrWMTS.registerPersistent(); |
|
76 |
// addAboutInfo(); |
|
77 |
} |
|
78 |
|
|
79 |
// private void addAboutInfo() { |
|
80 |
// ApplicationManager application = ApplicationLocator.getManager(); |
|
81 |
// |
|
82 |
// AboutManager about = application.getAbout(); |
|
83 |
// about.addDeveloper("PRODEVELOP", getClass().getClassLoader() |
|
84 |
// .getResource("about/wmts-about.html"), 2); |
|
85 |
// |
|
86 |
// AboutParticipant participant = about.getDeveloper("PRODEVELOP"); |
|
87 |
// participant.addContribution( |
|
88 |
// "WMTS", |
|
89 |
// "Cliente para Web Map Tile Service", |
|
90 |
// 2011,3,1, |
|
91 |
// 2011,3,30 |
|
92 |
// ); |
|
93 |
// } |
|
94 |
|
|
95 |
@SuppressWarnings("deprecation") |
|
96 |
public void execute(String actionCommand) { |
|
97 |
AbstractViewPanel theView = (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
98 |
MapControl mapCtrl = theView.getMapControl(); |
|
99 |
ViewPort viewPort = mapCtrl.getViewPort(); |
|
100 |
|
|
101 |
Multiresolution lyrMultires = null; |
|
102 |
|
|
103 |
FLayers lyrs = mapCtrl.getMapContext().getLayers(); |
|
104 |
for (int i = 0; i < lyrs.getLayersCount(); i++) { |
|
105 |
FLayer lyr = lyrs.getLayer(i); |
|
106 |
if(lyr instanceof FLyrWMTS) { |
|
107 |
lyrMultires = ((Multiresolution)lyr); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
if(actionCommand.compareTo("NEXT_LEVEL") == 0) { |
|
112 |
if(!lyrMultires.increaseZoomLevel()) { |
|
113 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), "max_zoom_reached"); |
|
114 |
return; |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
if(actionCommand.compareTo("PREV_LEVEL") == 0) { |
|
119 |
if(!lyrMultires.decreaseZoomLevel()) { |
|
120 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), "min_zoom_reached"); |
|
121 |
return; |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
Point2D center = new Point2D.Double(viewPort.getExtent().getCenterX(), viewPort.getExtent().getCenterY()); |
|
126 |
Envelope r; |
|
127 |
try { |
|
128 |
r = lyrMultires.getCoordsInLevel(center, lyrMultires.getZoomLevel(), |
|
129 |
viewPort.getImageWidth(), viewPort.getImageHeight()); |
|
130 |
} catch (CreateEnvelopeException e) { |
|
131 |
return; |
|
132 |
} |
|
133 |
|
|
134 |
mapCtrl.getViewPort().setEnvelope(r); |
|
135 |
mapCtrl.invalidate(); |
|
136 |
} |
|
137 |
|
|
138 |
public boolean isEnabled() { |
|
139 |
return true; |
|
140 |
} |
|
141 |
|
|
142 |
public boolean isVisible() { |
|
143 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
144 |
if(window instanceof AbstractViewPanel) { |
|
145 |
AbstractViewPanel theView = (AbstractViewPanel) window; |
|
146 |
MapControl mapCtrl = theView.getMapControl(); |
|
147 |
FLayers lyrs = mapCtrl.getMapContext().getLayers(); |
|
148 |
for (int i = 0; i < lyrs.getLayersCount(); i++) { |
|
149 |
if(lyrs.getLayer(i) instanceof FLyrWMTS) |
|
150 |
return true; |
|
151 |
} |
|
152 |
} |
|
153 |
return false; |
|
154 |
} |
|
155 |
|
|
156 |
|
|
157 |
void initilizeIcons(){ |
|
158 |
IconThemeHelper.registerIcon(null, "level-plus", this); |
|
159 |
IconThemeHelper.registerIcon(null, "level-less", this); |
|
160 |
IconThemeHelper.registerIcon(null, "icon-layer-wmts", this); |
|
161 |
IconThemeHelper.registerIcon(null, "aplication-preferences-downarrow", this); |
Also available in: Unified diff