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