root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / gui / DefaultViewPanel.java @ 38601
History | View | Annotate | Download (18.5 KB)
1 | 31496 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | 36475 | cordinyana | *
|
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | 31496 | jjdelcerro | |
23 | /*
|
||
24 | 36475 | cordinyana | * AUTHORS (In addition to CIT):
|
25 | * 2004-2009 IVER TI
|
||
26 | *
|
||
27 | */
|
||
28 | 29596 | jpiera | package org.gvsig.app.project.documents.view.gui; |
29 | 7304 | caballero | |
30 | import java.awt.BorderLayout; |
||
31 | import java.awt.Color; |
||
32 | import java.awt.Dimension; |
||
33 | import java.beans.PropertyChangeEvent; |
||
34 | import java.beans.PropertyChangeListener; |
||
35 | import java.util.HashMap; |
||
36 | import java.util.Iterator; |
||
37 | |||
38 | import javax.swing.JSplitPane; |
||
39 | |||
40 | 36641 | fdiaz | import org.cresques.cts.IProjection; |
41 | 36722 | cordinyana | |
42 | 29596 | jpiera | import org.gvsig.andami.PluginServices; |
43 | 30337 | jpiera | import org.gvsig.andami.messages.NotificationManager; |
44 | 31496 | jjdelcerro | import org.gvsig.andami.ui.mdiFrame.NewStatusBar; |
45 | 29596 | jpiera | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
46 | 31496 | jjdelcerro | import org.gvsig.app.project.DefaultProject; |
47 | import org.gvsig.app.project.documents.Document; |
||
48 | 29596 | jpiera | import org.gvsig.app.project.documents.view.MapOverview; |
49 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewDocument; |
50 | 29596 | jpiera | import org.gvsig.app.project.documents.view.toc.gui.TOC; |
51 | import org.gvsig.app.project.documents.view.toolListeners.AreaListener; |
||
52 | import org.gvsig.app.project.documents.view.toolListeners.InfoListener; |
||
53 | import org.gvsig.app.project.documents.view.toolListeners.MeasureListener; |
||
54 | import org.gvsig.app.project.documents.view.toolListeners.PanListener; |
||
55 | import org.gvsig.app.project.documents.view.toolListeners.PointSelectListener; |
||
56 | import org.gvsig.app.project.documents.view.toolListeners.PolygonSelectListener; |
||
57 | import org.gvsig.app.project.documents.view.toolListeners.RectangleSelectListener; |
||
58 | import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
||
59 | import org.gvsig.app.project.documents.view.toolListeners.ZoomInListener; |
||
60 | import org.gvsig.app.project.documents.view.toolListeners.ZoomOutListener; |
||
61 | 20994 | jmvivo | import org.gvsig.fmap.mapcontext.MapContext; |
62 | import org.gvsig.fmap.mapcontext.events.ColorEvent; |
||
63 | import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
||
64 | import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
||
65 | import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
||
66 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
67 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
68 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
69 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
70 | 30337 | jpiera | import org.gvsig.fmap.mapcontrol.MapControlCreationException; |
71 | import org.gvsig.fmap.mapcontrol.MapControlLocator; |
||
72 | import org.gvsig.fmap.mapcontrol.MapControlManager; |
||
73 | 20994 | jmvivo | import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
74 | 21743 | vcaballero | import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
75 | import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
||
76 | 36722 | cordinyana | import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseWheelBehavior; |
77 | 21743 | vcaballero | import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
78 | import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
||
79 | import org.gvsig.fmap.mapcontrol.tools.Behavior.PolygonBehavior; |
||
80 | import org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior; |
||
81 | import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
||
82 | 29596 | jpiera | import org.gvsig.utils.console.JConsole; |
83 | import org.gvsig.utils.console.JDockPanel; |
||
84 | import org.gvsig.utils.console.ResponseListener; |
||
85 | import org.gvsig.utils.console.jedit.JEditTextArea; |
||
86 | 20994 | jmvivo | |
87 | 7304 | caballero | /**
|
88 | * <p>
|
||
89 | 36475 | cordinyana | * <b>Class View</b>. This class represents the gvSIG specific internal window
|
90 | * where the maps are displayed and where the events coming from the user are
|
||
91 | * captured.
|
||
92 | 7304 | caballero | * </p>
|
93 | * <p>
|
||
94 | * It is composed by three main visual areas:
|
||
95 | * </p>
|
||
96 | * <ol>
|
||
97 | 36475 | cordinyana | * <li>
|
98 | * <b>Map control</b>: the map area located in the right area of the window. It
|
||
99 | * takes up the biggest part of the window.</li>
|
||
100 | * <li>
|
||
101 | * <b>Table of contents (TOC)</b>: is a list of layers displayed in the view.
|
||
102 | * The TOC is located on the left-top corner of the View and is the place where
|
||
103 | * the user can modify the order, the legends, the visibility and other
|
||
104 | * properties of the layers.</li>
|
||
105 | * <li>
|
||
106 | * <b>Map overview</b>: is a small MapControl located in the left-bottom corner
|
||
107 | * of the View where the user can put some layers which summarizes the view. It
|
||
108 | * is used to make the navigation easier and faster.</li>
|
||
109 | 7304 | caballero | * </ol>
|
110 | 31496 | jjdelcerro | *
|
111 | 36475 | cordinyana | * @author 2005- Vicente Caballero
|
112 | * @author 2009- Joaquin del Cerro
|
||
113 | *
|
||
114 | 7304 | caballero | */
|
115 | 31496 | jjdelcerro | public class DefaultViewPanel extends AbstractViewPanel { |
116 | 36641 | fdiaz | /**
|
117 | 31496 | jjdelcerro | *
|
118 | */
|
||
119 | 36641 | fdiaz | private static final long serialVersionUID = -4044661458841786519L; |
120 | 36475 | cordinyana | |
121 | 36641 | fdiaz | private JConsole console;
|
122 | private JDockPanel dockConsole = null; |
||
123 | protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
||
124 | protected boolean isShowConsole = false; |
||
125 | private ViewPortListener viewPortListener;
|
||
126 | private static MapControlManager mapControlManager = MapControlLocator |
||
127 | .getMapControlManager(); |
||
128 | 31496 | jjdelcerro | |
129 | 36641 | fdiaz | /**
|
130 | * Creates a new View object. Before being used, the object must be
|
||
131 | * initialized.
|
||
132 | *
|
||
133 | * @see initialize()
|
||
134 | */
|
||
135 | public DefaultViewPanel() {
|
||
136 | super();
|
||
137 | this.setName("View"); |
||
138 | // TODO Remove this when the system lo load libraries is finished
|
||
139 | if (mapControlManager == null) { |
||
140 | mapControlManager = MapControlLocator.getMapControlManager(); |
||
141 | } |
||
142 | } |
||
143 | 10839 | caballero | |
144 | 36641 | fdiaz | public DefaultViewPanel(Document document) { |
145 | this();
|
||
146 | this.initialize();
|
||
147 | this.setDocument(document);
|
||
148 | } |
||
149 | 36475 | cordinyana | |
150 | 36641 | fdiaz | /**
|
151 | 9044 | cesar | * Create the internal componentes and populate the window with them.
|
152 | * If the layout properties were set using the
|
||
153 | 36641 | fdiaz | * <code>setWindowData(WindowData)</code> method, the window will be
|
154 | * populated according to this properties.
|
||
155 | */
|
||
156 | protected void initialize() { |
||
157 | super.initialize();
|
||
158 | initComponents(); |
||
159 | hideConsole(); |
||
160 | getConsolePanel().addResponseListener(consoleResponseAdapter); |
||
161 | } |
||
162 | 7304 | caballero | |
163 | 36641 | fdiaz | public void setDocument(Document document) { |
164 | setModel((ViewDocument) document); |
||
165 | } |
||
166 | 36475 | cordinyana | |
167 | 36641 | fdiaz | public Document getDocument() { |
168 | return this.modelo; |
||
169 | } |
||
170 | 36475 | cordinyana | |
171 | 36641 | fdiaz | public void setModel(ViewDocument model) { |
172 | this.modelo = model;
|
||
173 | // Se registra como listener de cambios en FMap
|
||
174 | MapContext fmap = modelo.getMapContext(); |
||
175 | 7304 | caballero | |
176 | 36641 | fdiaz | FLayers layers = fmap.getLayers(); |
177 | for (int i = 0; i < layers.getLayersCount(); i++) { |
||
178 | if (layers.getLayer(i).isEditing()
|
||
179 | && layers.getLayer(i) instanceof FLyrVect) {
|
||
180 | this.showConsole();
|
||
181 | } |
||
182 | } |
||
183 | 36475 | cordinyana | |
184 | 36641 | fdiaz | // Se configura el mapControl
|
185 | m_MapControl.setMapContext(fmap); |
||
186 | m_TOC.setMapContext(fmap); |
||
187 | m_MapControl.getMapContext().getLayers().addLegendListener(m_TOC); |
||
188 | 21299 | vcaballero | |
189 | 36641 | fdiaz | m_MapControl.setBackground(new Color(255, 255, 255)); |
190 | if (modelo.getMapOverViewContext() != null) { |
||
191 | m_MapLoc.setModel(modelo.getMapOverViewContext()); |
||
192 | } |
||
193 | model.addPropertyChangeListener(new PropertyChangeListener() { |
||
194 | public void propertyChange(PropertyChangeEvent evt) { |
||
195 | if (evt.getPropertyName().equals("name")) { |
||
196 | PluginServices.getMDIManager() |
||
197 | .getWindowInfo(DefaultViewPanel.this) |
||
198 | 36765 | cordinyana | .setTitle( |
199 | PluginServices.getText(this, "Vista") + ": " |
||
200 | + (String) evt.getNewValue());
|
||
201 | 36641 | fdiaz | } |
202 | } |
||
203 | }); |
||
204 | if (m_MapControl.getViewPort() != null) { |
||
205 | viewPortListener = new ViewPortListener() {
|
||
206 | public void extentChanged(ExtentEvent e) { |
||
207 | if (PluginServices.getMainFrame() != null) { |
||
208 | PluginServices |
||
209 | .getMainFrame() |
||
210 | .getStatusBar() |
||
211 | .setControlValue( |
||
212 | "scale",
|
||
213 | String.valueOf(m_MapControl
|
||
214 | .getMapContext().getScaleView())); |
||
215 | PluginServices |
||
216 | .getMainFrame() |
||
217 | .getStatusBar() |
||
218 | .setMessage( |
||
219 | "projection",
|
||
220 | getMapControl().getViewPort() |
||
221 | .getProjection().getAbrev()); |
||
222 | } |
||
223 | } |
||
224 | 7304 | caballero | |
225 | 36641 | fdiaz | public void backColorChanged(ColorEvent e) { |
226 | // Do nothing
|
||
227 | } |
||
228 | 7304 | caballero | |
229 | 36641 | fdiaz | public void projectionChanged(ProjectionEvent e) { |
230 | m_MapLoc.setProjection(e.getNewProjection()); |
||
231 | } |
||
232 | }; |
||
233 | m_MapControl.getViewPort().addViewPortListener(viewPortListener); |
||
234 | } |
||
235 | } |
||
236 | 36475 | cordinyana | |
237 | 36641 | fdiaz | public JConsole getConsolePanel() {
|
238 | if (console == null) { |
||
239 | console = new JConsole();
|
||
240 | // Para distinguir cuando se est? escribiendo sobre la consola y
|
||
241 | // cuando no.
|
||
242 | console.setJTextName("CADConsole");
|
||
243 | } |
||
244 | return console;
|
||
245 | } |
||
246 | 36475 | cordinyana | |
247 | 36641 | fdiaz | private JDockPanel getDockConsole() {
|
248 | if (dockConsole == null) { |
||
249 | dockConsole = new JDockPanel(getConsolePanel());
|
||
250 | } |
||
251 | return dockConsole;
|
||
252 | } |
||
253 | 10839 | caballero | |
254 | 36641 | fdiaz | public void addConsoleListener(String prefix, ResponseListener listener) { |
255 | consoleResponseAdapter.putSpaceListener(prefix, listener); |
||
256 | 7304 | caballero | |
257 | 36641 | fdiaz | } |
258 | 7304 | caballero | |
259 | 36641 | fdiaz | public void removeConsoleListener(ResponseListener listener) { |
260 | consoleResponseAdapter.deleteListener(listener); |
||
261 | 7304 | caballero | |
262 | 36641 | fdiaz | } |
263 | 7304 | caballero | |
264 | 36641 | fdiaz | public void focusConsole(String text) { |
265 | getConsolePanel().addResponseText(text); |
||
266 | 7304 | caballero | |
267 | 36641 | fdiaz | JEditTextArea jeta = getConsolePanel().getTxt(); |
268 | jeta.requestFocusInWindow(); |
||
269 | jeta.setCaretPosition(jeta.getText().length()); |
||
270 | 7304 | caballero | |
271 | 36641 | fdiaz | } |
272 | 7304 | caballero | |
273 | 36641 | fdiaz | public void hideConsole() { |
274 | isShowConsole = false;
|
||
275 | getDockConsole().setVisible(false);
|
||
276 | 7304 | caballero | |
277 | 36641 | fdiaz | } |
278 | 7304 | caballero | |
279 | 36641 | fdiaz | public void showConsole() { |
280 | if (isShowConsole) {
|
||
281 | return;
|
||
282 | } |
||
283 | isShowConsole = true;
|
||
284 | getMapControl().remove(getDockConsole()); |
||
285 | getMapControl().setLayout(new BorderLayout()); |
||
286 | getMapControl().add(getDockConsole(), BorderLayout.SOUTH);
|
||
287 | getDockConsole().setVisible(true);
|
||
288 | 7304 | caballero | |
289 | 36641 | fdiaz | } |
290 | 7304 | caballero | |
291 | 36641 | fdiaz | static class ResponseAdapter implements ResponseListener { |
292 | 7304 | caballero | |
293 | 36475 | cordinyana | private HashMap<String, ResponseListener> spaceListener = |
294 | new HashMap<String, ResponseListener>(); |
||
295 | 7304 | caballero | |
296 | 36641 | fdiaz | public void putSpaceListener(String namespace, ResponseListener listener) { |
297 | spaceListener.put(namespace, listener); |
||
298 | } |
||
299 | 7304 | caballero | |
300 | 36641 | fdiaz | public void acceptResponse(String response) { |
301 | boolean nameSpace = false; |
||
302 | int n = -1; |
||
303 | if (response != null) { |
||
304 | if ((n = response.indexOf(':')) != -1) { |
||
305 | nameSpace = true;
|
||
306 | } |
||
307 | } |
||
308 | 7304 | caballero | |
309 | 36641 | fdiaz | if (nameSpace) {
|
310 | 36475 | cordinyana | ResponseListener listener = |
311 | spaceListener.get(response.substring(0, n));
|
||
312 | 36641 | fdiaz | if (listener != null) { |
313 | listener.acceptResponse(response.substring(n + 1));
|
||
314 | } |
||
315 | } else {
|
||
316 | 36475 | cordinyana | Iterator<ResponseListener> i =
|
317 | spaceListener.values().iterator(); |
||
318 | 36641 | fdiaz | while (i.hasNext()) {
|
319 | ResponseListener listener = i.next(); |
||
320 | listener.acceptResponse(response); |
||
321 | } |
||
322 | } |
||
323 | } |
||
324 | 7304 | caballero | |
325 | 36641 | fdiaz | /**
|
326 | * @param listener
|
||
327 | */
|
||
328 | public void deleteListener(ResponseListener listener) { |
||
329 | Iterator<String> i = spaceListener.keySet().iterator(); |
||
330 | while (i.hasNext()) {
|
||
331 | String namespace = i.next();
|
||
332 | ResponseListener l = spaceListener.get(namespace); |
||
333 | if (l == listener) {
|
||
334 | spaceListener.remove(namespace); |
||
335 | } |
||
336 | } |
||
337 | } |
||
338 | 7304 | caballero | |
339 | 36641 | fdiaz | } |
340 | 7304 | caballero | |
341 | 36641 | fdiaz | protected void initComponents() { // GEN-BEGIN:initComponents |
342 | m_MapControl = new MapControl(); // Default is paintEnabled = false. |
||
343 | // Remember to activate it
|
||
344 | try {
|
||
345 | m_MapControl.setMapControlDrawer(mapControlManager |
||
346 | .createDefaultMapControlDrawer()); |
||
347 | } catch (MapControlCreationException e) {
|
||
348 | NotificationManager.addError(e); |
||
349 | } |
||
350 | 36475 | cordinyana | |
351 | 36641 | fdiaz | m_MapControl.addExceptionListener(mapControlExceptionListener); |
352 | m_TOC = new TOC();
|
||
353 | 7304 | caballero | |
354 | 36641 | fdiaz | // Ponemos el localizador
|
355 | m_MapLoc = new MapOverview(m_MapControl);
|
||
356 | try {
|
||
357 | m_MapLoc.setMapControlDrawer(mapControlManager |
||
358 | .createDefaultMapControlDrawer()); |
||
359 | } catch (MapControlCreationException e) {
|
||
360 | NotificationManager.addError(e); |
||
361 | } |
||
362 | removeAll(); |
||
363 | tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
||
364 | 9044 | cesar | |
365 | 36641 | fdiaz | if (windowLayout == null) { |
366 | m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
||
367 | tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
||
368 | } |
||
369 | 10839 | caballero | |
370 | 36641 | fdiaz | if (!isPalette()) {
|
371 | tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
||
372 | tempSplitToc.setTopComponent(m_TOC); |
||
373 | tempSplitToc.setBottomComponent(m_MapLoc); |
||
374 | tempSplitToc.setResizeWeight(0.7);
|
||
375 | tempMainSplit.setLeftComponent(tempSplitToc); |
||
376 | } else {
|
||
377 | tempMainSplit.setLeftComponent(m_TOC); |
||
378 | } |
||
379 | m_TOC.setVisible(true);
|
||
380 | tempMainSplit.setRightComponent(m_MapControl); |
||
381 | this.setLayout(new BorderLayout()); |
||
382 | this.add(tempMainSplit, BorderLayout.CENTER); |
||
383 | 7304 | caballero | |
384 | 36641 | fdiaz | if (windowLayout != null) { |
385 | try {
|
||
386 | tempMainSplit.setDividerLocation(Integer.valueOf(
|
||
387 | windowLayout.get("MainDivider.Location")).intValue());
|
||
388 | if (windowLayout.get("TOCDivider.Location") != null) { |
||
389 | 36475 | cordinyana | tempSplitToc.setDividerLocation(Integer.valueOf(
|
390 | windowLayout.get("TOCDivider.Location")).intValue());
|
||
391 | 36641 | fdiaz | } |
392 | } catch (NumberFormatException ex) { |
||
393 | PluginServices.getLogger().error( |
||
394 | "Error restoring View properties");
|
||
395 | } |
||
396 | } |
||
397 | 10839 | caballero | |
398 | 36641 | fdiaz | // Listener de eventos de movimiento que pone las coordenadas del rat?n
|
399 | // en la barra de estado
|
||
400 | StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
||
401 | 7304 | caballero | |
402 | 36641 | fdiaz | // Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
403 | // No es dibujando un rect?ngulo, es solo pinchando.
|
||
404 | 7304 | caballero | |
405 | 36641 | fdiaz | ZoomOutListener zol = new ZoomOutListener(m_MapControl);
|
406 | 36722 | cordinyana | |
407 | 36641 | fdiaz | m_MapControl.addBehavior("zoomOut", new Behavior[] { |
408 | 36722 | cordinyana | new PointBehavior(zol), new MouseMovementBehavior(sbl) }); |
409 | 7304 | caballero | |
410 | 36641 | fdiaz | // pan
|
411 | 7304 | caballero | |
412 | 36641 | fdiaz | PanListener pl = new PanListener(m_MapControl);
|
413 | m_MapControl.addBehavior("pan", new Behavior[] { new MoveBehavior(pl), |
||
414 | 36722 | cordinyana | new MouseMovementBehavior(sbl) });
|
415 | 7304 | caballero | |
416 | 36641 | fdiaz | // Medir
|
417 | 7304 | caballero | |
418 | 36641 | fdiaz | MeasureListener mli = new MeasureListener(m_MapControl);
|
419 | m_MapControl.addBehavior("medicion", new Behavior[] { |
||
420 | 36722 | cordinyana | new PolylineBehavior(mli), new MouseMovementBehavior(sbl) }); |
421 | 7304 | caballero | |
422 | 36641 | fdiaz | // Area
|
423 | 7304 | caballero | |
424 | 36641 | fdiaz | AreaListener ali = new AreaListener(m_MapControl);
|
425 | m_MapControl.addBehavior("area", new Behavior[] { |
||
426 | 36722 | cordinyana | new PolygonBehavior(ali), new MouseMovementBehavior(sbl) }); |
427 | 7304 | caballero | |
428 | 36641 | fdiaz | // Seleccion por punto
|
429 | PointSelectListener psl = new PointSelectListener(m_MapControl);
|
||
430 | m_MapControl.addBehavior("pointSelection", new Behavior[] { |
||
431 | 36722 | cordinyana | new PointBehavior(psl), new MouseMovementBehavior(sbl) }); |
432 | 7304 | caballero | |
433 | 36641 | fdiaz | // Info por punto
|
434 | InfoListener il = new InfoListener(m_MapControl);
|
||
435 | m_MapControl.addBehavior("info", new Behavior[] { |
||
436 | 36722 | cordinyana | new PointBehavior(il), new MouseMovementBehavior(sbl) }); |
437 | 7304 | caballero | |
438 | 36641 | fdiaz | // Selecci?n por rect?ngulo
|
439 | RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl);
|
||
440 | m_MapControl.addBehavior("rectSelection", new Behavior[] { |
||
441 | 36722 | cordinyana | new RectangleBehavior(rsl), new MouseMovementBehavior(sbl) }); |
442 | 7304 | caballero | |
443 | 36641 | fdiaz | // Selecci?n por pol?gono
|
444 | 36475 | cordinyana | PolygonSelectListener poligSel = |
445 | new PolygonSelectListener(m_MapControl);
|
||
446 | m_MapControl.addBehavior("polSelection", new Behavior[] { |
||
447 | new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl) }); |
||
448 | 7392 | sbayarri | |
449 | 36641 | fdiaz | // Zoom por rect?ngulo
|
450 | ZoomOutRightButtonListener zoil = |
||
451 | 36475 | cordinyana | new ZoomOutRightButtonListener(m_MapControl);
|
452 | 36641 | fdiaz | ZoomInListener zil = new ZoomInListener(m_MapControl);
|
453 | m_MapControl.addBehavior("zoomIn", new Behavior[] { |
||
454 | new RectangleBehavior(zil), new PointBehavior(zoil), |
||
455 | 36722 | cordinyana | new MouseMovementBehavior(sbl) });
|
456 | 7304 | caballero | |
457 | 38601 | jldominguez | /*
|
458 | 36641 | fdiaz | SelectImageListener sil = new SelectImageListener(m_MapControl);
|
459 | m_MapControl.addBehavior("selectImage", new Behavior[] {
|
||
460 | 36722 | cordinyana | new PointBehavior(sil), new MouseMovementBehavior(sbl) });
|
461 | 38601 | jldominguez | */
|
462 | 7304 | caballero | |
463 | 36641 | fdiaz | m_MapControl.setTool("zoomIn"); // Por defecto |
464 | 36722 | cordinyana | m_MapControl.addCombinedBehavior(new MouseWheelBehavior());
|
465 | 36641 | fdiaz | } |
466 | 7304 | caballero | |
467 | 36641 | fdiaz | public void windowActivated() { |
468 | NewStatusBar statusbar = PluginServices.getMainFrame().getStatusBar(); |
||
469 | MapContext mapContext = this.getMapControl().getMapContext();
|
||
470 | 36475 | cordinyana | |
471 | 36641 | fdiaz | statusbar.setMessage("units",
|
472 | PluginServices.getText(this, mapContext.getDistanceName()));
|
||
473 | statusbar.setControlValue("scale",
|
||
474 | String.valueOf(mapContext.getScaleView()));
|
||
475 | IProjection proj = getMapControl().getViewPort().getProjection(); |
||
476 | if (proj != null) { |
||
477 | statusbar.setMessage("projection", proj.getAbrev());
|
||
478 | } else {
|
||
479 | statusbar.setMessage("projection", ""); |
||
480 | } |
||
481 | } |
||
482 | 31496 | jjdelcerro | |
483 | 36641 | fdiaz | public void windowClosed() { |
484 | super.windowClosed();
|
||
485 | if (viewPortListener != null) { |
||
486 | getMapControl().getViewPort().removeViewPortListener( |
||
487 | viewPortListener); |
||
488 | } |
||
489 | if (getMapOverview() != null) { |
||
490 | getMapOverview().getViewPort().removeViewPortListener( |
||
491 | getMapOverview()); |
||
492 | } |
||
493 | 10839 | caballero | |
494 | 36641 | fdiaz | } |
495 | 7304 | caballero | |
496 | 36641 | fdiaz | public void toPalette() { |
497 | isPalette = true;
|
||
498 | m_MapLoc.setPreferredSize(new Dimension(200, 150)); |
||
499 | m_MapLoc.setSize(new Dimension(200, 150)); |
||
500 | movp = new MapOverViewPalette(m_MapLoc, this); |
||
501 | PluginServices.getMDIManager().addWindow(movp); |
||
502 | 36475 | cordinyana | FLayer[] layers =
|
503 | getViewDocument().getMapContext().getLayers().getActives(); |
||
504 | 36641 | fdiaz | if (layers.length > 0 && layers[0] instanceof FLyrVect) { |
505 | if (((FLyrVect) layers[0]).isEditing()) { |
||
506 | showConsole(); |
||
507 | return;
|
||
508 | } |
||
509 | } |
||
510 | hideConsole(); |
||
511 | 7304 | caballero | |
512 | 36641 | fdiaz | } |
513 | 7304 | caballero | |
514 | 36641 | fdiaz | public void restore() { |
515 | isPalette = false;
|
||
516 | PluginServices.getMDIManager().closeWindow(movp); |
||
517 | 36475 | cordinyana | FLayer[] layers =
|
518 | getViewDocument().getMapContext().getLayers().getActives(); |
||
519 | 36641 | fdiaz | if (layers.length > 0 && layers[0] instanceof FLyrVect) { |
520 | if (((FLyrVect) layers[0]).isEditing()) { |
||
521 | showConsole(); |
||
522 | return;
|
||
523 | } |
||
524 | } |
||
525 | hideConsole(); |
||
526 | JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
||
527 | tempSplitToc.setTopComponent(m_TOC); |
||
528 | tempSplitToc.setBottomComponent(m_MapLoc); |
||
529 | tempSplitToc.setResizeWeight(0.7);
|
||
530 | tempMainSplit.setLeftComponent(tempSplitToc); |
||
531 | } |
||
532 | 7853 | jaume | |
533 | 36641 | fdiaz | /**
|
534 | * Sets the default map overview background color that will be used in
|
||
535 | * subsequent projects.
|
||
536 | *
|
||
537 | * @param color
|
||
538 | * @deprecated use instead
|
||
539 | * Project.getPreferences().setDefaultMapoverViewBackColor
|
||
540 | */
|
||
541 | public static void setDefaultMapOverViewBackColor(Color color) { |
||
542 | DefaultProject.getPreferences().setDefaultOverviewBackColor(color); |
||
543 | } |
||
544 | 7853 | jaume | |
545 | 36641 | fdiaz | /**
|
546 | * Returns the current default map overview background color defined which
|
||
547 | * is the color defined when the user does not define any other one
|
||
548 | *
|
||
549 | * @return java.awt.Color
|
||
550 | * @deprecated use instead
|
||
551 | * Project.getPreferences().setDefaultMapoverViewBackColor
|
||
552 | */
|
||
553 | public static Color getDefaultMapOverViewBackColor() { |
||
554 | return DefaultProject.getPreferences().getDefaultOverviewBackColor();
|
||
555 | } |
||
556 | 7853 | jaume | |
557 | 36641 | fdiaz | /**
|
558 | * Returns the current default view background color defined which is the
|
||
559 | * color defined when the user does not define any other one
|
||
560 | *
|
||
561 | * @return java.awt.Color
|
||
562 | * @deprecated use instead Project.getPreferences().getDefaultViewBackColor
|
||
563 | */
|
||
564 | public static Color getDefaultBackColor() { |
||
565 | return DefaultProject.getPreferences().getDefaultViewBackColor();
|
||
566 | } |
||
567 | 7853 | jaume | |
568 | 36641 | fdiaz | /**
|
569 | * @deprecated use instead Project.getPreferences().setDefaultViewBackColor
|
||
570 | */
|
||
571 | public static void setDefaultBackColor(Color color) { |
||
572 | DefaultProject.getPreferences().setDefaultViewBackColor(color); |
||
573 | } |
||
574 | 10839 | caballero | |
575 | 36641 | fdiaz | public Object getWindowProfile() { |
576 | return WindowInfo.EDITOR_PROFILE;
|
||
577 | } |
||
578 | 36475 | cordinyana | |
579 | 7304 | caballero | } |