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