root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / View.java @ 6117
History | View | Annotate | Download (21.3 KB)
1 | 1103 | fjp | /* 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 | 312 | fernando | package com.iver.cit.gvsig.gui; |
42 | |||
43 | import java.awt.BorderLayout; |
||
44 | import java.awt.Color; |
||
45 | import java.awt.Dimension; |
||
46 | 5998 | fjp | import java.awt.event.ContainerAdapter; |
47 | import java.awt.event.ContainerEvent; |
||
48 | 596 | fernando | import java.awt.image.BufferedImage; |
49 | 644 | fernando | import java.beans.PropertyChangeEvent; |
50 | import java.beans.PropertyChangeListener; |
||
51 | 3714 | caballero | import java.util.HashMap; |
52 | import java.util.Iterator; |
||
53 | 312 | fernando | |
54 | import javax.swing.JPanel; |
||
55 | import javax.swing.JSplitPane; |
||
56 | 5998 | fjp | import javax.swing.SwingUtilities; |
57 | 312 | fernando | |
58 | 904 | fjp | import org.cresques.cts.IProjection; |
59 | |||
60 | 596 | fernando | import com.iver.andami.PluginServices; |
61 | 755 | fernando | import com.iver.andami.messages.NotificationManager; |
62 | 596 | fernando | import com.iver.andami.ui.mdiManager.SingletonView; |
63 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
64 | 960 | vcaballero | import com.iver.andami.ui.mdiManager.ViewListener; |
65 | 4741 | caballero | import com.iver.andami.ui.mdiManager.ViewTransform; |
66 | 1062 | fernando | import com.iver.cit.gvsig.fmap.ColorEvent; |
67 | import com.iver.cit.gvsig.fmap.ExtentEvent; |
||
68 | 312 | fernando | import com.iver.cit.gvsig.fmap.FMap; |
69 | 1223 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
70 | 5966 | fjp | import com.iver.cit.gvsig.fmap.ProjectionEvent; |
71 | 1062 | fernando | import com.iver.cit.gvsig.fmap.ViewPortListener; |
72 | 899 | vcaballero | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
73 | 4741 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayer; |
74 | 3714 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayers; |
75 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
76 | 1115 | fjp | import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
77 | 1221 | fernando | 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 | 2209 | vcaballero | import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
82 | import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
||
83 | 1221 | fernando | import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
84 | 6117 | jaume | import com.iver.cit.gvsig.gui.panels.MapOverViewPalette; |
85 | 480 | fjp | import com.iver.cit.gvsig.gui.toc.TOC; |
86 | 775 | vcaballero | 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 | 666 | fernando | import com.iver.cit.gvsig.gui.toolListeners.MeasureListener; |
90 | 842 | vcaballero | 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 | 2183 | fernando | import com.iver.cit.gvsig.gui.toolListeners.SelectImageListener; |
94 | 1009 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
95 | 842 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener; |
96 | import com.iver.cit.gvsig.gui.toolListeners.ZoomOutListener; |
||
97 | 2359 | igbrotru | import com.iver.cit.gvsig.gui.toolListeners.ZoomPixelCursorListener; |
98 | 1221 | fernando | import com.iver.cit.gvsig.project.ProjectView; |
99 | 3714 | caballero | import com.iver.utiles.console.JConsole; |
100 | 5998 | fjp | import com.iver.utiles.console.JDockPanel; |
101 | 3714 | caballero | import com.iver.utiles.console.ResponseListener; |
102 | 5839 | fjp | import com.iver.utiles.console.jedit.JEditTextArea; |
103 | 862 | fjp | import com.iver.utiles.exceptionHandling.ExceptionListener; |
104 | 312 | fernando | |
105 | |||
106 | /**
|
||
107 | 5787 | jaume | * <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 | 5808 | jaume | * View where the user can put some layers which summarizes the view. It is used to make
|
127 | 5787 | jaume | * 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 | 312 | fernando | * @author vcn
|
135 | */
|
||
136 | 904 | fjp | public class View extends JPanel implements com.iver.andami.ui.mdiManager.View, |
137 | 4741 | caballero | SingletonView,ViewListener, IView, ViewTransform{ |
138 | 312 | fernando | |
139 | 5900 | jorpiell | protected MapControl m_MapControl;
|
140 | protected MapOverview m_MapLoc;
|
||
141 | 5253 | caballero | |
142 | 5028 | cesar | // store the properties of the window
|
143 | private ViewInfo m_viewInfo = null; |
||
144 | 312 | fernando | |
145 | 5028 | cesar | |
146 | 312 | fernando | /** DOCUMENT ME! */
|
147 | 5900 | jorpiell | protected TOC m_TOC;
|
148 | 359 | fjp | private ProjectView modelo;
|
149 | 3714 | caballero | private ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
150 | private JConsole console;
|
||
151 | 5998 | fjp | private JDockPanel dockConsole = null; |
152 | 5900 | jorpiell | protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
153 | 4741 | caballero | private boolean isPalette=false; |
154 | private MapOverViewPalette movp;
|
||
155 | 5900 | jorpiell | protected boolean isShowConsole=false; |
156 | 3714 | caballero | /**
|
157 | 312 | fernando | * Creates a new View object.
|
158 | */
|
||
159 | public View() { |
||
160 | 5787 | jaume | this.setName("View"); |
161 | 312 | fernando | //this.setName(Utilities.getMessage(this, "Vista")+ " : "+modelo.getName());
|
162 | 3331 | fjp | // this.setPreferredSize(new Dimension(500, 300));
|
163 | 312 | fernando | initComponents(); |
164 | 3714 | caballero | hideConsole(); |
165 | 3727 | caballero | getConsolePanel().addResponseListener(consoleResponseAdapter); |
166 | 5998 | fjp | /* 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 | 312 | fernando | } |
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 | 457 | fernando | //Se registra como listener de cambios en FMap
|
211 | 312 | fernando | FMap fmap = modelo.getMapContext(); |
212 | |||
213 | 3714 | caballero | 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 | 5028 | cesar | model.setAndamiView(this);
|
220 | 3714 | caballero | |
221 | //Se configura el mapControl
|
||
222 | 312 | fernando | m_MapControl.setMapContext(fmap); |
223 | 493 | fjp | m_TOC.setMapContext(fmap); |
224 | 312 | fernando | m_MapControl.setBackground(new Color(255, 255, 255)); |
225 | 944 | vcaballero | if (modelo.getMapOverViewContext()!=null){ |
226 | m_MapLoc.setModel(modelo.getMapOverViewContext()); |
||
227 | } |
||
228 | 644 | fernando | 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 | 1367 | vcaballero | if (m_MapControl.getViewPort() != null){ |
236 | m_MapControl.getViewPort().addViewPortListener(new ViewPortListener() {
|
||
237 | public void extentChanged(ExtentEvent e) { |
||
238 | 3714 | caballero | if (PluginServices.getMainFrame() != null){ |
239 | 1367 | vcaballero | PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
240 | PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev());
|
||
241 | } |
||
242 | 1139 | vcaballero | } |
243 | 1062 | fernando | |
244 | 1367 | vcaballero | public void backColorChanged(ColorEvent e) { |
245 | } |
||
246 | 5939 | jmvivo | |
247 | public void projectionChanged(ProjectionEvent e) { |
||
248 | m_MapLoc.setProjection(e.getNewProjection()); |
||
249 | } |
||
250 | 3714 | caballero | }); |
251 | 1367 | vcaballero | } |
252 | 312 | fernando | } |
253 | 3714 | caballero | public JConsole getConsolePanel(){
|
254 | if (console==null){ |
||
255 | console=new JConsole();
|
||
256 | 5787 | jaume | // Para distinguir cuando se est? escribiendo sobre la consola y cuando no.
|
257 | 4459 | fjp | console.setJTextName("CADConsole");
|
258 | 3714 | caballero | } |
259 | return console;
|
||
260 | } |
||
261 | 5998 | fjp | |
262 | private JDockPanel getDockConsole()
|
||
263 | { |
||
264 | if (dockConsole == null) |
||
265 | { |
||
266 | dockConsole = new JDockPanel(getConsolePanel());
|
||
267 | } |
||
268 | return dockConsole;
|
||
269 | } |
||
270 | 312 | fernando | |
271 | 3714 | caballero | |
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 | 4212 | fjp | // TODO: HACE ESTO CON EL KEYBOARDFOCUSMANAGER
|
285 | 5839 | fjp | // 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 | 5828 | fjp | // FocusManager fm=FocusManager.getCurrentManager();
|
295 | // fm.focusNextComponent(getConsolePanel());
|
||
296 | 3714 | caballero | |
297 | } |
||
298 | |||
299 | 5998 | fjp | |
300 | 3714 | caballero | public void hideConsole() { |
301 | 5253 | caballero | isShowConsole=false;
|
302 | 5965 | fjp | /* removeAll();
|
303 | 3718 | caballero | //JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
304 | JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||
305 | tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
||
306 | 4741 | caballero | 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 | 3718 | caballero | 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 | 5965 | fjp | this.add(tempMainSplit, BorderLayout.CENTER); */
|
322 | 5998 | fjp | getDockConsole().setVisible(false);
|
323 | 3718 | caballero | |
324 | 3714 | caballero | } |
325 | |||
326 | public void showConsole() { |
||
327 | 5253 | caballero | if (isShowConsole)
|
328 | return;
|
||
329 | isShowConsole=true;
|
||
330 | 5965 | fjp | /* removeAll();
|
331 | 3718 | caballero | JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
332 | JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||
333 | tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
||
334 | 4741 | caballero | 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 | 3718 | caballero | 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 | 5965 | fjp | this.add(split, BorderLayout.CENTER); */
|
350 | 5998 | fjp | getMapControl().remove(getDockConsole()); |
351 | 5972 | fjp | // getConsolePanel().setPreferredSize(new Dimension(200, 150));
|
352 | 5965 | fjp | getMapControl().setLayout(new BorderLayout()); |
353 | 5998 | fjp | getMapControl().add(getDockConsole(), BorderLayout.SOUTH);
|
354 | getDockConsole().setVisible(true);
|
||
355 | 3718 | caballero | |
356 | 3714 | caballero | } |
357 | 5808 | jaume | |
358 | 3714 | caballero | 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 | 312 | fernando | /**
|
411 | 3714 | caballero | * DOCUMENT ME!
|
412 | */
|
||
413 | 5900 | jorpiell | protected void initComponents() { // GEN-BEGIN:initComponents |
414 | 3714 | caballero | m_MapControl = new MapControl(); // Default is paintEnabled = false. |
415 | // Remember to activate it
|
||
416 | 755 | fernando | m_MapControl.addExceptionListener(mapControlExceptionListener); |
417 | 359 | fjp | // modelo.setMapContext(m_MapControl.getMapContext());
|
418 | 312 | fernando | |
419 | // m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel
|
||
420 | 493 | fjp | m_TOC = new TOC();
|
421 | 312 | fernando | |
422 | 3718 | caballero | |
423 | 312 | fernando | // Ponemos el localizador
|
424 | 377 | fjp | m_MapLoc = new MapOverview(m_MapControl);
|
425 | 312 | fernando | m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
426 | 5965 | fjp | 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 | 312 | fernando | |
449 | |||
450 | |||
451 | 3714 | caballero | |
452 | 1062 | fernando | //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 | 3714 | caballero | |
455 | 375 | fjp | // 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 | 842 | vcaballero | ZoomOutListener zol = new ZoomOutListener(m_MapControl);
|
459 | 1221 | fernando | m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
460 | 3714 | caballero | |
461 | 375 | fjp | // pan
|
462 | |||
463 | 842 | vcaballero | PanListener pl = new PanListener(m_MapControl);
|
464 | 1221 | fernando | m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
465 | 3714 | caballero | |
466 | 375 | fjp | // Medir
|
467 | |||
468 | 666 | fernando | MeasureListener mli = new MeasureListener(m_MapControl);
|
469 | 1221 | fernando | m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
470 | 375 | fjp | |
471 | // Area
|
||
472 | |||
473 | 775 | vcaballero | AreaListener ali = new AreaListener(m_MapControl);
|
474 | 1221 | fernando | m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
475 | 3714 | caballero | |
476 | 457 | fernando | //Seleccion por punto
|
477 | 842 | vcaballero | PointSelectListener psl = new PointSelectListener(m_MapControl);
|
478 | 1221 | fernando | m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
479 | 3714 | caballero | |
480 | 482 | vcaballero | //Info por punto
|
481 | InfoListener il = new InfoListener(m_MapControl);
|
||
482 | 1221 | fernando | m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
483 | 3714 | caballero | |
484 | 775 | vcaballero | // Link por punto
|
485 | LinkListener ll = new LinkListener(m_MapControl);
|
||
486 | 1221 | fernando | m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
487 | 3714 | caballero | |
488 | 457 | fernando | //Selecci?n por rect?ngulo
|
489 | 842 | vcaballero | RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl);
|
490 | 1221 | fernando | m_MapControl.addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
491 | 1062 | fernando | |
492 | // Zoom por rect?ngulo
|
||
493 | 1115 | fjp | ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl);
|
494 | 1062 | fernando | ZoomInListener zil = new ZoomInListener(m_MapControl);
|
495 | 1221 | fernando | m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
496 | new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
||
497 | 3714 | caballero | |
498 | 2183 | fernando | SelectImageListener sil = new SelectImageListener(m_MapControl);
|
499 | m_MapControl.addMapTool("selectImage", new Behavior[]{ |
||
500 | new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
||
501 | 3714 | caballero | |
502 | 2359 | igbrotru | ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl);
|
503 | m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
||
504 | 3714 | caballero | |
505 | 457 | fernando | m_MapControl.setTool("zoomIn"); // Por defecto |
506 | 3331 | fjp | // m_MapControl.setPaintEnabled(true);
|
507 | 312 | fernando | } |
508 | |||
509 | /**
|
||
510 | * DOCUMENT ME!
|
||
511 | */
|
||
512 | 960 | vcaballero | /*public void openPropertiesWindow() {
|
513 | 312 | fernando | }
|
514 | 960 | vcaballero | */
|
515 | 312 | fernando | /**
|
516 | * DOCUMENT ME!
|
||
517 | */
|
||
518 | 960 | vcaballero | /* public void openQueryWindow() {
|
519 | 312 | fernando | }
|
520 | 960 | vcaballero | */
|
521 | 312 | fernando | /**
|
522 | * DOCUMENT ME!
|
||
523 | *
|
||
524 | * @return DOCUMENT ME!
|
||
525 | */
|
||
526 | 655 | fjp | public MapOverview getMapOverview() {
|
527 | 312 | fernando | return m_MapLoc;
|
528 | } |
||
529 | |||
530 | /**
|
||
531 | * DOCUMENT ME!
|
||
532 | *
|
||
533 | * @return DOCUMENT ME!
|
||
534 | */
|
||
535 | 1223 | fernando | public MapControl getMapControl() {
|
536 | 312 | fernando | return m_MapControl;
|
537 | } |
||
538 | |||
539 | /**
|
||
540 | * DOCUMENT ME!
|
||
541 | *
|
||
542 | * @return DOCUMENT ME!
|
||
543 | */
|
||
544 | public TOC getTOC() {
|
||
545 | 5808 | jaume | return m_TOC;
|
546 | 312 | fernando | } |
547 | |||
548 | /**
|
||
549 | * DOCUMENT ME!
|
||
550 | */
|
||
551 | public void repaintMap() { |
||
552 | 3422 | fjp | m_MapControl.drawMap(false);
|
553 | 312 | fernando | } |
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 | 5028 | cesar | * 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 | 5253 | caballero | *
|
569 | 312 | fernando | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
570 | */
|
||
571 | public ViewInfo getViewInfo() {
|
||
572 | 5028 | cesar | if (m_viewInfo == null) |
573 | { |
||
574 | m_viewInfo = new ViewInfo(ViewInfo.ICONIFIABLE | ViewInfo.RESIZABLE |
|
||
575 | 312 | fernando | ViewInfo.MAXIMIZABLE); |
576 | |||
577 | m_viewInfo.setWidth(500);
|
||
578 | m_viewInfo.setHeight(300);
|
||
579 | 5028 | cesar | m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
580 | 312 | fernando | modelo.getName()); |
581 | 5028 | cesar | } |
582 | return m_viewInfo;
|
||
583 | 312 | fernando | } |
584 | |||
585 | 5253 | caballero | |
586 | 312 | fernando | /**
|
587 | * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
||
588 | */
|
||
589 | public void viewActivated() { |
||
590 | 899 | vcaballero | PluginServices.getMainFrame().getStatusBar().setMessage("1",
|
591 | 2544 | caballero | FConstant.NAMES[getMapControl().getMapContext().getViewPort().getDistanceUnits()]); |
592 | 1367 | vcaballero | PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
593 | 2685 | fjp | PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev());
|
594 | 1367 | vcaballero | } |
595 | 312 | fernando | |
596 | /**
|
||
597 | * @return
|
||
598 | */
|
||
599 | 596 | fernando | public BufferedImage getImage() { |
600 | 312 | fernando | return m_MapControl.getImage();
|
601 | } |
||
602 | 3714 | caballero | |
603 | 904 | fjp | public void setProjection(IProjection proj) |
604 | { |
||
605 | getMapControl().setProjection(proj); |
||
606 | } |
||
607 | public IProjection getProjection()
|
||
608 | { |
||
609 | return getMapControl().getProjection();
|
||
610 | } |
||
611 | 3714 | caballero | |
612 | 755 | fernando | 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 | 3714 | caballero | |
621 | 755 | fernando | } |
622 | 899 | vcaballero | |
623 | /**
|
||
624 | * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
|
||
625 | */
|
||
626 | public void viewClosed() { |
||
627 | 4741 | caballero | if (movp!=null) |
628 | PluginServices.getMDIManager().closeView(movp); |
||
629 | 899 | vcaballero | ///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
630 | } |
||
631 | 3714 | caballero | |
632 | 4741 | caballero | 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 | 312 | fernando | } |