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