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 | 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 | 596 | fernando | import java.awt.image.BufferedImage; |
47 | 644 | fernando | import java.beans.PropertyChangeEvent; |
48 | import java.beans.PropertyChangeListener; |
||
49 | 3714 | caballero | import java.util.HashMap; |
50 | import java.util.Iterator; |
||
51 | 312 | fernando | |
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JSplitPane; |
||
54 | |||
55 | 904 | fjp | import org.cresques.cts.IProjection; |
56 | |||
57 | 596 | fernando | import com.iver.andami.PluginServices; |
58 | 755 | fernando | import com.iver.andami.messages.NotificationManager; |
59 | 7011 | fjp | import com.iver.andami.ui.mdiManager.IWindowListener; |
60 | import com.iver.andami.ui.mdiManager.IWindowTransform; |
||
61 | 6880 | cesar | import com.iver.andami.ui.mdiManager.SingletonWindow; |
62 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
63 | 1062 | fernando | import com.iver.cit.gvsig.fmap.ColorEvent; |
64 | import com.iver.cit.gvsig.fmap.ExtentEvent; |
||
65 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
66 | 1223 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
67 | 5966 | fjp | import com.iver.cit.gvsig.fmap.ProjectionEvent; |
68 | 1062 | fernando | import com.iver.cit.gvsig.fmap.ViewPortListener; |
69 | 899 | vcaballero | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
70 | 4741 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayer; |
71 | 3714 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayers; |
72 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
73 | 1115 | fjp | import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
74 | 1221 | fernando | 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 | 2209 | vcaballero | import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
79 | import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
||
80 | 1221 | fernando | import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
81 | 6117 | jaume | import com.iver.cit.gvsig.gui.panels.MapOverViewPalette; |
82 | 480 | fjp | import com.iver.cit.gvsig.gui.toc.TOC; |
83 | 775 | vcaballero | 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 | 666 | fernando | import com.iver.cit.gvsig.gui.toolListeners.MeasureListener; |
87 | 842 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.PanListener; |
88 | import com.iver.cit.gvsig.gui.toolListeners.PointSelectListener; |
||
89 | 7011 | fjp | import com.iver.cit.gvsig.gui.toolListeners.PolygonSelectListener; |
90 | 842 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.RectangleSelectListener; |
91 | 2183 | fernando | import com.iver.cit.gvsig.gui.toolListeners.SelectImageListener; |
92 | 1009 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
93 | 842 | vcaballero | import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener; |
94 | import com.iver.cit.gvsig.gui.toolListeners.ZoomOutListener; |
||
95 | 2359 | igbrotru | import com.iver.cit.gvsig.gui.toolListeners.ZoomPixelCursorListener; |
96 | 1221 | fernando | import com.iver.cit.gvsig.project.ProjectView; |
97 | 3714 | caballero | import com.iver.utiles.console.JConsole; |
98 | 5998 | fjp | import com.iver.utiles.console.JDockPanel; |
99 | 3714 | caballero | import com.iver.utiles.console.ResponseListener; |
100 | 5839 | fjp | import com.iver.utiles.console.jedit.JEditTextArea; |
101 | 862 | fjp | import com.iver.utiles.exceptionHandling.ExceptionListener; |
102 | 312 | fernando | |
103 | |||
104 | /**
|
||
105 | 5787 | jaume | * <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 | 6630 | caballero | * <b>Map control</b>: the map area located in the right area of the window. It takes up
|
115 | 5787 | jaume | * the biggest part of the window.
|
116 | * </li>
|
||
117 | * <li>
|
||
118 | 6630 | caballero | * <b>Table of contents (TOC)</b>: is a list of layers displayed in the view. The TOC is
|
119 | 5787 | jaume | * located on the left-top corner of the View and is the place where the user can modify
|
120 | 6630 | caballero | * the order, the legends, the visibility and other properties of the layers.
|
121 | 5787 | jaume | * </li>
|
122 | * <li>
|
||
123 | * <b>Map overview</b>: is a small MapControl located in the left-bottom corner of the
|
||
124 | 6630 | caballero | * View where the user can put some layers which summarizes the view. It is used to make
|
125 | 5787 | jaume | * the navigation easier and faster.
|
126 | * </li>
|
||
127 | * </ol>
|
||
128 | 6630 | caballero | *
|
129 | 5787 | jaume | * @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 | 312 | fernando | * @author vcn
|
133 | */
|
||
134 | 6877 | cesar | public class View extends JPanel implements com.iver.andami.ui.mdiManager.IWindow, |
135 | 6880 | cesar | SingletonWindow,IWindowListener, IView, IWindowTransform{ |
136 | 312 | fernando | |
137 | 5900 | jorpiell | protected MapControl m_MapControl;
|
138 | protected MapOverview m_MapLoc;
|
||
139 | 5253 | caballero | |
140 | 5028 | cesar | // store the properties of the window
|
141 | 6880 | cesar | private WindowInfo m_viewInfo = null; |
142 | 312 | fernando | |
143 | 5028 | cesar | |
144 | 312 | fernando | /** DOCUMENT ME! */
|
145 | 5900 | jorpiell | protected TOC m_TOC;
|
146 | 359 | fjp | private ProjectView modelo;
|
147 | 7526 | jorpiell | protected ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
148 | 3714 | caballero | private JConsole console;
|
149 | 5998 | fjp | private JDockPanel dockConsole = null; |
150 | 5900 | jorpiell | protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
151 | 4741 | caballero | private boolean isPalette=false; |
152 | private MapOverViewPalette movp;
|
||
153 | 6682 | caballero | private JSplitPane tempMainSplit; |
154 | 5900 | jorpiell | protected boolean isShowConsole=false; |
155 | 3714 | caballero | /**
|
156 | 312 | fernando | * Creates a new View object.
|
157 | */
|
||
158 | public View() { |
||
159 | 5787 | jaume | this.setName("View"); |
160 | 312 | fernando | //this.setName(Utilities.getMessage(this, "Vista")+ " : "+modelo.getName());
|
161 | 3331 | fjp | // this.setPreferredSize(new Dimension(500, 300));
|
162 | 312 | fernando | initComponents(); |
163 | 3714 | caballero | hideConsole(); |
164 | 3727 | caballero | getConsolePanel().addResponseListener(consoleResponseAdapter); |
165 | 5998 | fjp | /* getConsolePanel().addContainerListener(new ContainerAdapter() {
|
166 | public void componentAdded(ContainerEvent e) {
|
||
167 | // Mostramos consola
|
||
168 | SwingUtilities.invokeLater(new Runnable() {
|
||
169 | public void run() {
|
||
170 | 6630 | caballero | |
171 | 5998 | fjp | getMapControl().doLayout(); // drawMap(false);
|
172 | getConsolePanel().invalidate();
|
||
173 | getConsolePanel().repaint();
|
||
174 | getMapControl().repaint();
|
||
175 | getConsolePanel().getTxt().doLayout();
|
||
176 | }
|
||
177 | 6630 | caballero | });
|
178 | 5998 | fjp | }
|
179 | |||
180 | public void componentRemoved(ContainerEvent e) {
|
||
181 | // Ocultamos consola
|
||
182 | SwingUtilities.invokeLater(new Runnable() {
|
||
183 | public void run() {
|
||
184 | getMapControl().repaint();
|
||
185 | }
|
||
186 | 6630 | caballero | });
|
187 | 5998 | fjp | |
188 | }
|
||
189 | |||
190 | }); */
|
||
191 | 312 | fernando | } |
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 | 457 | fernando | //Se registra como listener de cambios en FMap
|
210 | 6878 | cesar | MapContext fmap = modelo.getMapContext(); |
211 | 312 | fernando | |
212 | 3714 | caballero | 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 | 7422 | cesar | model.setAndamiWindow(this);
|
219 | 3714 | caballero | |
220 | //Se configura el mapControl
|
||
221 | 312 | fernando | m_MapControl.setMapContext(fmap); |
222 | 493 | fjp | m_TOC.setMapContext(fmap); |
223 | 312 | fernando | m_MapControl.setBackground(new Color(255, 255, 255)); |
224 | 944 | vcaballero | if (modelo.getMapOverViewContext()!=null){ |
225 | m_MapLoc.setModel(modelo.getMapOverViewContext()); |
||
226 | } |
||
227 | 644 | fernando | model.addPropertyChangeListener(new PropertyChangeListener() { |
228 | public void propertyChange(PropertyChangeEvent evt) { |
||
229 | if (evt.getPropertyName().equals("name")){ |
||
230 | 6880 | cesar | PluginServices.getMDIManager().getWindowInfo(View.this).setTitle("Vista: " + (String)evt.getNewValue()); |
231 | 644 | fernando | } |
232 | } |
||
233 | }); |
||
234 | 1367 | vcaballero | if (m_MapControl.getViewPort() != null){ |
235 | m_MapControl.getViewPort().addViewPortListener(new ViewPortListener() {
|
||
236 | public void extentChanged(ExtentEvent e) { |
||
237 | 3714 | caballero | if (PluginServices.getMainFrame() != null){ |
238 | 6630 | caballero | PluginServices.getMainFrame().getStatusBar().setControlValue("scale",String.valueOf(m_MapControl.getMapContext().getScaleView())); |
239 | PluginServices.getMainFrame().getStatusBar().setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev());
|
||
240 | 1367 | vcaballero | } |
241 | 1139 | vcaballero | } |
242 | 1062 | fernando | |
243 | 1367 | vcaballero | public void backColorChanged(ColorEvent e) { |
244 | } |
||
245 | 5939 | jmvivo | |
246 | public void projectionChanged(ProjectionEvent e) { |
||
247 | 6630 | caballero | m_MapLoc.setProjection(e.getNewProjection()); |
248 | 5939 | jmvivo | } |
249 | 3714 | caballero | }); |
250 | 1367 | vcaballero | } |
251 | 312 | fernando | } |
252 | 3714 | caballero | public JConsole getConsolePanel(){
|
253 | if (console==null){ |
||
254 | console=new JConsole();
|
||
255 | 5787 | jaume | // Para distinguir cuando se est? escribiendo sobre la consola y cuando no.
|
256 | 4459 | fjp | console.setJTextName("CADConsole");
|
257 | 3714 | caballero | } |
258 | return console;
|
||
259 | } |
||
260 | 6630 | caballero | |
261 | 5998 | fjp | private JDockPanel getDockConsole()
|
262 | { |
||
263 | if (dockConsole == null) |
||
264 | { |
||
265 | 6630 | caballero | dockConsole = new JDockPanel(getConsolePanel());
|
266 | 5998 | fjp | } |
267 | return dockConsole;
|
||
268 | } |
||
269 | 312 | fernando | |
270 | 3714 | caballero | |
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 | 4212 | fjp | // TODO: HACE ESTO CON EL KEYBOARDFOCUSMANAGER
|
284 | 5839 | fjp | // KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
285 | // kfm.focusNextComponent(getConsolePanel());
|
||
286 | System.err.println("Asigno el foco a la consola"); |
||
287 | 6630 | caballero | |
288 | 5839 | fjp | JEditTextArea jeta=getConsolePanel().getTxt(); |
289 | jeta.requestFocusInWindow(); |
||
290 | jeta.setCaretPosition(jeta.getText().length()); |
||
291 | |||
292 | |||
293 | 5828 | fjp | // FocusManager fm=FocusManager.getCurrentManager();
|
294 | // fm.focusNextComponent(getConsolePanel());
|
||
295 | 3714 | caballero | |
296 | } |
||
297 | |||
298 | 6630 | caballero | |
299 | 3714 | caballero | public void hideConsole() { |
300 | 5253 | caballero | isShowConsole=false;
|
301 | 5965 | fjp | /* removeAll();
|
302 | 3718 | caballero | //JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
303 | JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||
304 | tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
||
305 | 4741 | caballero | 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 | 3718 | caballero | 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 | 5965 | fjp | this.add(tempMainSplit, BorderLayout.CENTER); */
|
321 | 5998 | fjp | getDockConsole().setVisible(false);
|
322 | 3718 | caballero | |
323 | 3714 | caballero | } |
324 | |||
325 | public void showConsole() { |
||
326 | 5253 | caballero | if (isShowConsole)
|
327 | return;
|
||
328 | isShowConsole=true;
|
||
329 | 5965 | fjp | /* removeAll();
|
330 | 3718 | caballero | JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
331 | JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||
332 | tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
||
333 | 4741 | caballero | 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 | 3718 | caballero | 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 | 5965 | fjp | this.add(split, BorderLayout.CENTER); */
|
349 | 5998 | fjp | getMapControl().remove(getDockConsole()); |
350 | 5972 | fjp | // getConsolePanel().setPreferredSize(new Dimension(200, 150));
|
351 | 5965 | fjp | getMapControl().setLayout(new BorderLayout()); |
352 | 5998 | fjp | getMapControl().add(getDockConsole(), BorderLayout.SOUTH);
|
353 | getDockConsole().setVisible(true);
|
||
354 | 3718 | caballero | |
355 | 3714 | caballero | } |
356 | 6630 | caballero | |
357 | 3714 | caballero | 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 | 312 | fernando | /**
|
410 | 3714 | caballero | * DOCUMENT ME!
|
411 | */
|
||
412 | 5900 | jorpiell | protected void initComponents() { // GEN-BEGIN:initComponents |
413 | 3714 | caballero | m_MapControl = new MapControl(); // Default is paintEnabled = false. |
414 | // Remember to activate it
|
||
415 | 755 | fernando | m_MapControl.addExceptionListener(mapControlExceptionListener); |
416 | 359 | fjp | // modelo.setMapContext(m_MapControl.getMapContext());
|
417 | 312 | fernando | |
418 | // m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel
|
||
419 | 493 | fjp | m_TOC = new TOC();
|
420 | 312 | fernando | |
421 | 3718 | caballero | |
422 | 312 | fernando | // Ponemos el localizador
|
423 | 377 | fjp | m_MapLoc = new MapOverview(m_MapControl);
|
424 | 312 | fernando | m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
425 | 5965 | fjp | removeAll(); |
426 | //JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
||
427 | 6682 | caballero | tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
428 | 5965 | fjp | tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
429 | if (!isPalette()){
|
||
430 | JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
||
431 | 6682 | caballero | tempSplitToc.setTopComponent(m_TOC); |
432 | 5965 | fjp | 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 | 6630 | caballero | |
446 | 5965 | fjp | // hideConsole();
|
447 | 7566 | caballero | |
448 | 7526 | jorpiell | setListeners(); |
449 | } |
||
450 | 312 | fernando | |
451 | |||
452 | 7526 | jorpiell | 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 | 7566 | caballero | |
456 | 7526 | jorpiell | // Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
457 | // No es dibujando un rect?ngulo, es solo pinchando.
|
||
458 | 7566 | caballero | |
459 | 7526 | jorpiell | ZoomOutListener zol = new ZoomOutListener(m_MapControl);
|
460 | m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
||
461 | 7566 | caballero | |
462 | 7526 | jorpiell | // pan
|
463 | 7566 | caballero | |
464 | 7526 | jorpiell | PanListener pl = new PanListener(m_MapControl);
|
465 | m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
||
466 | 7566 | caballero | |
467 | 7526 | jorpiell | // Medir
|
468 | 7566 | caballero | |
469 | 7526 | jorpiell | MeasureListener mli = new MeasureListener(m_MapControl);
|
470 | m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
||
471 | 7566 | caballero | |
472 | 7526 | jorpiell | // Area
|
473 | 7566 | caballero | |
474 | 7526 | jorpiell | AreaListener ali = new AreaListener(m_MapControl);
|
475 | m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
||
476 | 7566 | caballero | |
477 | 7526 | jorpiell | //Seleccion por punto
|
478 | PointSelectListener psl = new PointSelectListener(m_MapControl);
|
||
479 | m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
||
480 | 7566 | caballero | |
481 | 7526 | jorpiell | //Info por punto
|
482 | InfoListener il = new InfoListener(m_MapControl);
|
||
483 | m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
||
484 | 7566 | caballero | |
485 | 7526 | jorpiell | // Link por punto
|
486 | LinkListener ll = new LinkListener(m_MapControl);
|
||
487 | m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
||
488 | 7566 | caballero | |
489 | 7526 | jorpiell | //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 | 7566 | caballero | |
493 | 7526 | jorpiell | //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 | 7566 | caballero | |
497 | 7526 | jorpiell | // 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 | 7566 | caballero | |
503 | 7526 | jorpiell | SelectImageListener sil = new SelectImageListener(m_MapControl);
|
504 | m_MapControl.addMapTool("selectImage", new Behavior[]{ |
||
505 | new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
||
506 | 7566 | caballero | |
507 | 7526 | jorpiell | ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl);
|
508 | m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
||
509 | 7566 | caballero | |
510 | 7526 | jorpiell | m_MapControl.setTool("zoomIn"); // Por defecto |
511 | // m_MapControl.setPaintEnabled(true);
|
||
512 | 312 | fernando | } |
513 | |||
514 | /**
|
||
515 | * DOCUMENT ME!
|
||
516 | */
|
||
517 | 960 | vcaballero | /*public void openPropertiesWindow() {
|
518 | 312 | fernando | }
|
519 | 960 | vcaballero | */
|
520 | 312 | fernando | /**
|
521 | * DOCUMENT ME!
|
||
522 | */
|
||
523 | 960 | vcaballero | /* public void openQueryWindow() {
|
524 | 312 | fernando | }
|
525 | 960 | vcaballero | */
|
526 | 312 | fernando | /**
|
527 | * DOCUMENT ME!
|
||
528 | *
|
||
529 | * @return DOCUMENT ME!
|
||
530 | */
|
||
531 | 655 | fjp | public MapOverview getMapOverview() {
|
532 | 312 | fernando | return m_MapLoc;
|
533 | } |
||
534 | |||
535 | /**
|
||
536 | * DOCUMENT ME!
|
||
537 | *
|
||
538 | * @return DOCUMENT ME!
|
||
539 | */
|
||
540 | 1223 | fernando | public MapControl getMapControl() {
|
541 | 312 | fernando | return m_MapControl;
|
542 | } |
||
543 | |||
544 | /**
|
||
545 | * DOCUMENT ME!
|
||
546 | *
|
||
547 | * @return DOCUMENT ME!
|
||
548 | */
|
||
549 | public TOC getTOC() {
|
||
550 | 5808 | jaume | return m_TOC;
|
551 | 312 | fernando | } |
552 | |||
553 | /**
|
||
554 | * DOCUMENT ME!
|
||
555 | */
|
||
556 | public void repaintMap() { |
||
557 | 3422 | fjp | m_MapControl.drawMap(false);
|
558 | 312 | fernando | } |
559 | |||
560 | /* (non-Javadoc)
|
||
561 | * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getModel()
|
||
562 | */
|
||
563 | 6880 | cesar | public Object getWindowModel() { |
564 | 312 | fernando | return modelo;
|
565 | } |
||
566 | |||
567 | /**
|
||
568 | 5028 | cesar | * 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 | 5253 | caballero | *
|
574 | 6880 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
575 | 312 | fernando | */
|
576 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
577 | 5028 | cesar | if (m_viewInfo == null) |
578 | { |
||
579 | 6880 | cesar | m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE |
|
580 | WindowInfo.MAXIMIZABLE); |
||
581 | 312 | fernando | |
582 | m_viewInfo.setWidth(500);
|
||
583 | m_viewInfo.setHeight(300);
|
||
584 | 5028 | cesar | m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
585 | 312 | fernando | modelo.getName()); |
586 | 5028 | cesar | } |
587 | return m_viewInfo;
|
||
588 | 312 | fernando | } |
589 | |||
590 | 5253 | caballero | |
591 | 312 | fernando | /**
|
592 | 6880 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
593 | 312 | fernando | */
|
594 | 6880 | cesar | public void windowActivated() { |
595 | 6630 | caballero | PluginServices.getMainFrame().getStatusBar().setMessage("units",
|
596 | 2544 | caballero | FConstant.NAMES[getMapControl().getMapContext().getViewPort().getDistanceUnits()]); |
597 | 6630 | caballero | PluginServices.getMainFrame().getStatusBar().setControlValue("scale",String.valueOf(m_MapControl.getMapContext().getScaleView())); |
598 | PluginServices.getMainFrame().getStatusBar().setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev());
|
||
599 | 1367 | vcaballero | } |
600 | 312 | fernando | |
601 | /**
|
||
602 | * @return
|
||
603 | */
|
||
604 | 596 | fernando | public BufferedImage getImage() { |
605 | 312 | fernando | return m_MapControl.getImage();
|
606 | } |
||
607 | 3714 | caballero | |
608 | 904 | fjp | public void setProjection(IProjection proj) |
609 | { |
||
610 | getMapControl().setProjection(proj); |
||
611 | } |
||
612 | public IProjection getProjection()
|
||
613 | { |
||
614 | return getMapControl().getProjection();
|
||
615 | } |
||
616 | 3714 | caballero | |
617 | 755 | fernando | 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 | 3714 | caballero | |
626 | 755 | fernando | } |
627 | 899 | vcaballero | |
628 | /**
|
||
629 | 6880 | cesar | * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
630 | 899 | vcaballero | */
|
631 | 6880 | cesar | public void windowClosed() { |
632 | 4741 | caballero | if (movp!=null) |
633 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(movp); |
634 | 899 | vcaballero | ///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
635 | } |
||
636 | 3714 | caballero | |
637 | 4741 | caballero | public void toPalette() { |
638 | isPalette=true;
|
||
639 | m_MapLoc.setPreferredSize(new Dimension(200,150)); |
||
640 | m_MapLoc.setSize(new Dimension(200,150)); |
||
641 | 7566 | caballero | movp=new MapOverViewPalette(m_MapLoc,this); |
642 | 6880 | cesar | PluginServices.getMDIManager().addWindow(movp); |
643 | 4741 | caballero | 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 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(movp); |
657 | 4741 | caballero | 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 | 6682 | caballero | 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 | 4741 | caballero | } |
671 | |||
672 | public boolean isPalette() { |
||
673 | return isPalette;
|
||
674 | } |
||
675 | 312 | fernando | } |