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