Revision 22699
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/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); |
|
162 |
IconThemeHelper.registerIcon(null, "aplication-preferences-uparrow", this); |
|
163 |
} |
|
164 |
} |
|
0 | 165 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/WMTSPropsTocMenuEntry.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 org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
27 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
28 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
29 |
import org.gvsig.raster.wmts.app.wmtsclient.gui.wizard.WMTSPropsDialog; |
|
30 |
import org.gvsig.raster.wmts.app.wmtsclient.layer.FLyrWMTS; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* The TOC WMTS properties. |
|
35 |
* |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class WMTSPropsTocMenuEntry extends AbstractTocContextMenuAction { |
|
39 |
|
|
40 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
41 |
WMTSPropsDialog dialog = new WMTSPropsDialog(selectedItems[0]); |
|
42 |
PluginServices.getMDIManager().addWindow(dialog); |
|
43 |
} |
|
44 |
|
|
45 |
public String getText() { |
|
46 |
return PluginServices.getText(this, "wmts_properties"); |
|
47 |
} |
|
48 |
|
|
49 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
50 |
return selectedItems.length == 1 && selectedItems[0].isAvailable(); |
|
51 |
} |
|
52 |
|
|
53 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
54 |
if (selectedItems.length != 1) { |
|
55 |
return false; |
|
56 |
} |
|
57 |
return selectedItems[0] instanceof FLyrWMTS; |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
} |
|
0 | 62 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/layer/DynObjectIteratorWMTSInfo.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.app.wmtsclient.layer; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.feature.Feature; |
|
27 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
28 |
import org.gvsig.tools.dynobject.DynObject; |
|
29 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
30 |
|
|
31 |
/** |
|
32 |
* {@link DynObject} implementation to facade a iterator of a WMTSInfo |
|
33 |
* and allow to be used as a {@link DynObjectSet} iterator. |
|
34 |
* |
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
36 |
* @version $Id$ |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class DynObjectIteratorWMTSInfo implements DisposableIterator { |
|
40 |
|
|
41 |
private ArrayList<Object> infoList = new ArrayList<Object>(); |
|
42 |
private int index = -1; |
|
43 |
|
|
44 |
/** |
|
45 |
* Creates a new DynObjects iterator facade over a feature iterator. |
|
46 |
* Each WMTSInfo will be returned through a new or reused |
|
47 |
* {@link DynObjectWMTSInfo} which allows the {@link Feature} to be |
|
48 |
* used like a DynObject. |
|
49 |
* |
|
50 |
* @param featureIterator |
|
51 |
* to facade |
|
52 |
* @param featureFacade |
|
53 |
* if not null this object will be reused as the facade for the |
|
54 |
* Feature objects of the feature iterator |
|
55 |
*/ |
|
56 |
public DynObjectIteratorWMTSInfo(Object info) { |
|
57 |
this.infoList.add(info); |
|
58 |
index = 0; |
|
59 |
} |
|
60 |
|
|
61 |
public void addObject(Object info) { |
|
62 |
this.infoList.add(info); |
|
63 |
if(index == -1) |
|
64 |
index = 0; |
|
65 |
} |
|
66 |
|
|
67 |
public synchronized void dispose() { |
|
68 |
this.infoList.clear(); |
|
69 |
index = -1; |
|
70 |
} |
|
71 |
|
|
72 |
public synchronized boolean hasNext() { |
|
73 |
return (infoList.size() == 0 || index >= infoList.size()) ? false : true; |
|
74 |
} |
|
75 |
|
|
76 |
public synchronized Object next() { |
|
77 |
Object o = infoList.get(index); |
|
78 |
index ++; |
|
79 |
return o; |
|
80 |
} |
|
81 |
|
|
82 |
public synchronized void remove() { |
|
83 |
if(index < infoList.size() && index >= 0) { |
|
84 |
index --; |
|
85 |
infoList.remove(index); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
public long getSize() { |
|
90 |
return infoList.size(); |
|
91 |
} |
|
92 |
} |
|
0 | 93 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/layer/DynObjectSetWMTSInfo.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.app.wmtsclient.layer; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
25 |
import org.gvsig.tools.ToolsLocator; |
|
26 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
27 |
import org.gvsig.tools.dynobject.DynClass; |
|
28 |
import org.gvsig.tools.dynobject.DynObject; |
|
29 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
30 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
31 |
import org.gvsig.tools.exception.BaseException; |
|
32 |
import org.gvsig.tools.observer.Observable; |
|
33 |
import org.gvsig.tools.observer.Observer; |
|
34 |
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable; |
|
35 |
import org.gvsig.tools.visitor.Visitor; |
|
36 |
|
|
37 |
/** |
|
38 |
* {@link DynObject} implementation to facade of a {@link FeatureSet} and allow |
|
39 |
* to be used as a {@link DynObjectSet}. |
|
40 |
* |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
* @version $Id$ |
|
43 |
*/ |
|
44 |
public class DynObjectSetWMTSInfo extends BaseWeakReferencingObservable |
|
45 |
implements DynObjectSet, Observer { |
|
46 |
public static final int TYPE_TEXT = 0; |
|
47 |
public static final int TYPE_HTML = 1; |
|
48 |
public static final int TYPE_XML = 2; |
|
49 |
private DynObjectIteratorWMTSInfo ite = null; |
|
50 |
|
|
51 |
public static void registerDynClass() { |
|
52 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
53 |
DynClass dynClass = manager.add("WMTSInfoByPoint", "WMTS InfoByPoint"); |
|
54 |
dynClass.setNamespace("InfoByPoint"); |
|
55 |
dynClass.addDynFieldString("info"); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Creates a new facade over a given info, with fast dynobject |
|
60 |
* iteration. |
|
61 |
*/ |
|
62 |
public DynObjectSetWMTSInfo(String txt, int type) { |
|
63 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
64 |
DynObject dynObject = manager.createDynObject("WMTSInfoByPoint"); |
|
65 |
dynObject.setDynValue("info", txt); |
|
66 |
ite = new DynObjectIteratorWMTSInfo(dynObject); |
|
67 |
} |
|
68 |
|
|
69 |
public void dispose() { |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
public void accept(final Visitor visitor, long firstValueIndex) throws BaseException { |
|
74 |
while(ite.hasNext()) { |
|
75 |
visitor.visit(ite.next()); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public void accept(final Visitor visitor) throws BaseException { |
|
80 |
while(ite.hasNext()) { |
|
81 |
visitor.visit(ite.next()); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
public long getSize() throws BaseException { |
|
86 |
return ite.getSize(); |
|
87 |
} |
|
88 |
|
|
89 |
public DisposableIterator iterator(long index) throws BaseException { |
|
90 |
return iterator(); |
|
91 |
} |
|
92 |
|
|
93 |
public DisposableIterator iterator() throws BaseException { |
|
94 |
return ite; |
|
95 |
} |
|
96 |
|
|
97 |
public boolean isEmpty() throws BaseException { |
|
98 |
return (getSize() == 0); |
|
99 |
} |
|
100 |
|
|
101 |
public boolean isDeleteEnabled() { |
|
102 |
return true; |
|
103 |
} |
|
104 |
|
|
105 |
public void delete(DynObject dynObject) throws BaseException { |
|
106 |
|
|
107 |
} |
|
108 |
|
|
109 |
public boolean isUpdateEnabled() { |
|
110 |
return true; |
|
111 |
} |
|
112 |
|
|
113 |
public void update(DynObject dynObject) throws BaseException { |
|
114 |
System.out.println(); |
|
115 |
} |
|
116 |
|
|
117 |
public void update(Observable observable, Object notification) { |
|
118 |
System.out.println(); |
|
119 |
} |
|
120 |
} |
|
0 | 121 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/layer/FLyrWMTS.java | ||
---|---|---|
1 |
package org.gvsig.raster.wmts.app.wmtsclient.layer; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.Graphics2D; |
|
5 |
import java.awt.Image; |
|
6 |
import java.awt.Point; |
|
7 |
import java.awt.geom.Point2D; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
import java.awt.image.BufferedImage; |
|
10 |
import java.lang.ref.WeakReference; |
|
11 |
import java.net.URI; |
|
12 |
import java.net.URISyntaxException; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.Iterator; |
|
16 |
import java.util.List; |
|
17 |
|
|
18 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
19 |
|
|
20 |
import org.cresques.cts.ICoordTrans; |
|
21 |
import org.cresques.cts.IProjection; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
import org.gvsig.fmap.dal.DALLocator; |
|
26 |
import org.gvsig.fmap.dal.DataManager; |
|
27 |
import org.gvsig.fmap.dal.DataParameters; |
|
28 |
import org.gvsig.fmap.dal.DataStore; |
|
29 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
30 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
32 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
33 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
34 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
39 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
44 |
import org.gvsig.fmap.dal.exception.DataException; |
|
45 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
46 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
47 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
48 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
49 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
50 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
51 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
52 |
import org.gvsig.fmap.geom.GeometryManager; |
|
53 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
54 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
55 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
56 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
57 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
58 |
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend; |
|
59 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
60 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
61 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
62 |
import org.gvsig.raster.fmap.layers.NotAvailableStateException; |
|
63 |
import org.gvsig.raster.fmap.legend.ImageLegend; |
|
64 |
import org.gvsig.raster.util.CancelTaskImpl; |
|
65 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
66 |
import org.gvsig.raster.wmts.io.WMTSServerExplorer; |
|
67 |
import org.gvsig.raster.wmts.io.WMTSServerExplorerParameters; |
|
68 |
import org.gvsig.tools.ToolsLocator; |
|
69 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
70 |
import org.gvsig.tools.dynobject.DynStruct; |
|
71 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
72 |
import org.gvsig.tools.persistence.PersistentState; |
|
73 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
74 |
import org.gvsig.tools.persistence.exception.PersistenceRuntimeException; |
|
75 |
import org.gvsig.tools.task.Cancellable; |
|
76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
77 |
import org.gvsig.tools.task.TaskStatusManager; |
|
78 |
|
|
79 |
/** |
|
80 |
* WMTS Layer class. |
|
81 |
* |
|
82 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
83 |
* |
|
84 |
*/ |
|
85 |
public class FLyrWMTS extends DefaultFLyrRaster implements IHasImageLegend { |
|
86 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
87 |
private static final Logger logger = LoggerFactory.getLogger(FLyrWMTS.class); |
|
88 |
private List<WeakReference<Thread>> disableUpdateDrawVersion; |
|
89 |
private Envelope fullEnvelope = null; |
|
90 |
private boolean firstLoad = false; |
|
91 |
private RasterManager rManager = RasterLocator.getManager(); |
|
92 |
private DataStoreParameters params = null; |
|
93 |
private WMTSServerExplorer wmtsExplorer = null; |
|
94 |
private boolean deleteCache = false; |
|
95 |
|
|
96 |
/** |
|
97 |
* Register the persistence |
|
98 |
*/ |
|
99 |
public static void registerPersistent() { |
|
100 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
101 |
DynStruct definition = manager.getDefinition("FLyrWMTS_Persistent"); |
|
102 |
if( definition == null ) { |
|
103 |
if (manager.getDefinition(DefaultFLyrRaster.class) == null) { |
|
104 |
DefaultFLyrRaster.registerPersistence(); |
|
105 |
} |
|
106 |
|
|
107 |
definition = manager.addDefinition( |
|
108 |
FLyrWMTS.class, |
|
109 |
"FLyrWMTS_Persistent", |
|
110 |
"FLyrWMTS Persistent Definition", |
|
111 |
null, |
|
112 |
null |
|
113 |
); |
|
114 |
|
|
115 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, DefaultFLyrRaster.PERSISTENT_NAME); |
|
116 |
} |
|
117 |
|
|
118 |
DefaultFLyrRaster.registerPersistence(definition); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Constructor |
|
123 |
*/ |
|
124 |
public FLyrWMTS() { |
|
125 |
super(); |
|
126 |
this.updateDrawVersion(); |
|
127 |
try { |
|
128 |
enableAwake(); |
|
129 |
} catch (NotAvailableStateException e) { |
|
130 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* @param host |
|
136 |
* @param srs |
|
137 |
* @return the data store |
|
138 |
* @throws InitializeException |
|
139 |
*/ |
|
140 |
public static DataStore createDataStore(String host, IProjection srs) throws InitializeException { |
|
141 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
142 |
RasterDataParameters params = null; |
|
143 |
try { |
|
144 |
params = (RasterDataParameters)dataman.createServerExplorerParameters(WMTSServerExplorer.NAME); |
|
145 |
} catch (InitializeException e) { |
|
146 |
return null; |
|
147 |
} catch (ProviderNotRegisteredException e) { |
|
148 |
return null; |
|
149 |
} |
|
150 |
URI hostURI; |
|
151 |
try { |
|
152 |
hostURI = new URI(host); |
|
153 |
} catch (URISyntaxException e1) { |
|
154 |
logger.warn("Can't create URI from "+host, e1); |
|
155 |
throw new InitializeException(e1); |
|
156 |
} |
|
157 |
params.setURI(hostURI); |
|
158 |
params.setSRS(srs); |
|
159 |
|
|
160 |
try { |
|
161 |
return dataman.openStore(params.getDataStoreName(), params); |
|
162 |
} catch (ValidateDataParametersException e) { |
|
163 |
throw new InitializeException(e); |
|
164 |
} catch (ProviderNotRegisteredException e) { |
|
165 |
throw new InitializeException(e); |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
public void loadFromState(PersistentState state) |
|
170 |
throws PersistenceException { |
|
171 |
try { |
|
172 |
super.loadFromState(state); |
|
173 |
|
|
174 |
/* |
|
175 |
* Needs to initialize variables using methods on setDataStore method of this class |
|
176 |
*/ |
|
177 |
this.setDataStore(getDataStore()); |
|
178 |
//this.setParameters(getDataStore().getParameters()); |
|
179 |
}catch (PersistenceRuntimeException e) { |
|
180 |
logger.debug("Unable to load store from persistence in layer: " + this.getName(), e); |
|
181 |
this.setAvailable(false); |
|
182 |
return; |
|
183 |
} catch (LoadLayerException e) { |
|
184 |
logger.debug("Unable to load store to layer: " + this.getName(), e); |
|
185 |
this.setAvailable(false); |
|
186 |
return; |
|
187 |
// } catch (InitializeException e) { |
|
188 |
// logger.debug("Unable to load store parameters to layer: " + this.getName(), e); |
|
189 |
// this.setAvailable(false); |
|
190 |
// return; |
|
191 |
} |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public void setDataStore(DataStore dataStore) throws LoadLayerException { |
|
196 |
this.dataStore = (RasterDataStore) dataStore; |
|
197 |
try { |
|
198 |
enableOpen(); |
|
199 |
} catch (NotAvailableStateException e) { |
|
200 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e); |
|
201 |
} |
|
202 |
if (this.dataStore != null) { |
|
203 |
setProjection(this.dataStore.getProjection()); |
|
204 |
setFullExtent(this.dataStore.getExtent().toRectangle2D()); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
@SuppressWarnings("deprecation") |
|
209 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
210 |
Cancellable cancel, double scale) throws ReadException { |
|
211 |
//CancelTaskImpl cancellable = new CancelTaskImpl(cancel); |
|
212 |
|
|
213 |
//Solo el zoom normal recalcula el nivel dependiendo de la escala. El zoom por niveles asigna |
|
214 |
//?l el nivel de zoom por lo que no habr? que recalcularlo. |
|
215 |
if(recalcLevel) { |
|
216 |
double pixelSize = viewPort.getExtent().getWidth() / (double)viewPort.getImageWidth(); |
|
217 |
zoomLevel = dataStore.getNearestLevel(pixelSize); |
|
218 |
} |
|
219 |
recalcLevel = true; |
|
220 |
|
|
221 |
if(!firstLoad) { |
|
222 |
try { |
|
223 |
initFilters(); |
|
224 |
try { |
|
225 |
if(!isOpen()) |
|
226 |
enableOpen(); |
|
227 |
} catch (NotAvailableStateException e) { |
|
228 |
throw new ReadException("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), e); |
|
229 |
} |
|
230 |
} catch (FilePaletteException e) { |
|
231 |
throw new ReadException(e.getMessage(), e); |
|
232 |
} |
|
233 |
firstLoad = true; |
|
234 |
} |
|
235 |
|
|
236 |
enableStopped(); |
|
237 |
|
|
238 |
if (isWithinScale(scale)) { |
|
239 |
Envelope adjustedExtent = viewPort.getAdjustedEnvelope(); |
|
240 |
if (!adjustedExtent.intersects(getFullEnvelope())) { |
|
241 |
return; |
|
242 |
} |
|
243 |
Extent ext = rManager.getDataStructFactory().createExtent( |
|
244 |
adjustedExtent.getLowerCorner().getX(), |
|
245 |
adjustedExtent.getUpperCorner().getY(), |
|
246 |
adjustedExtent.getUpperCorner().getX(), |
|
247 |
adjustedExtent.getLowerCorner().getY()); |
|
248 |
Dimension imgSz = viewPort.getImageSize(); |
|
249 |
ViewPortData vp2 = rManager.getDataStructFactory().createViewPortData(viewPort.getProjection(), ext, imgSz ); |
|
250 |
vp2.setMat(viewPort.getAffineTransform()); |
|
251 |
vp2.setDPI((int)viewPort.getDPI()); |
|
252 |
|
|
253 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
|
254 |
SimpleTaskStatus taskStatus = new RasterTaskStatus("Drawing " + getName() + "...", cancel); |
|
255 |
manager.add(taskStatus); |
|
256 |
taskStatus.setAutoremove(true); |
|
257 |
|
|
258 |
try { |
|
259 |
WMTSDataParameters par = getWMTSParameters(getParameters()); |
|
260 |
//getParameters().setExtent(ext.toRectangle2D()); |
|
261 |
par.setWidth((int)viewPort.getImageSize().getWidth()); |
|
262 |
par.setHeight((int)viewPort.getImageSize().getHeight()); |
|
263 |
|
|
264 |
getRender().drawTiledService(g, vp2, viewPort.getImageSize(), taskStatus); |
|
265 |
} catch (ProcessInterruptedException e) { |
|
266 |
throw new ReadException("Problems drawing this layer: " + e.getMessage(), e); |
|
267 |
} catch (QueryException e) { |
|
268 |
throw new ReadException("Problems drawing this layer: " + e.getMessage(), e); |
|
269 |
} finally { |
|
270 |
taskStatus.terminate(); |
|
271 |
} |
|
272 |
} |
|
273 |
disableStopped(); |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
/** |
|
278 |
* @param g |
|
279 |
* @param viewPort |
|
280 |
* @param cancel |
|
281 |
* @param scale |
|
282 |
* @param properties |
|
283 |
* @throws ReadException |
|
284 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, |
|
285 |
* com.iver.cit.gvsig.fmap.ViewPort, |
|
286 |
* com.iver.cit.gvsig.fmap.operations.Cancellable) |
|
287 |
*/ |
|
288 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
|
289 |
throws ReadException { |
|
290 |
|
|
291 |
|
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* @param g |
|
296 |
* @param viewPort |
|
297 |
* @param cancel |
|
298 |
* @param scale |
|
299 |
* @throws ReadException |
|
300 |
*/ |
|
301 |
public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadException { |
|
302 |
draw(null, g, viewPort, cancel,scale); |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* Inserta la extensi?n total de la capa. |
|
307 |
* |
|
308 |
* @param fullExtent |
|
309 |
* Rectangulo. |
|
310 |
*/ |
|
311 |
public void setFullExtent(Rectangle2D fullExtent) { |
|
312 |
this.setFullEnvelope(this.getEnvelopeFromRectable2D(fullExtent)); |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* Inserta la extensi?n total de la capa en la proyeccion original. |
|
317 |
* @param envelope |
|
318 |
* |
|
319 |
*/ |
|
320 |
public void setFullEnvelope(Envelope envelope) { |
|
321 |
Envelope cur = this.getFullEnvelope(); |
|
322 |
if (cur == envelope) { |
|
323 |
return; |
|
324 |
} |
|
325 |
if (cur != null && cur.equals(envelope)) { |
|
326 |
return; |
|
327 |
} |
|
328 |
|
|
329 |
this.fullEnvelope = envelope; |
|
330 |
this.updateDrawVersion(); |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* @return the properties. |
|
335 |
*/ |
|
336 |
public HashMap<String, Object> getProperties() { |
|
337 |
HashMap<String, Object> info = new HashMap<String, Object>(); |
|
338 |
WMTSDataParameters par = getWMTSParameters(getParameters()); |
|
339 |
String layerName = par.getLayer().getTitle(); |
|
340 |
try { |
|
341 |
info.put("name", getName()); |
|
342 |
info.put("selectedLayer", layerName); |
|
343 |
info.put("host", par.getURI()); |
|
344 |
info.put("srs", par.getSRSCode()); |
|
345 |
info.put("imageformat", par.getImageFormat()); |
|
346 |
info.put("infoformat", par.getInfoFormat()); |
|
347 |
//info.put("styles", getParameters().getStyles()); |
|
348 |
return info; |
|
349 |
} catch (Exception e) { |
|
350 |
e.printStackTrace(); |
|
351 |
} |
|
352 |
return null; |
|
353 |
} |
|
354 |
|
|
355 |
|
|
356 |
public String getTocImageIcon() { |
|
357 |
return "icon-layer-wmts"; |
|
358 |
} |
|
359 |
|
|
360 |
public boolean isActionEnabled(int action) { |
|
361 |
switch (action) { |
|
362 |
case IRasterLayerActions.ZOOM_PIXEL_RESOLUTION: |
|
363 |
case IRasterLayerActions.FLYRASTER_BAR_TOOLS: |
|
364 |
case IRasterLayerActions.BANDS_FILE_LIST: |
|
365 |
case IRasterLayerActions.COLOR_TABLE: |
|
366 |
case IRasterLayerActions.GEOLOCATION: |
|
367 |
case IRasterLayerActions.PANSHARPENING: |
|
368 |
case IRasterLayerActions.SAVE_COLORINTERP: |
|
369 |
case IRasterLayerActions.SAVEAS: |
|
370 |
case IRasterLayerActions.BANDS_RGB: |
|
371 |
case IRasterLayerActions.CLIPPING: |
|
372 |
case IRasterLayerActions.ENHANCED: |
|
373 |
case IRasterLayerActions.STATS: |
|
374 |
case IRasterLayerActions.NODATA: |
|
375 |
case IRasterLayerActions.HISTOGRAM: |
|
376 |
return false; |
|
377 |
case IRasterLayerActions.REMOTE_ACTIONS: |
|
378 |
return true; |
|
379 |
} |
|
380 |
|
|
381 |
return super.isActionEnabled(action); |
|
382 |
} |
|
383 |
|
|
384 |
public ILegend getLegend() { |
|
385 |
if(getDataStore() != null) |
|
386 |
return new ImageLegend(getDataStore().getImageLegend()); |
|
387 |
return null; |
|
388 |
} |
|
389 |
|
|
390 |
public boolean isRemote() { |
|
391 |
return true; |
|
392 |
} |
|
393 |
|
|
394 |
public boolean overviewsSupport() { |
|
395 |
return false; |
|
396 |
} |
|
397 |
|
|
398 |
protected void updateDrawVersion() { |
|
399 |
if (this.disableUpdateDrawVersion != null){ |
|
400 |
|
|
401 |
Thread curThread = Thread.currentThread(); |
|
402 |
|
|
403 |
Thread aThread; |
|
404 |
|
|
405 |
Iterator<WeakReference<Thread>> iter = this.disableUpdateDrawVersion.iterator(); |
|
406 |
while (iter.hasNext()){ |
|
407 |
aThread = (Thread) ((WeakReference<?>)iter.next()).get(); |
|
408 |
if (aThread == null){ |
|
409 |
iter.remove(); |
|
410 |
} else if(aThread.equals(curThread)){ |
|
411 |
return; |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
super.updateDrawVersion(); |
|
416 |
} |
|
417 |
|
|
418 |
protected void disableUpdateDrawVersion() { |
|
419 |
if (this.disableUpdateDrawVersion == null) { |
|
420 |
this.disableUpdateDrawVersion = new ArrayList<WeakReference<Thread>>(); |
|
421 |
} |
|
422 |
this.disableUpdateDrawVersion.add(new WeakReference<Thread>(Thread.currentThread())); |
|
423 |
} |
|
424 |
|
|
425 |
protected void enableUpdateDrawVersion() { |
|
426 |
if (this.disableUpdateDrawVersion == null) { |
|
427 |
return; |
|
428 |
} |
|
429 |
Thread curThread = Thread.currentThread(); |
|
430 |
Thread aThread; |
|
431 |
|
|
432 |
Iterator<WeakReference<Thread>> iter = this.disableUpdateDrawVersion.iterator(); |
|
433 |
while (iter.hasNext()) { |
|
434 |
aThread = (Thread) ((WeakReference<?>)iter.next()).get(); |
|
435 |
if (aThread == null) { |
|
436 |
iter.remove(); |
|
437 |
} else if(aThread.equals(curThread)) { |
|
438 |
iter.remove(); |
|
439 |
break; |
|
440 |
} |
|
441 |
} |
|
442 |
|
|
443 |
} |
|
444 |
|
|
445 |
@SuppressWarnings("unused") |
|
446 |
private Rectangle2D.Double getRectable2DFromEnvelope(Envelope env) { |
|
447 |
return new Rectangle2D.Double(env.getMinimum(0), env.getMinimum(1), env |
|
448 |
.getLength(0), env.getLength(1)); |
|
449 |
} |
|
450 |
|
|
451 |
private Envelope getEnvelopeFromRectable2D(Rectangle2D rect) { |
|
452 |
try { |
|
453 |
return geomManager.createEnvelope(rect.getMinX(), rect.getMinY(), |
|
454 |
rect.getMaxX(), rect.getMaxY(), |
|
455 |
SUBTYPES.GEOM2D); |
|
456 |
} catch (CreateEnvelopeException e) { |
|
457 |
logger.error("Error creating the envelope", e); |
|
458 |
} |
|
459 |
return null; |
|
460 |
} |
|
461 |
|
|
462 |
@Override |
|
463 |
public String getFileFormat() { |
|
464 |
return "WMTS"; |
|
465 |
} |
|
466 |
|
|
467 |
|
|
468 |
/** |
|
469 |
* Devuelve el envelope en la proyeccion de la vista |
|
470 |
*/ |
|
471 |
public Envelope getFullEnvelope() { |
|
472 |
Envelope rAux; |
|
473 |
rAux = this.fullEnvelope; |
|
474 |
|
|
475 |
// Esto es para cuando se crea una capa nueva con el fullExtent de ancho |
|
476 |
// y alto 0. |
|
477 |
if (rAux == null || rAux.getMaximum(0) - rAux.getMinimum(0) == 0 |
|
478 |
&& rAux.getMaximum(1) - rAux.getMinimum(1) == 0) { |
|
479 |
try { |
|
480 |
rAux = geomManager.createEnvelope(0, 0, 100, 100, SUBTYPES.GEOM2D); |
|
481 |
} catch (CreateEnvelopeException e) { |
|
482 |
logger.error("Error creating the envelope", e); |
|
483 |
} |
|
484 |
} |
|
485 |
// Si existe reproyecci?n, reproyectar el extent |
|
486 |
ICoordTrans ct = getCoordTrans(); |
|
487 |
if (ct != null) { |
|
488 |
Point2D pt1 = new Point2D.Double(rAux.getMinimum(0), rAux |
|
489 |
.getMinimum(1)); |
|
490 |
Point2D pt2 = new Point2D.Double(rAux.getMaximum(0), rAux |
|
491 |
.getMaximum(1)); |
|
492 |
pt1 = ct.convert(pt1, null); |
|
493 |
pt2 = ct.convert(pt2, null); |
|
494 |
try { |
|
495 |
rAux = geomManager.createEnvelope(pt1.getX(), pt1.getY(), pt2 |
|
496 |
.getX(), pt2.getY(), SUBTYPES.GEOM2D); |
|
497 |
} catch (CreateEnvelopeException e) { |
|
498 |
logger.error("Error creating the envelope", e); |
|
499 |
}// new |
|
500 |
// Rectangle2D.Double(); |
|
501 |
} |
|
502 |
return rAux; |
|
503 |
|
|
504 |
} |
|
505 |
|
|
506 |
public Extent getFullRasterExtent() { |
|
507 |
Envelope env = getFullEnvelope(); |
|
508 |
double minx = env.getMinimum(0); |
|
509 |
double miny = env.getMinimum(1); |
|
510 |
double maxx = env.getMaximum(0); |
|
511 |
double maxy = env.getMaximum(1); |
|
512 |
Point2D ul = new Point2D.Double(minx, maxy); |
|
513 |
Point2D ur = new Point2D.Double(maxx, maxy); |
|
514 |
Point2D ll = new Point2D.Double(minx, miny); |
|
515 |
Point2D lr = new Point2D.Double(maxx, miny); |
|
516 |
return rManager.getDataStructFactory().createExtent(ul, lr, ur, ll); |
|
517 |
} |
|
518 |
|
|
519 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel) |
|
520 |
throws LoadLayerException, DataException { |
|
521 |
|
|
522 |
return null; |
|
523 |
} |
|
524 |
|
|
525 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel, boolean fast) |
|
526 |
throws LoadLayerException, DataException { |
|
527 |
|
|
528 |
org.gvsig.fmap.geom.primitive.Point pReal = getMapContext().getViewPort().convertToMapPoint(p); |
|
529 |
String fInfo = null; |
|
530 |
try { |
|
531 |
fInfo = getDataStore().getInfoByPoint(pReal.getX(), pReal.getY(), new CancelTaskImpl(cancel)); |
|
532 |
} catch (InfoByPointException e) { |
|
533 |
throw new LoadLayerException("Error in getInfoByPoint", e); |
|
534 |
} |
|
535 |
int type = DynObjectSetWMTSInfo.TYPE_TEXT; |
|
536 |
WMTSDataParameters wmtsParams = getWMTSParameters(params); |
|
537 |
|
|
538 |
if(wmtsParams.getInfoFormat() != null) { |
|
539 |
if(wmtsParams.getInfoFormat().compareTo("text/html") == 0) |
|
540 |
type = DynObjectSetWMTSInfo.TYPE_HTML; |
|
541 |
if(wmtsParams.getInfoFormat().compareTo("application/vnd.ogc.gml") == 0) |
|
542 |
type = DynObjectSetWMTSInfo.TYPE_XML; |
|
543 |
} |
|
544 |
return new DynObjectSetWMTSInfo(fInfo, type); |
|
545 |
} |
|
546 |
|
|
547 |
/** |
|
548 |
* Sets the data store parameters |
|
549 |
* @param params |
|
550 |
* @throws InitializeException |
|
551 |
*/ |
|
552 |
public void setParameters(DataStoreParameters params) throws InitializeException { |
|
553 |
this.params = params; |
|
554 |
|
|
555 |
if(params instanceof TileDataParameters) { |
|
556 |
((TileDataParameters)params).deleteCache(deleteCache); |
|
557 |
} |
|
558 |
|
|
559 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
560 |
try { |
|
561 |
DataStore dStore = dataman.openStore(params.getDataStoreName(), params); |
|
562 |
this.setDataStore(dStore); |
|
563 |
|
|
564 |
if(params instanceof WMTSDataParameters) { |
|
565 |
this.setName(((WMTSDataParameters) params).getURI().getPath()); |
|
566 |
} |
|
567 |
|
|
568 |
if(params instanceof TileDataParameters) { |
|
569 |
DataParameters p = ((TileDataParameters) params).getDataParameters(); |
|
570 |
if(p instanceof WMTSDataParameters) { |
|
571 |
this.setName(((WMTSDataParameters) p).getURI().getPath()); |
|
572 |
} |
|
573 |
} |
|
574 |
|
|
575 |
} catch (ValidateDataParametersException e) { |
|
576 |
throw new InitializeException(e); |
|
577 |
} catch (ProviderNotRegisteredException e) { |
|
578 |
throw new InitializeException(e); |
|
579 |
} catch (InitializeException e) { |
|
580 |
throw new InitializeException(e); |
|
581 |
} catch (LoadLayerException e) { |
|
582 |
throw new InitializeException(e); |
|
583 |
} |
|
584 |
} |
|
585 |
|
|
586 |
/** |
|
587 |
* @return the data store parameters |
|
588 |
*/ |
|
589 |
@SuppressWarnings("deprecation") |
|
590 |
public DataStoreParameters getParameters() { |
|
591 |
if(params == null) { |
|
592 |
DataManager datamanager = DALLocator.getDataManager(); |
|
593 |
WMTSServerExplorerParameters explorerParams = null; |
|
594 |
try { |
|
595 |
explorerParams = (WMTSServerExplorerParameters) datamanager.createServerExplorerParameters(WMTSServerExplorer.NAME); |
|
596 |
explorerParams.setHost(""); |
|
597 |
wmtsExplorer = (WMTSServerExplorer) datamanager.createServerExplorer(explorerParams); |
|
598 |
params = wmtsExplorer.getStoredParameters(); |
|
599 |
} catch (InitializeException e) { |
|
600 |
} catch (ProviderNotRegisteredException e) { |
|
601 |
} catch (ValidateDataParametersException e) { |
|
602 |
} |
|
603 |
} |
|
604 |
return getWMTSParameters(params); |
|
605 |
} |
|
606 |
|
|
607 |
/** |
|
608 |
* Gets <code>WMTSDataParameters</code> |
|
609 |
* @param parameters |
|
610 |
* @return |
|
611 |
*/ |
|
612 |
private WMTSDataParameters getWMTSParameters(DataStoreParameters parameters) { |
|
613 |
WMTSDataParameters params = null; |
|
614 |
if(parameters instanceof WMTSDataParameters) { |
|
615 |
params = (WMTSDataParameters) parameters; |
|
616 |
} |
|
617 |
|
|
618 |
if(parameters instanceof TileDataParameters) { |
|
619 |
DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
|
620 |
if(p instanceof WMTSDataParameters) { |
|
621 |
params = (WMTSDataParameters) p; |
|
622 |
} |
|
623 |
} |
|
624 |
return params; |
|
625 |
} |
|
626 |
|
|
627 |
/** |
|
628 |
* Sets the explorer |
|
629 |
* @param explorer |
|
630 |
*/ |
|
631 |
public void setExplorer(WMTSServerExplorer explorer) { |
|
632 |
this.wmtsExplorer = explorer; |
|
633 |
} |
|
634 |
|
|
635 |
/** |
|
636 |
* Gets the explorer |
|
637 |
* @return the server explorer |
|
638 |
*/ |
|
639 |
public WMTSServerExplorer getExplorer() { |
|
640 |
return this.wmtsExplorer; |
|
641 |
} |
|
642 |
|
|
643 |
public Image getImageLegend() { |
|
644 |
return dataStore.getImageLegend(); |
|
645 |
} |
|
646 |
|
|
647 |
public String getPathImage() { |
|
648 |
return null; |
|
649 |
} |
|
650 |
|
|
651 |
public FLayer cloneLayer() throws Exception { |
|
652 |
RasterDataStore ds = dataStore.cloneDataStore(); |
|
653 |
FLyrWMTS newLayer = new FLyrWMTS(); |
|
654 |
newLayer.setName(getName()); |
|
655 |
newLayer.setOpenRasterStore(ds); |
|
656 |
newLayer.fullEnvelope = fullEnvelope; |
|
657 |
newLayer.params = params; |
|
658 |
newLayer.firstLoad = firstLoad; |
|
659 |
newLayer.wmtsExplorer = wmtsExplorer; |
|
660 |
|
|
661 |
List<RasterFilter> filters = getRender().getFilterList().getStatusCloned(); |
|
662 |
|
|
663 |
//Hacemos una copia de las bandas a renderizar |
|
664 |
ColorInterpretation ci = getRender().getRenderColorInterpretation(); |
|
665 |
if(ci != null) { |
|
666 |
newLayer.getRender().setRenderColorInterpretation(ci.cloneColorInterpretation()); |
|
667 |
} |
|
668 |
|
|
669 |
//Asignamos el entorno |
|
670 |
if(newLayer.getRender().getFilterList() == null) |
|
671 |
newLayer.getRender().setFilterList(RasterLocator.getManager().createEmptyFilterList(getRender().getFilterList().getInitDataType())); |
|
672 |
newLayer.getRender().getFilterList().setEnv(getRender().getFilterList().getEnv()); |
|
673 |
newLayer.getRender().getFilterList().setStatus(filters); |
|
674 |
|
|
675 |
// Asignamos los valores noData del original |
|
676 |
NoData nd = (NoData)getNoDataValue().clone(); |
|
677 |
newLayer.setNoDataValue(nd); |
|
678 |
newLayer.enableOpen(); |
|
679 |
|
|
680 |
return newLayer; |
|
681 |
} |
|
682 |
|
|
683 |
/** |
|
684 |
* Assigns the flag to delete this layer from the cache |
|
685 |
* @param deleteCache |
|
686 |
*/ |
|
687 |
public void deleteCache(boolean deleteCache) { |
|
688 |
this.deleteCache = deleteCache; |
|
689 |
} |
|
690 |
} |
|
0 | 691 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.245/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){ |
Also available in: Unified diff