root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / View.java @ 5965
History | View | Annotate | Download (20.1 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Color; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.KeyboardFocusManager; |
47 |
import java.awt.image.BufferedImage; |
48 |
import java.beans.PropertyChangeEvent; |
49 |
import java.beans.PropertyChangeListener; |
50 |
import java.util.HashMap; |
51 |
import java.util.Iterator; |
52 |
|
53 |
import javax.swing.FocusManager; |
54 |
import javax.swing.JPanel; |
55 |
import javax.swing.JSplitPane; |
56 |
|
57 |
import org.cresques.cts.IProjection; |
58 |
|
59 |
import com.iver.andami.PluginServices; |
60 |
import com.iver.andami.messages.NotificationManager; |
61 |
import com.iver.andami.ui.mdiManager.MDIManager; |
62 |
import com.iver.andami.ui.mdiManager.SingletonView; |
63 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
64 |
import com.iver.andami.ui.mdiManager.ViewListener; |
65 |
import com.iver.andami.ui.mdiManager.ViewTransform; |
66 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
67 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
68 |
import com.iver.cit.gvsig.fmap.FMap; |
69 |
import com.iver.cit.gvsig.fmap.MapControl; |
70 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
71 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
72 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
73 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
74 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
75 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
76 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
77 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
78 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MoveBehavior; |
79 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
80 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
81 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
82 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
83 |
import com.iver.cit.gvsig.gui.Panels.MapOverViewPalette; |
84 |
import com.iver.cit.gvsig.gui.toc.TOC; |
85 |
import com.iver.cit.gvsig.gui.toolListeners.AreaListener; |
86 |
import com.iver.cit.gvsig.gui.toolListeners.InfoListener; |
87 |
import com.iver.cit.gvsig.gui.toolListeners.LinkListener; |
88 |
import com.iver.cit.gvsig.gui.toolListeners.MeasureListener; |
89 |
import com.iver.cit.gvsig.gui.toolListeners.PanListener; |
90 |
import com.iver.cit.gvsig.gui.toolListeners.PointSelectListener; |
91 |
import com.iver.cit.gvsig.gui.toolListeners.RectangleSelectListener; |
92 |
import com.iver.cit.gvsig.gui.toolListeners.SelectImageListener; |
93 |
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
94 |
import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener; |
95 |
import com.iver.cit.gvsig.gui.toolListeners.ZoomOutListener; |
96 |
import com.iver.cit.gvsig.gui.toolListeners.ZoomPixelCursorListener; |
97 |
import com.iver.cit.gvsig.project.ProjectView; |
98 |
import com.iver.utiles.console.JConsole; |
99 |
import com.iver.utiles.console.ResponseListener; |
100 |
import com.iver.utiles.console.jedit.JEditTextArea; |
101 |
import com.iver.utiles.exceptionHandling.ExceptionListener; |
102 |
|
103 |
|
104 |
/**
|
105 |
* <p>
|
106 |
* <b>Class View</b>. This class represents the gvSIG specific internal window where the maps are
|
107 |
* displayed and where the events coming from the user are captured.
|
108 |
* </p>
|
109 |
* <p>
|
110 |
* It is composed by three main visual areas:
|
111 |
* </p>
|
112 |
* <ol>
|
113 |
* <li>
|
114 |
* <b>Map control</b>: the map area located in the right area of the window. It takes up
|
115 |
* the biggest part of the window.
|
116 |
* </li>
|
117 |
* <li>
|
118 |
* <b>Table of contents (TOC)</b>: is a list of layers displayed in the view. The TOC is
|
119 |
* located on the left-top corner of the View and is the place where the user can modify
|
120 |
* the order, the legends, the visibility and other properties of the layers.
|
121 |
* </li>
|
122 |
* <li>
|
123 |
* <b>Map overview</b>: is a small MapControl located in the left-bottom corner of the
|
124 |
* View where the user can put some layers which summarizes the view. It is used to make
|
125 |
* the navigation easier and faster.
|
126 |
* </li>
|
127 |
* </ol>
|
128 |
*
|
129 |
* @see com.iver.cit.gvsig.fmap.MapControl.java <br>
|
130 |
* com.iver.cit.gvsig.gui.toc.TOC.java <br>
|
131 |
* com.iver.cit.gvsig.gui.MapOverview.java <br>
|
132 |
* @author vcn
|
133 |
*/
|
134 |
public class View extends JPanel implements com.iver.andami.ui.mdiManager.View, |
135 |
SingletonView,ViewListener, IView, ViewTransform{ |
136 |
|
137 |
protected MapControl m_MapControl;
|
138 |
protected MapOverview m_MapLoc;
|
139 |
|
140 |
// store the properties of the window
|
141 |
private ViewInfo m_viewInfo = null; |
142 |
|
143 |
|
144 |
/** DOCUMENT ME! */
|
145 |
protected TOC m_TOC;
|
146 |
private ProjectView modelo;
|
147 |
private ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
148 |
private JConsole console;
|
149 |
protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
150 |
private boolean isPalette=false; |
151 |
private MapOverViewPalette movp;
|
152 |
protected boolean isShowConsole=false; |
153 |
/**
|
154 |
* Creates a new View object.
|
155 |
*/
|
156 |
public View() { |
157 |
this.setName("View"); |
158 |
//this.setName(Utilities.getMessage(this, "Vista")+ " : "+modelo.getName());
|
159 |
// this.setPreferredSize(new Dimension(500, 300));
|
160 |
initComponents(); |
161 |
hideConsole(); |
162 |
getConsolePanel().addResponseListener(consoleResponseAdapter); |
163 |
} |
164 |
|
165 |
/**
|
166 |
* DOCUMENT ME!
|
167 |
*
|
168 |
* @return DOCUMENT ME!
|
169 |
*/
|
170 |
public ProjectView getModel() {
|
171 |
return modelo;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* DOCUMENT ME!
|
176 |
*
|
177 |
* @param model DOCUMENT ME!
|
178 |
*/
|
179 |
public void setModel(ProjectView model) { |
180 |
this.modelo = model;
|
181 |
//Se registra como listener de cambios en FMap
|
182 |
FMap fmap = modelo.getMapContext(); |
183 |
|
184 |
FLayers layers=fmap.getLayers(); |
185 |
for (int i=0;i<layers.getLayersCount();i++){ |
186 |
if (layers.getLayer(i).isEditing() && layers.getLayer(i) instanceof FLyrVect){ |
187 |
this.showConsole();
|
188 |
} |
189 |
} |
190 |
model.setAndamiView(this);
|
191 |
|
192 |
//Se configura el mapControl
|
193 |
m_MapControl.setMapContext(fmap); |
194 |
m_TOC.setMapContext(fmap); |
195 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
196 |
if (modelo.getMapOverViewContext()!=null){ |
197 |
m_MapLoc.setModel(modelo.getMapOverViewContext()); |
198 |
} |
199 |
model.addPropertyChangeListener(new PropertyChangeListener() { |
200 |
public void propertyChange(PropertyChangeEvent evt) { |
201 |
if (evt.getPropertyName().equals("name")){ |
202 |
PluginServices.getMDIManager().getViewInfo(View.this).setTitle("Vista: " + (String)evt.getNewValue()); |
203 |
} |
204 |
} |
205 |
}); |
206 |
if (m_MapControl.getViewPort() != null){ |
207 |
m_MapControl.getViewPort().addViewPortListener(new ViewPortListener() {
|
208 |
public void extentChanged(ExtentEvent e) { |
209 |
if (PluginServices.getMainFrame() != null){ |
210 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
211 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev());
|
212 |
} |
213 |
} |
214 |
|
215 |
public void backColorChanged(ColorEvent e) { |
216 |
} |
217 |
|
218 |
public void projectionChanged(ProjectionEvent e) { |
219 |
m_MapLoc.setProjection(e.getNewProjection()); |
220 |
} |
221 |
}); |
222 |
} |
223 |
} |
224 |
public JConsole getConsolePanel(){
|
225 |
if (console==null){ |
226 |
console=new JConsole();
|
227 |
// Para distinguir cuando se est? escribiendo sobre la consola y cuando no.
|
228 |
console.setJTextName("CADConsole");
|
229 |
} |
230 |
return console;
|
231 |
} |
232 |
|
233 |
|
234 |
public void addConsoleListener(String prefix, ResponseListener listener) { |
235 |
consoleResponseAdapter.putSpaceListener(prefix, listener); |
236 |
|
237 |
} |
238 |
|
239 |
public void removeConsoleListener(ResponseListener listener) { |
240 |
consoleResponseAdapter.deleteListener(listener); |
241 |
|
242 |
} |
243 |
|
244 |
public void focusConsole(String text) { |
245 |
getConsolePanel().addResponseText(text); |
246 |
// TODO: HACE ESTO CON EL KEYBOARDFOCUSMANAGER
|
247 |
// KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
248 |
// kfm.focusNextComponent(getConsolePanel());
|
249 |
System.err.println("Asigno el foco a la consola"); |
250 |
|
251 |
JEditTextArea jeta=getConsolePanel().getTxt(); |
252 |
jeta.requestFocusInWindow(); |
253 |
jeta.setCaretPosition(jeta.getText().length()); |
254 |
|
255 |
|
256 |
// FocusManager fm=FocusManager.getCurrentManager();
|
257 |
// fm.focusNextComponent(getConsolePanel());
|
258 |
|
259 |
} |
260 |
|
261 |
public void hideConsole() { |
262 |
isShowConsole=false;
|
263 |
/* removeAll();
|
264 |
//JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
265 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
266 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
267 |
if (!isPalette()){
|
268 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
269 |
tempSplitToc.setTopComponent((TOC) m_TOC);
|
270 |
tempSplitToc.setBottomComponent(m_MapLoc);
|
271 |
tempSplitToc.setResizeWeight(0.7);
|
272 |
tempMainSplit.setLeftComponent(tempSplitToc);
|
273 |
}else{
|
274 |
tempMainSplit.setLeftComponent(m_TOC);
|
275 |
}
|
276 |
m_TOC.setVisible(true);
|
277 |
tempMainSplit.setRightComponent(m_MapControl);
|
278 |
//split.setBottomComponent(getConsolePanel());
|
279 |
//split.setTopComponent(tempMainSplit);
|
280 |
// split.setResizeWeight(0.9);
|
281 |
this.setLayout(new BorderLayout());
|
282 |
this.add(tempMainSplit, BorderLayout.CENTER); */
|
283 |
getConsolePanel().setVisible(false);
|
284 |
|
285 |
} |
286 |
|
287 |
public void showConsole() { |
288 |
if (isShowConsole)
|
289 |
return;
|
290 |
isShowConsole=true;
|
291 |
/* removeAll();
|
292 |
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
293 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
294 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
295 |
if (!isPalette()){
|
296 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
297 |
tempSplitToc.setTopComponent((TOC) m_TOC);
|
298 |
tempSplitToc.setBottomComponent(m_MapLoc);
|
299 |
tempSplitToc.setResizeWeight(0.7);
|
300 |
tempMainSplit.setLeftComponent(tempSplitToc);
|
301 |
}else{
|
302 |
tempMainSplit.setLeftComponent(m_TOC);
|
303 |
}
|
304 |
m_TOC.setVisible(true);
|
305 |
tempMainSplit.setRightComponent(m_MapControl);
|
306 |
split.setBottomComponent(getConsolePanel());
|
307 |
split.setTopComponent(tempMainSplit);
|
308 |
split.setResizeWeight(0.9);
|
309 |
this.setLayout(new BorderLayout());
|
310 |
this.add(split, BorderLayout.CENTER); */
|
311 |
getMapControl().remove(getConsolePanel()); |
312 |
getConsolePanel().setPreferredSize(new Dimension(200, 150)); |
313 |
getMapControl().setLayout(new BorderLayout()); |
314 |
getMapControl().add(getConsolePanel(), BorderLayout.SOUTH);
|
315 |
getConsolePanel().setVisible(true);
|
316 |
|
317 |
} |
318 |
|
319 |
private class ResponseAdapter implements ResponseListener{ |
320 |
|
321 |
private HashMap spaceListener = new HashMap(); |
322 |
|
323 |
public void putSpaceListener(String namespace, ResponseListener listener){ |
324 |
spaceListener.put(namespace, listener); |
325 |
} |
326 |
|
327 |
/**
|
328 |
* @see com.iver.utiles.console.ResponseListener#acceptResponse(java.lang.String)
|
329 |
*/
|
330 |
public void acceptResponse(String response) { |
331 |
boolean nameSpace = false; |
332 |
int n = -1; |
333 |
if (response != null){ |
334 |
if ((n = response.indexOf(':')) != -1){ |
335 |
nameSpace = true;
|
336 |
} |
337 |
} |
338 |
|
339 |
if (nameSpace){
|
340 |
ResponseListener listener = (ResponseListener) spaceListener.get(response.substring(0, n));
|
341 |
if (listener != null) |
342 |
listener.acceptResponse(response.substring(n+1));
|
343 |
}else{
|
344 |
Iterator i = spaceListener.values().iterator();
|
345 |
while (i.hasNext()) {
|
346 |
ResponseListener listener = (ResponseListener) i.next(); |
347 |
listener.acceptResponse(response); |
348 |
} |
349 |
} |
350 |
} |
351 |
|
352 |
/**
|
353 |
* @param listener
|
354 |
*/
|
355 |
public void deleteListener(ResponseListener listener) { |
356 |
Iterator i = spaceListener.keySet().iterator();
|
357 |
while (i.hasNext()) {
|
358 |
String namespace = (String) i.next(); |
359 |
ResponseListener l = (ResponseListener) spaceListener.get(namespace); |
360 |
if (l == listener){
|
361 |
spaceListener.remove(namespace); |
362 |
} |
363 |
} |
364 |
} |
365 |
|
366 |
} |
367 |
|
368 |
|
369 |
|
370 |
|
371 |
/**
|
372 |
* DOCUMENT ME!
|
373 |
*/
|
374 |
protected void initComponents() { // GEN-BEGIN:initComponents |
375 |
m_MapControl = new MapControl(); // Default is paintEnabled = false. |
376 |
// Remember to activate it
|
377 |
m_MapControl.addExceptionListener(mapControlExceptionListener); |
378 |
// modelo.setMapContext(m_MapControl.getMapContext());
|
379 |
|
380 |
// m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel
|
381 |
m_TOC = new TOC();
|
382 |
|
383 |
|
384 |
// Ponemos el localizador
|
385 |
m_MapLoc = new MapOverview(m_MapControl);
|
386 |
m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
387 |
removeAll(); |
388 |
//JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
389 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
390 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
391 |
if (!isPalette()){
|
392 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
393 |
tempSplitToc.setTopComponent((TOC) m_TOC); |
394 |
tempSplitToc.setBottomComponent(m_MapLoc); |
395 |
tempSplitToc.setResizeWeight(0.7);
|
396 |
tempMainSplit.setLeftComponent(tempSplitToc); |
397 |
}else{
|
398 |
tempMainSplit.setLeftComponent(m_TOC); |
399 |
} |
400 |
m_TOC.setVisible(true);
|
401 |
tempMainSplit.setRightComponent(m_MapControl); |
402 |
//split.setBottomComponent(getConsolePanel());
|
403 |
//split.setTopComponent(tempMainSplit);
|
404 |
// split.setResizeWeight(0.9);
|
405 |
this.setLayout(new BorderLayout()); |
406 |
this.add(tempMainSplit, BorderLayout.CENTER); |
407 |
|
408 |
// hideConsole();
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado
|
414 |
StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
415 |
|
416 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
417 |
// No es dibujando un rect?ngulo, es solo pinchando.
|
418 |
|
419 |
ZoomOutListener zol = new ZoomOutListener(m_MapControl);
|
420 |
m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
421 |
|
422 |
// pan
|
423 |
|
424 |
PanListener pl = new PanListener(m_MapControl);
|
425 |
m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
426 |
|
427 |
// Medir
|
428 |
|
429 |
MeasureListener mli = new MeasureListener(m_MapControl);
|
430 |
m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
431 |
|
432 |
// Area
|
433 |
|
434 |
AreaListener ali = new AreaListener(m_MapControl);
|
435 |
m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
436 |
|
437 |
//Seleccion por punto
|
438 |
PointSelectListener psl = new PointSelectListener(m_MapControl);
|
439 |
m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
440 |
|
441 |
//Info por punto
|
442 |
InfoListener il = new InfoListener(m_MapControl);
|
443 |
m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
444 |
|
445 |
// Link por punto
|
446 |
LinkListener ll = new LinkListener(m_MapControl);
|
447 |
m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
448 |
|
449 |
//Selecci?n por rect?ngulo
|
450 |
RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl);
|
451 |
m_MapControl.addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
452 |
|
453 |
// Zoom por rect?ngulo
|
454 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl);
|
455 |
ZoomInListener zil = new ZoomInListener(m_MapControl);
|
456 |
m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
457 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
458 |
|
459 |
SelectImageListener sil = new SelectImageListener(m_MapControl);
|
460 |
m_MapControl.addMapTool("selectImage", new Behavior[]{ |
461 |
new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
462 |
|
463 |
ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl);
|
464 |
m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
465 |
|
466 |
m_MapControl.setTool("zoomIn"); // Por defecto |
467 |
// m_MapControl.setPaintEnabled(true);
|
468 |
} |
469 |
|
470 |
/**
|
471 |
* DOCUMENT ME!
|
472 |
*/
|
473 |
/*public void openPropertiesWindow() {
|
474 |
}
|
475 |
*/
|
476 |
/**
|
477 |
* DOCUMENT ME!
|
478 |
*/
|
479 |
/* public void openQueryWindow() {
|
480 |
}
|
481 |
*/
|
482 |
/**
|
483 |
* DOCUMENT ME!
|
484 |
*
|
485 |
* @return DOCUMENT ME!
|
486 |
*/
|
487 |
public MapOverview getMapOverview() {
|
488 |
return m_MapLoc;
|
489 |
} |
490 |
|
491 |
/**
|
492 |
* DOCUMENT ME!
|
493 |
*
|
494 |
* @return DOCUMENT ME!
|
495 |
*/
|
496 |
public MapControl getMapControl() {
|
497 |
return m_MapControl;
|
498 |
} |
499 |
|
500 |
/**
|
501 |
* DOCUMENT ME!
|
502 |
*
|
503 |
* @return DOCUMENT ME!
|
504 |
*/
|
505 |
public TOC getTOC() {
|
506 |
return m_TOC;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* DOCUMENT ME!
|
511 |
*/
|
512 |
public void repaintMap() { |
513 |
m_MapControl.drawMap(false);
|
514 |
} |
515 |
|
516 |
/* (non-Javadoc)
|
517 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonView#getModel()
|
518 |
*/
|
519 |
public Object getViewModel() { |
520 |
return modelo;
|
521 |
} |
522 |
|
523 |
/**
|
524 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
525 |
* for this View. It is not intended to retrieve the ViewInfo object in a
|
526 |
* later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
527 |
* to retrieve the ViewInfo object at any time after the creation of the
|
528 |
* object.
|
529 |
*
|
530 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
531 |
*/
|
532 |
public ViewInfo getViewInfo() {
|
533 |
if (m_viewInfo == null) |
534 |
{ |
535 |
m_viewInfo = new ViewInfo(ViewInfo.ICONIFIABLE | ViewInfo.RESIZABLE |
|
536 |
ViewInfo.MAXIMIZABLE); |
537 |
|
538 |
m_viewInfo.setWidth(500);
|
539 |
m_viewInfo.setHeight(300);
|
540 |
m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
541 |
modelo.getName()); |
542 |
} |
543 |
return m_viewInfo;
|
544 |
} |
545 |
|
546 |
|
547 |
/**
|
548 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
549 |
*/
|
550 |
public void viewActivated() { |
551 |
PluginServices.getMainFrame().getStatusBar().setMessage("1",
|
552 |
FConstant.NAMES[getMapControl().getMapContext().getViewPort().getDistanceUnits()]); |
553 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
554 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev());
|
555 |
} |
556 |
|
557 |
/**
|
558 |
* @return
|
559 |
*/
|
560 |
public BufferedImage getImage() { |
561 |
return m_MapControl.getImage();
|
562 |
} |
563 |
|
564 |
public void setProjection(IProjection proj) |
565 |
{ |
566 |
getMapControl().setProjection(proj); |
567 |
} |
568 |
public IProjection getProjection()
|
569 |
{ |
570 |
return getMapControl().getProjection();
|
571 |
} |
572 |
|
573 |
public class ViewExceptionListener implements ExceptionListener { |
574 |
|
575 |
/**
|
576 |
* @see com.iver.cit.gvsig.fmap.ExceptionListener#exceptionThrown(java.lang.Throwable)
|
577 |
*/
|
578 |
public void exceptionThrown(Throwable t) { |
579 |
NotificationManager.addError(t.getMessage(), t); |
580 |
} |
581 |
|
582 |
} |
583 |
|
584 |
/**
|
585 |
* @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
|
586 |
*/
|
587 |
public void viewClosed() { |
588 |
if (movp!=null) |
589 |
PluginServices.getMDIManager().closeView(movp); |
590 |
///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
591 |
} |
592 |
|
593 |
public void toPalette() { |
594 |
isPalette=true;
|
595 |
m_MapLoc.setPreferredSize(new Dimension(200,150)); |
596 |
m_MapLoc.setSize(new Dimension(200,150)); |
597 |
movp=new MapOverViewPalette(m_MapLoc);
|
598 |
PluginServices.getMDIManager().addView(movp); |
599 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives();
|
600 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
601 |
if (((FLyrVect)layers[0]).isEditing()){ |
602 |
showConsole(); |
603 |
return;
|
604 |
} |
605 |
} |
606 |
hideConsole(); |
607 |
|
608 |
} |
609 |
|
610 |
public void restore() { |
611 |
isPalette=false;
|
612 |
PluginServices.getMDIManager().closeView(movp); |
613 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives();
|
614 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
615 |
if (((FLyrVect)layers[0]).isEditing()){ |
616 |
showConsole(); |
617 |
return;
|
618 |
} |
619 |
} |
620 |
hideConsole(); |
621 |
} |
622 |
|
623 |
public boolean isPalette() { |
624 |
return isPalette;
|
625 |
} |
626 |
} |