Revision 36475 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/gui/DefaultViewPanel.java
DefaultViewPanel.java | ||
---|---|---|
1 | 1 |
/* gvSIG. Geographic Information System of the Valencian Government |
2 |
* |
|
3 |
* Copyright (C) 2007-2009 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2004-2009 IVER TI |
|
26 |
* |
|
27 |
*/ |
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2004-2009 IVER TI
|
|
26 |
*
|
|
27 |
*/
|
|
28 | 28 |
package org.gvsig.app.project.documents.view.gui; |
29 | 29 |
|
30 | 30 |
import java.awt.BorderLayout; |
... | ... | |
42 | 42 |
import org.gvsig.andami.ui.mdiFrame.NewStatusBar; |
43 | 43 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
44 | 44 |
import org.gvsig.app.project.DefaultProject; |
45 |
import org.gvsig.app.project.Project; |
|
46 | 45 |
import org.gvsig.app.project.documents.Document; |
47 | 46 |
import org.gvsig.app.project.documents.view.MapOverview; |
48 | 47 |
import org.gvsig.app.project.documents.view.ViewDocument; |
... | ... | |
84 | 83 |
import org.gvsig.utils.console.ResponseListener; |
85 | 84 |
import org.gvsig.utils.console.jedit.JEditTextArea; |
86 | 85 |
|
87 |
|
|
88 |
|
|
89 | 86 |
/** |
90 | 87 |
* <p> |
91 |
* <b>Class View</b>. This class represents the gvSIG specific internal window where the maps are |
|
92 |
* displayed and where the events coming from the user are captured. |
|
88 |
* <b>Class View</b>. This class represents the gvSIG specific internal window |
|
89 |
* where the maps are displayed and where the events coming from the user are |
|
90 |
* captured. |
|
93 | 91 |
* </p> |
94 | 92 |
* <p> |
95 | 93 |
* It is composed by three main visual areas: |
96 | 94 |
* </p> |
97 | 95 |
* <ol> |
98 |
* <li> |
|
99 |
* <b>Map control</b>: the map area located in the right area of the window. It takes up |
|
100 |
* the biggest part of the window. |
|
101 |
* </li> |
|
102 |
* <li> |
|
103 |
* <b>Table of contents (TOC)</b>: is a list of layers displayed in the view. The TOC is |
|
104 |
* located on the left-top corner of the View and is the place where the user can modify |
|
105 |
* the order, the legends, the visibility and other properties of the layers. |
|
106 |
* </li> |
|
107 |
* <li> |
|
108 |
* <b>Map overview</b>: is a small MapControl located in the left-bottom corner of the |
|
109 |
* View where the user can put some layers which summarizes the view. It is used to make |
|
110 |
* the navigation easier and faster. |
|
111 |
* </li> |
|
96 |
* <li> |
|
97 |
* <b>Map control</b>: the map area located in the right area of the window. It |
|
98 |
* takes up the biggest part of the window.</li> |
|
99 |
* <li> |
|
100 |
* <b>Table of contents (TOC)</b>: is a list of layers displayed in the view. |
|
101 |
* The TOC is located on the left-top corner of the View and is the place where |
|
102 |
* the user can modify the order, the legends, the visibility and other |
|
103 |
* properties of the layers.</li> |
|
104 |
* <li> |
|
105 |
* <b>Map overview</b>: is a small MapControl located in the left-bottom corner |
|
106 |
* of the View where the user can put some layers which summarizes the view. It |
|
107 |
* is used to make the navigation easier and faster.</li> |
|
112 | 108 |
* </ol> |
113 |
* |
|
114 |
* @author 2005- Vicente Caballero |
|
115 |
* @author 2009- Joaquin del Cerro |
|
116 | 109 |
* |
110 |
* @author 2005- Vicente Caballero |
|
111 |
* @author 2009- Joaquin del Cerro |
|
112 |
* |
|
117 | 113 |
*/ |
118 | 114 |
public class DefaultViewPanel extends AbstractViewPanel { |
119 |
/** |
|
115 |
|
|
116 |
/** |
|
120 | 117 |
* |
121 | 118 |
*/ |
122 |
private static final long serialVersionUID = -4044661458841786519L;
|
|
123 |
|
|
119 |
private static final long serialVersionUID = -4044661458841786519L;
|
|
120 |
|
|
124 | 121 |
private JConsole console; |
125 |
private JDockPanel dockConsole = null; |
|
126 |
protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
|
127 |
protected boolean isShowConsole=false; |
|
128 |
private ViewPortListener viewPortListener; |
|
129 |
private static MapControlManager mapControlManager = MapControlLocator.getMapControlManager(); |
|
122 |
private JDockPanel dockConsole = null; |
|
123 |
protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
|
124 |
protected boolean isShowConsole = false; |
|
125 |
private ViewPortListener viewPortListener; |
|
126 |
private static MapControlManager mapControlManager = MapControlLocator |
|
127 |
.getMapControlManager(); |
|
130 | 128 |
|
131 |
/**
|
|
129 |
/**
|
|
132 | 130 |
* Creates a new View object. Before being used, the object must be |
133 | 131 |
* initialized. |
134 |
* |
|
132 |
*
|
|
135 | 133 |
* @see initialize() |
136 | 134 |
*/ |
137 | 135 |
public DefaultViewPanel() { |
138 |
super();
|
|
139 |
this.setName("View");
|
|
140 |
//TODO Remove this when the system lo load libraries is finished
|
|
141 |
if (mapControlManager == null){
|
|
142 |
mapControlManager = MapControlLocator.getMapControlManager();
|
|
143 |
}
|
|
136 |
super();
|
|
137 |
this.setName("View");
|
|
138 |
// TODO Remove this when the system lo load libraries is finished
|
|
139 |
if (mapControlManager == null) {
|
|
140 |
mapControlManager = MapControlLocator.getMapControlManager();
|
|
141 |
}
|
|
144 | 142 |
} |
145 | 143 |
|
146 | 144 |
public DefaultViewPanel(Document document) { |
... | ... | |
148 | 146 |
this.initialize(); |
149 | 147 |
this.setDocument(document); |
150 | 148 |
} |
151 |
|
|
149 |
|
|
152 | 150 |
/** |
153 | 151 |
* Create the internal componentes and populate the window with them. |
154 | 152 |
* If the layout properties were set using the |
155 |
* <code>setWindowData(WindowData)</code> |
|
156 |
* method, the window will be populated according to this
|
|
153 |
* <code>setWindowData(WindowData)</code> method, the window will be
|
|
154 |
* populated according to this |
|
157 | 155 |
* properties. |
158 | 156 |
*/ |
159 | 157 |
protected void initialize() { |
160 |
super.initialize();
|
|
161 |
initComponents();
|
|
162 |
hideConsole();
|
|
158 |
super.initialize();
|
|
159 |
initComponents();
|
|
160 |
hideConsole();
|
|
163 | 161 |
getConsolePanel().addResponseListener(consoleResponseAdapter); |
164 | 162 |
} |
165 | 163 |
|
166 | 164 |
public void setDocument(Document document) { |
167 |
setModel((ViewDocument) document);
|
|
165 |
setModel((ViewDocument) document);
|
|
168 | 166 |
} |
169 |
|
|
167 |
|
|
170 | 168 |
public Document getDocument() { |
171 |
return this.modelo;
|
|
169 |
return this.modelo;
|
|
172 | 170 |
} |
173 |
|
|
171 |
|
|
174 | 172 |
public void setModel(ViewDocument model) { |
175 | 173 |
this.modelo = model; |
176 |
//Se registra como listener de cambios en FMap |
|
174 |
// Se registra como listener de cambios en FMap
|
|
177 | 175 |
MapContext fmap = modelo.getMapContext(); |
178 |
|
|
179 |
FLayers layers=fmap.getLayers(); |
|
180 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
181 |
if (layers.getLayer(i).isEditing() && layers.getLayer(i) instanceof FLyrVect){ |
|
182 |
this.showConsole(); |
|
183 |
} |
|
184 |
} |
|
185 | 176 |
|
186 |
//Se configura el mapControl |
|
177 |
FLayers layers = fmap.getLayers(); |
|
178 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
179 |
if (layers.getLayer(i).isEditing() |
|
180 |
&& layers.getLayer(i) instanceof FLyrVect) { |
|
181 |
this.showConsole(); |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
// Se configura el mapControl |
|
187 | 186 |
m_MapControl.setMapContext(fmap); |
188 | 187 |
m_TOC.setMapContext(fmap); |
189 | 188 |
m_MapControl.getMapContext().getLayers().addLegendListener(m_TOC); |
190 | 189 |
|
191 | 190 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
192 |
if (modelo.getMapOverViewContext()!=null){
|
|
193 |
m_MapLoc.setModel(modelo.getMapOverViewContext());
|
|
191 |
if (modelo.getMapOverViewContext() != null) {
|
|
192 |
m_MapLoc.setModel(modelo.getMapOverViewContext());
|
|
194 | 193 |
} |
195 | 194 |
model.addPropertyChangeListener(new PropertyChangeListener() { |
196 |
public void propertyChange(PropertyChangeEvent evt) { |
|
197 |
if (evt.getPropertyName().equals("name")){ |
|
198 |
PluginServices.getMDIManager().getWindowInfo(DefaultViewPanel.this).setTitle("Vista: " + (String)evt.getNewValue()); |
|
199 |
} |
|
200 |
} |
|
201 |
}); |
|
202 |
if (m_MapControl.getViewPort() != null){ |
|
203 |
viewPortListener=new ViewPortListener() { |
|
204 |
public void extentChanged(ExtentEvent e) { |
|
205 |
if (PluginServices.getMainFrame() != null){ |
|
206 |
PluginServices.getMainFrame().getStatusBar().setControlValue("scale",String.valueOf(m_MapControl.getMapContext().getScaleView())); |
|
207 |
PluginServices.getMainFrame().getStatusBar().setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev()); |
|
208 |
} |
|
209 |
} |
|
210 | 195 |
|
211 |
public void backColorChanged(ColorEvent e) { |
|
212 |
// Do nothing |
|
213 |
} |
|
196 |
public void propertyChange(PropertyChangeEvent evt) { |
|
197 |
if (evt.getPropertyName().equals("name")) { |
|
198 |
PluginServices.getMDIManager() |
|
199 |
.getWindowInfo(DefaultViewPanel.this) |
|
200 |
.setTitle("Vista: " + (String) evt.getNewValue()); |
|
201 |
} |
|
202 |
} |
|
203 |
}); |
|
204 |
if (m_MapControl.getViewPort() != null) { |
|
205 |
viewPortListener = new ViewPortListener() { |
|
214 | 206 |
|
215 |
public void projectionChanged(ProjectionEvent e) { |
|
216 |
m_MapLoc.setProjection(e.getNewProjection()); |
|
217 |
} |
|
218 |
}; |
|
219 |
m_MapControl.getViewPort().addViewPortListener(viewPortListener); |
|
220 |
} |
|
207 |
public void extentChanged(ExtentEvent e) { |
|
208 |
if (PluginServices.getMainFrame() != null) { |
|
209 |
PluginServices |
|
210 |
.getMainFrame() |
|
211 |
.getStatusBar() |
|
212 |
.setControlValue( |
|
213 |
"scale", |
|
214 |
String.valueOf(m_MapControl.getMapContext() |
|
215 |
.getScaleView())); |
|
216 |
PluginServices |
|
217 |
.getMainFrame() |
|
218 |
.getStatusBar() |
|
219 |
.setMessage( |
|
220 |
"projection", |
|
221 |
getMapControl().getViewPort().getProjection() |
|
222 |
.getAbrev()); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
public void backColorChanged(ColorEvent e) { |
|
227 |
// Do nothing |
|
228 |
} |
|
229 |
|
|
230 |
public void projectionChanged(ProjectionEvent e) { |
|
231 |
m_MapLoc.setProjection(e.getNewProjection()); |
|
232 |
} |
|
233 |
}; |
|
234 |
m_MapControl.getViewPort().addViewPortListener(viewPortListener); |
|
235 |
} |
|
221 | 236 |
} |
222 | 237 |
|
223 |
public JConsole getConsolePanel(){ |
|
224 |
if (console==null){ |
|
225 |
console=new JConsole(); |
|
226 |
// Para distinguir cuando se est? escribiendo sobre la consola y cuando no. |
|
227 |
console.setJTextName("CADConsole"); |
|
228 |
} |
|
229 |
return console; |
|
238 |
public JConsole getConsolePanel() { |
|
239 |
if (console == null) { |
|
240 |
console = new JConsole(); |
|
241 |
// Para distinguir cuando se est? escribiendo sobre la consola y |
|
242 |
// cuando no. |
|
243 |
console.setJTextName("CADConsole"); |
|
244 |
} |
|
245 |
return console; |
|
230 | 246 |
} |
231 | 247 |
|
232 |
private JDockPanel getDockConsole() |
|
233 |
{ |
|
234 |
if (dockConsole == null) |
|
235 |
{ |
|
236 |
dockConsole = new JDockPanel(getConsolePanel()); |
|
237 |
} |
|
238 |
return dockConsole; |
|
248 |
private JDockPanel getDockConsole() { |
|
249 |
if (dockConsole == null) { |
|
250 |
dockConsole = new JDockPanel(getConsolePanel()); |
|
251 |
} |
|
252 |
return dockConsole; |
|
239 | 253 |
} |
240 | 254 |
|
241 |
|
|
242 | 255 |
public void addConsoleListener(String prefix, ResponseListener listener) { |
243 |
consoleResponseAdapter.putSpaceListener(prefix, listener);
|
|
256 |
consoleResponseAdapter.putSpaceListener(prefix, listener);
|
|
244 | 257 |
|
245 |
}
|
|
258 |
}
|
|
246 | 259 |
|
247 |
public void removeConsoleListener(ResponseListener listener) {
|
|
248 |
consoleResponseAdapter.deleteListener(listener);
|
|
260 |
public void removeConsoleListener(ResponseListener listener) {
|
|
261 |
consoleResponseAdapter.deleteListener(listener);
|
|
249 | 262 |
|
250 |
}
|
|
263 |
}
|
|
251 | 264 |
|
252 |
public void focusConsole(String text) {
|
|
253 |
getConsolePanel().addResponseText(text);
|
|
265 |
public void focusConsole(String text) {
|
|
266 |
getConsolePanel().addResponseText(text);
|
|
254 | 267 |
|
255 |
JEditTextArea jeta=getConsolePanel().getTxt();
|
|
256 |
jeta.requestFocusInWindow();
|
|
257 |
jeta.setCaretPosition(jeta.getText().length());
|
|
268 |
JEditTextArea jeta = getConsolePanel().getTxt();
|
|
269 |
jeta.requestFocusInWindow();
|
|
270 |
jeta.setCaretPosition(jeta.getText().length());
|
|
258 | 271 |
|
259 |
}
|
|
272 |
}
|
|
260 | 273 |
|
274 |
public void hideConsole() { |
|
275 |
isShowConsole = false; |
|
276 |
getDockConsole().setVisible(false); |
|
261 | 277 |
|
262 |
public void hideConsole() { |
|
263 |
isShowConsole=false; |
|
264 |
getDockConsole().setVisible(false); |
|
278 |
} |
|
265 | 279 |
|
266 |
} |
|
280 |
public void showConsole() { |
|
281 |
if (isShowConsole) { |
|
282 |
return; |
|
283 |
} |
|
284 |
isShowConsole = true; |
|
285 |
getMapControl().remove(getDockConsole()); |
|
286 |
getMapControl().setLayout(new BorderLayout()); |
|
287 |
getMapControl().add(getDockConsole(), BorderLayout.SOUTH); |
|
288 |
getDockConsole().setVisible(true); |
|
267 | 289 |
|
268 |
public void showConsole() { |
|
269 |
if (isShowConsole) { |
|
270 |
return; |
|
271 |
} |
|
272 |
isShowConsole=true; |
|
273 |
getMapControl().remove(getDockConsole()); |
|
274 |
getMapControl().setLayout(new BorderLayout()); |
|
275 |
getMapControl().add(getDockConsole(), BorderLayout.SOUTH); |
|
276 |
getDockConsole().setVisible(true); |
|
290 |
} |
|
277 | 291 |
|
278 |
}
|
|
292 |
static class ResponseAdapter implements ResponseListener {
|
|
279 | 293 |
|
280 |
static class ResponseAdapter implements ResponseListener{ |
|
294 |
private HashMap<String, ResponseListener> spaceListener = |
|
295 |
new HashMap<String, ResponseListener>(); |
|
281 | 296 |
|
282 |
private HashMap<String,ResponseListener> spaceListener = new HashMap<String,ResponseListener>(); |
|
297 |
public void putSpaceListener(String namespace, ResponseListener listener) { |
|
298 |
spaceListener.put(namespace, listener); |
|
299 |
} |
|
283 | 300 |
|
284 |
public void putSpaceListener(String namespace, ResponseListener listener){ |
|
285 |
spaceListener.put(namespace, listener); |
|
286 |
} |
|
301 |
public void acceptResponse(String response) { |
|
302 |
boolean nameSpace = false; |
|
303 |
int n = -1; |
|
304 |
if (response != null) { |
|
305 |
if ((n = response.indexOf(':')) != -1) { |
|
306 |
nameSpace = true; |
|
307 |
} |
|
308 |
} |
|
287 | 309 |
|
288 |
@SuppressWarnings("null") |
|
289 |
public void acceptResponse(String response) { |
|
290 |
boolean nameSpace = false; |
|
291 |
int n = -1; |
|
292 |
if (response != null){ |
|
293 |
if ((n = response.indexOf(':')) != -1){ |
|
294 |
nameSpace = true; |
|
295 |
} |
|
296 |
} |
|
310 |
if (nameSpace) { |
|
311 |
ResponseListener listener = |
|
312 |
spaceListener.get(response.substring(0, n)); |
|
313 |
if (listener != null) { |
|
314 |
listener.acceptResponse(response.substring(n + 1)); |
|
315 |
} |
|
316 |
} else { |
|
317 |
Iterator<ResponseListener> i = |
|
318 |
spaceListener.values().iterator(); |
|
319 |
while (i.hasNext()) { |
|
320 |
ResponseListener listener = i.next(); |
|
321 |
listener.acceptResponse(response); |
|
322 |
} |
|
323 |
} |
|
324 |
} |
|
297 | 325 |
|
298 |
if (nameSpace){
|
|
299 |
ResponseListener listener = spaceListener.get(response.substring(0, n));
|
|
300 |
if (listener != null) {
|
|
301 |
listener.acceptResponse(response.substring(n+1));
|
|
302 |
}
|
|
303 |
}else{
|
|
304 |
Iterator<ResponseListener> i = spaceListener.values().iterator();
|
|
305 |
while (i.hasNext()) {
|
|
306 |
ResponseListener listener = i.next();
|
|
307 |
listener.acceptResponse(response);
|
|
308 |
}
|
|
309 |
}
|
|
310 |
}
|
|
326 |
/**
|
|
327 |
* @param listener
|
|
328 |
*/
|
|
329 |
public void deleteListener(ResponseListener listener) {
|
|
330 |
Iterator<String> i = spaceListener.keySet().iterator();
|
|
331 |
while (i.hasNext()) {
|
|
332 |
String namespace = i.next();
|
|
333 |
ResponseListener l = spaceListener.get(namespace);
|
|
334 |
if (l == listener) {
|
|
335 |
spaceListener.remove(namespace);
|
|
336 |
}
|
|
337 |
}
|
|
338 |
}
|
|
311 | 339 |
|
312 |
/** |
|
313 |
* @param listener |
|
314 |
*/ |
|
315 |
public void deleteListener(ResponseListener listener) { |
|
316 |
Iterator<String> i = spaceListener.keySet().iterator(); |
|
317 |
while (i.hasNext()) { |
|
318 |
String namespace = i.next(); |
|
319 |
ResponseListener l = spaceListener.get(namespace); |
|
320 |
if (l == listener){ |
|
321 |
spaceListener.remove(namespace); |
|
322 |
} |
|
323 |
} |
|
324 |
} |
|
340 |
} |
|
325 | 341 |
|
326 |
} |
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 | 342 |
protected void initComponents() { // GEN-BEGIN:initComponents |
332 | 343 |
m_MapControl = new MapControl(); // Default is paintEnabled = false. |
333 |
// Remember to activate it
|
|
344 |
// Remember to activate it
|
|
334 | 345 |
try { |
335 |
m_MapControl.setMapControlDrawer(mapControlManager.createDefaultMapControlDrawer()); |
|
336 |
} catch (MapControlCreationException e) { |
|
337 |
NotificationManager.addError(e); |
|
338 |
} |
|
339 |
|
|
346 |
m_MapControl.setMapControlDrawer(mapControlManager |
|
347 |
.createDefaultMapControlDrawer()); |
|
348 |
} catch (MapControlCreationException e) { |
|
349 |
NotificationManager.addError(e); |
|
350 |
} |
|
351 |
|
|
340 | 352 |
m_MapControl.addExceptionListener(mapControlExceptionListener); |
341 | 353 |
m_TOC = new TOC(); |
342 | 354 |
|
343 | 355 |
// Ponemos el localizador |
344 | 356 |
m_MapLoc = new MapOverview(m_MapControl); |
345 | 357 |
try { |
346 |
m_MapLoc.setMapControlDrawer(mapControlManager.createDefaultMapControlDrawer()); |
|
347 |
} catch (MapControlCreationException e) { |
|
348 |
NotificationManager.addError(e); |
|
349 |
} |
|
350 |
removeAll(); |
|
351 |
tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
|
358 |
m_MapLoc.setMapControlDrawer(mapControlManager |
|
359 |
.createDefaultMapControlDrawer()); |
|
360 |
} catch (MapControlCreationException e) { |
|
361 |
NotificationManager.addError(e); |
|
362 |
} |
|
363 |
removeAll(); |
|
364 |
tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
|
352 | 365 |
|
353 |
if (windowLayout==null) {
|
|
354 |
m_MapLoc.setPreferredSize(new Dimension(150, 200));
|
|
355 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
|
356 |
}
|
|
366 |
if (windowLayout == null) {
|
|
367 |
m_MapLoc.setPreferredSize(new Dimension(150, 200));
|
|
368 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
|
369 |
}
|
|
357 | 370 |
|
358 |
if (!isPalette()){ |
|
359 |
tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
360 |
tempSplitToc.setTopComponent(m_TOC); |
|
361 |
tempSplitToc.setBottomComponent(m_MapLoc); |
|
362 |
tempSplitToc.setResizeWeight(0.7); |
|
363 |
tempMainSplit.setLeftComponent(tempSplitToc); |
|
364 |
}else{ |
|
365 |
tempMainSplit.setLeftComponent(m_TOC); |
|
366 |
} |
|
367 |
m_TOC.setVisible(true); |
|
368 |
tempMainSplit.setRightComponent(m_MapControl); |
|
369 |
//split.setBottomComponent(getConsolePanel()); |
|
370 |
//split.setTopComponent(tempMainSplit); |
|
371 |
// split.setResizeWeight(0.9); |
|
372 |
this.setLayout(new BorderLayout()); |
|
373 |
this.add(tempMainSplit, BorderLayout.CENTER); |
|
371 |
if (!isPalette()) { |
|
372 |
tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
373 |
tempSplitToc.setTopComponent(m_TOC); |
|
374 |
tempSplitToc.setBottomComponent(m_MapLoc); |
|
375 |
tempSplitToc.setResizeWeight(0.7); |
|
376 |
tempMainSplit.setLeftComponent(tempSplitToc); |
|
377 |
} else { |
|
378 |
tempMainSplit.setLeftComponent(m_TOC); |
|
379 |
} |
|
380 |
m_TOC.setVisible(true); |
|
381 |
tempMainSplit.setRightComponent(m_MapControl); |
|
382 |
this.setLayout(new BorderLayout()); |
|
383 |
this.add(tempMainSplit, BorderLayout.CENTER); |
|
374 | 384 |
|
385 |
if (windowLayout != null) { |
|
386 |
try { |
|
387 |
tempMainSplit.setDividerLocation(Integer.valueOf( |
|
388 |
windowLayout.get("MainDivider.Location")).intValue()); |
|
389 |
if (windowLayout.get("TOCDivider.Location") != null) { |
|
390 |
tempSplitToc.setDividerLocation(Integer.valueOf( |
|
391 |
windowLayout.get("TOCDivider.Location")).intValue()); |
|
392 |
} |
|
393 |
} catch (NumberFormatException ex) { |
|
394 |
PluginServices.getLogger().error( |
|
395 |
"Error restoring View properties"); |
|
396 |
} |
|
397 |
} |
|
375 | 398 |
|
376 |
if (windowLayout!=null) { |
|
377 |
try { |
|
378 |
tempMainSplit.setDividerLocation(Integer.valueOf(windowLayout.get("MainDivider.Location")).intValue()); |
|
379 |
if (windowLayout.get("TOCDivider.Location")!=null) { |
|
380 |
tempSplitToc.setDividerLocation(Integer.valueOf(windowLayout.get("TOCDivider.Location")).intValue()); |
|
381 |
} |
|
382 |
} |
|
383 |
catch (NumberFormatException ex) { |
|
384 |
PluginServices.getLogger().error("Error restoring View properties"); |
|
385 |
} |
|
386 |
} |
|
387 |
|
|
388 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado |
|
399 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n |
|
400 |
// en la barra de estado |
|
389 | 401 |
StatusBarListener sbl = new StatusBarListener(m_MapControl); |
390 | 402 |
|
391 | 403 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s). |
392 | 404 |
// No es dibujando un rect?ngulo, es solo pinchando. |
393 | 405 |
|
394 | 406 |
ZoomOutListener zol = new ZoomOutListener(m_MapControl); |
395 |
m_MapControl.addBehavior("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
|
407 |
m_MapControl.addBehavior("zoomOut", new Behavior[] { |
|
408 |
new PointBehavior(zol), new MouseMovementBehavior(sbl) }); |
|
396 | 409 |
|
397 | 410 |
// pan |
398 | 411 |
|
399 | 412 |
PanListener pl = new PanListener(m_MapControl); |
400 |
m_MapControl.addBehavior("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
|
413 |
m_MapControl.addBehavior("pan", new Behavior[] { new MoveBehavior(pl), |
|
414 |
new MouseMovementBehavior(sbl) }); |
|
401 | 415 |
|
402 | 416 |
// Medir |
403 | 417 |
|
404 | 418 |
MeasureListener mli = new MeasureListener(m_MapControl); |
405 |
m_MapControl.addBehavior("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
|
419 |
m_MapControl.addBehavior("medicion", new Behavior[] { |
|
420 |
new PolylineBehavior(mli), new MouseMovementBehavior(sbl) }); |
|
406 | 421 |
|
407 | 422 |
// Area |
408 | 423 |
|
409 | 424 |
AreaListener ali = new AreaListener(m_MapControl); |
410 |
m_MapControl.addBehavior("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
|
425 |
m_MapControl.addBehavior("area", new Behavior[] { |
|
426 |
new PolygonBehavior(ali), new MouseMovementBehavior(sbl) }); |
|
411 | 427 |
|
412 |
//Seleccion por punto |
|
428 |
// Seleccion por punto
|
|
413 | 429 |
PointSelectListener psl = new PointSelectListener(m_MapControl); |
414 |
m_MapControl.addBehavior("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
|
430 |
m_MapControl.addBehavior("pointSelection", new Behavior[] { |
|
431 |
new PointBehavior(psl), new MouseMovementBehavior(sbl) }); |
|
415 | 432 |
|
416 |
//Info por punto |
|
433 |
// Info por punto
|
|
417 | 434 |
InfoListener il = new InfoListener(m_MapControl); |
418 |
m_MapControl.addBehavior("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
|
435 |
m_MapControl.addBehavior("info", new Behavior[] { |
|
436 |
new PointBehavior(il), new MouseMovementBehavior(sbl) }); |
|
419 | 437 |
|
420 |
// Link por punto
|
|
438 |
// Link por punto
|
|
421 | 439 |
LinkListener ll = new LinkListener(m_MapControl); |
422 |
m_MapControl.addBehavior("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
|
440 |
m_MapControl.addBehavior("link", new Behavior[] { |
|
441 |
new PointBehavior(ll), new MouseMovementBehavior(sbl) }); |
|
423 | 442 |
|
424 |
//Selecci?n por rect?ngulo |
|
443 |
// Selecci?n por rect?ngulo
|
|
425 | 444 |
RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl); |
426 |
m_MapControl.addBehavior("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
|
445 |
m_MapControl.addBehavior("rectSelection", new Behavior[] { |
|
446 |
new RectangleBehavior(rsl), new MouseMovementBehavior(sbl) }); |
|
427 | 447 |
|
428 |
//Selecci?n por pol?gono |
|
429 |
PolygonSelectListener poligSel = new PolygonSelectListener(m_MapControl); |
|
430 |
m_MapControl.addBehavior("polSelection", new Behavior[]{new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl)}); |
|
448 |
// Selecci?n por pol?gono |
|
449 |
PolygonSelectListener poligSel = |
|
450 |
new PolygonSelectListener(m_MapControl); |
|
451 |
m_MapControl.addBehavior("polSelection", new Behavior[] { |
|
452 |
new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl) }); |
|
431 | 453 |
|
432 | 454 |
// Zoom por rect?ngulo |
433 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl); |
|
455 |
ZoomOutRightButtonListener zoil = |
|
456 |
new ZoomOutRightButtonListener(m_MapControl); |
|
434 | 457 |
ZoomInListener zil = new ZoomInListener(m_MapControl); |
435 |
m_MapControl.addBehavior("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
|
436 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
|
458 |
m_MapControl.addBehavior("zoomIn", new Behavior[] { |
|
459 |
new RectangleBehavior(zil), new PointBehavior(zoil), |
|
460 |
new MouseMovementBehavior(sbl) }); |
|
437 | 461 |
|
438 | 462 |
SelectImageListener sil = new SelectImageListener(m_MapControl); |
439 |
m_MapControl.addBehavior("selectImage", new Behavior[]{ |
|
440 |
new PointBehavior(sil), new MouseMovementBehavior(sbl)});
|
|
463 |
m_MapControl.addBehavior("selectImage", new Behavior[] {
|
|
464 |
new PointBehavior(sil), new MouseMovementBehavior(sbl) });
|
|
441 | 465 |
|
442 |
//ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl); |
|
443 |
//m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
|
444 |
|
|
445 | 466 |
m_MapControl.setTool("zoomIn"); // Por defecto |
446 |
// m_MapControl.setPaintEnabled(true); |
|
447 | 467 |
} |
448 | 468 |
|
449 | 469 |
public void windowActivated() { |
450 |
NewStatusBar statusbar = PluginServices.getMainFrame().getStatusBar(); |
|
451 |
MapContext mapContext = this.getMapControl().getMapContext(); |
|
452 |
|
|
453 |
statusbar.setMessage("units", PluginServices.getText(this, mapContext.getDistanceName())); |
|
454 |
statusbar.setControlValue("scale",String.valueOf( mapContext.getScaleView() )); |
|
455 |
statusbar.setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev()); |
|
470 |
NewStatusBar statusbar = PluginServices.getMainFrame().getStatusBar(); |
|
471 |
MapContext mapContext = this.getMapControl().getMapContext(); |
|
472 |
|
|
473 |
statusbar.setMessage("units", |
|
474 |
PluginServices.getText(this, mapContext.getDistanceName())); |
|
475 |
statusbar.setControlValue("scale", |
|
476 |
String.valueOf(mapContext.getScaleView())); |
|
477 |
statusbar.setMessage("projection", getMapControl().getViewPort() |
|
478 |
.getProjection().getAbrev()); |
|
456 | 479 |
} |
457 | 480 |
|
458 | 481 |
public void windowClosed() { |
459 |
super.windowClosed(); |
|
460 |
if (viewPortListener!=null) { |
|
461 |
getMapControl().getViewPort().removeViewPortListener(viewPortListener); |
|
462 |
} |
|
463 |
if (getMapOverview()!=null) { |
|
464 |
getMapOverview().getViewPort().removeViewPortListener(getMapOverview()); |
|
465 |
} |
|
482 |
super.windowClosed(); |
|
483 |
if (viewPortListener != null) { |
|
484 |
getMapControl().getViewPort().removeViewPortListener( |
|
485 |
viewPortListener); |
|
486 |
} |
|
487 |
if (getMapOverview() != null) { |
|
488 |
getMapOverview().getViewPort().removeViewPortListener( |
|
489 |
getMapOverview()); |
|
490 |
} |
|
466 | 491 |
|
467 |
} |
|
468 |
public void toPalette() { |
|
469 |
isPalette=true; |
|
470 |
m_MapLoc.setPreferredSize(new Dimension(200,150)); |
|
471 |
m_MapLoc.setSize(new Dimension(200,150)); |
|
472 |
movp=new MapOverViewPalette(m_MapLoc,this); |
|
473 |
PluginServices.getMDIManager().addWindow(movp); |
|
474 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives(); |
|
475 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
|
476 |
if (((FLyrVect)layers[0]).isEditing()){ |
|
477 |
showConsole(); |
|
478 |
return; |
|
479 |
} |
|
480 |
} |
|
481 |
hideConsole(); |
|
492 |
} |
|
482 | 493 |
|
483 |
} |
|
494 |
public void toPalette() { |
|
495 |
isPalette = true; |
|
496 |
m_MapLoc.setPreferredSize(new Dimension(200, 150)); |
|
497 |
m_MapLoc.setSize(new Dimension(200, 150)); |
|
498 |
movp = new MapOverViewPalette(m_MapLoc, this); |
|
499 |
PluginServices.getMDIManager().addWindow(movp); |
|
500 |
FLayer[] layers = |
|
501 |
getViewDocument().getMapContext().getLayers().getActives(); |
|
502 |
if (layers.length > 0 && layers[0] instanceof FLyrVect) { |
|
503 |
if (((FLyrVect) layers[0]).isEditing()) { |
|
504 |
showConsole(); |
|
505 |
return; |
|
506 |
} |
|
507 |
} |
|
508 |
hideConsole(); |
|
484 | 509 |
|
485 |
public void restore() { |
|
486 |
isPalette=false; |
|
487 |
PluginServices.getMDIManager().closeWindow(movp); |
|
488 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives(); |
|
489 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
|
490 |
if (((FLyrVect)layers[0]).isEditing()){ |
|
491 |
showConsole(); |
|
492 |
return; |
|
493 |
} |
|
494 |
} |
|
495 |
hideConsole(); |
|
496 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
497 |
tempSplitToc.setTopComponent(m_TOC); |
|
498 |
tempSplitToc.setBottomComponent(m_MapLoc); |
|
499 |
tempSplitToc.setResizeWeight(0.7); |
|
500 |
tempMainSplit.setLeftComponent(tempSplitToc); |
|
501 |
} |
|
510 |
} |
|
502 | 511 |
|
503 |
/** |
|
504 |
* Sets the default map overview background color that will be used in subsequent |
|
505 |
* projects. |
|
506 |
* |
|
507 |
* @param color |
|
508 |
* @deprecated use instead Project.getPreferences().setDefaultMapoverViewBackColor |
|
509 |
*/ |
|
510 |
public static void setDefaultMapOverViewBackColor(Color color) { |
|
511 |
DefaultProject.getPreferences().setDefaultOverviewBackColor(color); |
|
512 |
} |
|
512 |
public void restore() { |
|
513 |
isPalette = false; |
|
514 |
PluginServices.getMDIManager().closeWindow(movp); |
|
515 |
FLayer[] layers = |
|
516 |
getViewDocument().getMapContext().getLayers().getActives(); |
|
517 |
if (layers.length > 0 && layers[0] instanceof FLyrVect) { |
|
518 |
if (((FLyrVect) layers[0]).isEditing()) { |
|
519 |
showConsole(); |
|
520 |
return; |
|
521 |
} |
|
522 |
} |
|
523 |
hideConsole(); |
|
524 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
525 |
tempSplitToc.setTopComponent(m_TOC); |
|
526 |
tempSplitToc.setBottomComponent(m_MapLoc); |
|
527 |
tempSplitToc.setResizeWeight(0.7); |
|
528 |
tempMainSplit.setLeftComponent(tempSplitToc); |
|
529 |
} |
|
513 | 530 |
|
514 |
/** |
|
515 |
* Returns the current default map overview background color defined which |
|
516 |
* is the color defined when the user does not define any other one |
|
517 |
* |
|
518 |
* @return java.awt.Color |
|
519 |
* @deprecated use instead Project.getPreferences().setDefaultMapoverViewBackColor |
|
520 |
*/ |
|
521 |
public static Color getDefaultMapOverViewBackColor() { |
|
522 |
return DefaultProject.getPreferences().getDefaultOverviewBackColor(); |
|
523 |
} |
|
531 |
/** |
|
532 |
* Sets the default map overview background color that will be used in |
|
533 |
* subsequent |
|
534 |
* projects. |
|
535 |
* |
|
536 |
* @param color |
|
537 |
* @deprecated use instead |
|
538 |
* Project.getPreferences().setDefaultMapoverViewBackColor |
|
539 |
*/ |
|
540 |
public static void setDefaultMapOverViewBackColor(Color color) { |
|
541 |
DefaultProject.getPreferences().setDefaultOverviewBackColor(color); |
|
542 |
} |
|
524 | 543 |
|
525 |
/** |
|
526 |
* Returns the current default view background color defined which is the |
|
527 |
* color defined when the user does not define any other one |
|
528 |
* @return java.awt.Color |
|
529 |
* @deprecated use instead Project.getPreferences().getDefaultViewBackColor |
|
530 |
*/ |
|
531 |
public static Color getDefaultBackColor() { |
|
532 |
return DefaultProject.getPreferences().getDefaultViewBackColor(); |
|
533 |
} |
|
544 |
/** |
|
545 |
* Returns the current default map overview background color defined which |
|
546 |
* is the color defined when the user does not define any other one |
|
547 |
* |
|
548 |
* @return java.awt.Color |
|
549 |
* @deprecated use instead |
|
550 |
* Project.getPreferences().setDefaultMapoverViewBackColor |
|
551 |
*/ |
|
552 |
public static Color getDefaultMapOverViewBackColor() { |
|
553 |
return DefaultProject.getPreferences().getDefaultOverviewBackColor(); |
|
554 |
} |
|
534 | 555 |
|
535 |
/** |
|
536 |
* @deprecated use instead Project.getPreferences().setDefaultViewBackColor |
|
537 |
*/ |
|
538 |
public static void setDefaultBackColor(Color color) { |
|
539 |
DefaultProject.getPreferences().setDefaultViewBackColor(color); |
|
540 |
} |
|
556 |
/** |
|
557 |
* Returns the current default view background color defined which is the |
|
558 |
* color defined when the user does not define any other one |
|
559 |
* |
|
560 |
* @return java.awt.Color |
|
561 |
* @deprecated use instead Project.getPreferences().getDefaultViewBackColor |
|
562 |
*/ |
|
563 |
public static Color getDefaultBackColor() { |
|
564 |
return DefaultProject.getPreferences().getDefaultViewBackColor(); |
|
565 |
} |
|
541 | 566 |
|
542 |
public Object getWindowProfile() { |
|
543 |
return WindowInfo.EDITOR_PROFILE; |
|
544 |
} |
|
567 |
/** |
|
568 |
* @deprecated use instead Project.getPreferences().setDefaultViewBackColor |
|
569 |
*/ |
|
570 |
public static void setDefaultBackColor(Color color) { |
|
571 |
DefaultProject.getPreferences().setDefaultViewBackColor(color); |
|
572 |
} |
|
545 | 573 |
|
574 |
public Object getWindowProfile() { |
|
575 |
return WindowInfo.EDITOR_PROFILE; |
|
576 |
} |
|
577 |
|
|
546 | 578 |
} |
Also available in: Unified diff