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