gvsig-webmap / org.gvsig.googlemaps / trunk / org.gvsig.googlemaps / org.gvsig.googlemaps.app / org.gvsig.googlemaps.app.streetview / src / main / java / org / gvsig / googlemaps / app / streetview / GoogleStreetViewExtension.java @ 135
History | View | Annotate | Download (4.54 KB)
1 | 1 | dmartinezizquierdo | /* gvSIG. Desktop Geographic Information System.
|
---|---|---|---|
2 | *
|
||
3 | * Copyright ? 2007-2016 gvSIG Association
|
||
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., 51 Franklin Street, Fifth Floor, Boston,
|
||
18 | * MA 02110-1301, USA.
|
||
19 | *
|
||
20 | * For any additional information, do not hesitate to contact us
|
||
21 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
22 | */
|
||
23 | package org.gvsig.googlemaps.app.streetview; |
||
24 | |||
25 | import org.slf4j.Logger; |
||
26 | import org.slf4j.LoggerFactory; |
||
27 | |||
28 | import org.gvsig.andami.IconThemeHelper; |
||
29 | import org.gvsig.andami.plugins.Extension; |
||
30 | import org.gvsig.app.ApplicationLocator; |
||
31 | import org.gvsig.app.ApplicationManager; |
||
32 | import org.gvsig.app.project.documents.view.ViewDocument; |
||
33 | import org.gvsig.app.project.documents.view.gui.IView; |
||
34 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
35 | import org.gvsig.fmap.mapcontext.ViewPort; |
||
36 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
37 | import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
||
38 | import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener; |
||
39 | import org.gvsig.tools.ToolsLocator; |
||
40 | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
||
41 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
42 | |||
43 | |||
44 | /**
|
||
45 | * @author fdiaz
|
||
46 | *
|
||
47 | */
|
||
48 | public class GoogleStreetViewExtension extends Extension { |
||
49 | |||
50 | private static final Logger logger = LoggerFactory |
||
51 | .getLogger(GoogleStreetViewExtension.class); |
||
52 | |||
53 | public static final String PERSIST_GOOGLEMAPSAPIKEY_KEY = "apiKey"; |
||
54 | 135 | dmartinezizquierdo | public static final String PERSIST_DISCLAIMER_URL = "disclaimerURL"; |
55 | 1 | dmartinezizquierdo | |
56 | /* (non-Javadoc)
|
||
57 | * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
||
58 | */
|
||
59 | @Override
|
||
60 | public void execute(String s) { |
||
61 | ApplicationManager application = ApplicationLocator.getManager(); |
||
62 | |||
63 | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
||
64 | if (view == null) { |
||
65 | return;
|
||
66 | } |
||
67 | ViewDocument document = view.getViewDocument(); |
||
68 | if (s.compareTo("google-street-view") == 0) { |
||
69 | MapControl mapCtrl = view.getMapControl(); |
||
70 | |||
71 | if (!mapCtrl.hasTool("google-street-view")) { |
||
72 | // Info por punto
|
||
73 | PointListener il = new StreetViewListener(mapCtrl);
|
||
74 | mapCtrl.addBehavior("google-street-view", new PointBehavior(il)); |
||
75 | } |
||
76 | mapCtrl.setTool("google-street-view");
|
||
77 | document.setModified(true);
|
||
78 | } |
||
79 | } |
||
80 | |||
81 | /* (non-Javadoc)
|
||
82 | * @see org.gvsig.andami.plugins.IExtension#initialize()
|
||
83 | */
|
||
84 | @Override
|
||
85 | public void initialize() { |
||
86 | IconThemeHelper.registerIcon("action", "street-view_16", this); |
||
87 | IconThemeHelper.registerIcon("cursor", "street-view_cursor", this); |
||
88 | IconThemeHelper.registerIcon("preferences", "street-view-preferences", this); |
||
89 | |||
90 | ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
||
91 | ExtensionPoint ep = extensionPoints.add("AplicationPreferences", ""); |
||
92 | |||
93 | ep.append("GoogleStreetViewPreferencePage", "", new GoogleStreetViewPreferencePage()); |
||
94 | |||
95 | } |
||
96 | |||
97 | /* (non-Javadoc)
|
||
98 | * @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
||
99 | */
|
||
100 | @Override
|
||
101 | public boolean isEnabled() { |
||
102 | ApplicationManager application = ApplicationLocator.getManager(); |
||
103 | |||
104 | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
||
105 | if (view != null) { |
||
106 | ViewPort viewPort = view.getMapControl().getViewPort(); |
||
107 | Envelope viewPortEnvelope = viewPort.getEnvelope(); |
||
108 | if(viewPortEnvelope == null || viewPortEnvelope.isEmpty()){ |
||
109 | return false; |
||
110 | } |
||
111 | return true; |
||
112 | } |
||
113 | return false; |
||
114 | } |
||
115 | |||
116 | /* (non-Javadoc)
|
||
117 | * @see org.gvsig.andami.plugins.IExtension#isVisible()
|
||
118 | */
|
||
119 | @Override
|
||
120 | public boolean isVisible() { |
||
121 | ApplicationManager application = ApplicationLocator.getManager(); |
||
122 | |||
123 | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
||
124 | if (view != null) { |
||
125 | return true; |
||
126 | } |
||
127 | return false; |
||
128 | } |
||
129 | |||
130 | } |