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