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