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