svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / gui / View.java @ 21743
History | View | Annotate | Download (20.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 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.mapcontext.MapContext; |
54 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
55 |
import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
56 |
import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
57 |
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
58 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
59 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
60 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
61 |
import org.gvsig.fmap.mapcontrol.MapControl; |
62 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
63 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
64 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
65 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
66 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
67 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolygonBehavior; |
68 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior; |
69 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
70 |
|
71 |
import com.iver.andami.PluginServices; |
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.getMapContext().getLayers().addLegendListener(m_TOC); |
182 |
|
183 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
184 |
if (modelo.getMapOverViewContext()!=null){ |
185 |
m_MapLoc.setModel(modelo.getMapOverViewContext()); |
186 |
} |
187 |
model.addPropertyChangeListener(new PropertyChangeListener() { |
188 |
public void propertyChange(PropertyChangeEvent evt) { |
189 |
if (evt.getPropertyName().equals("name")){ |
190 |
PluginServices.getMDIManager().getWindowInfo(View.this).setTitle("Vista: " + (String)evt.getNewValue()); |
191 |
} |
192 |
} |
193 |
}); |
194 |
if (m_MapControl.getViewPort() != null){ |
195 |
viewPortListener=new ViewPortListener() {
|
196 |
public void extentChanged(ExtentEvent e) { |
197 |
if (PluginServices.getMainFrame() != null){ |
198 |
PluginServices.getMainFrame().getStatusBar().setControlValue("scale",String.valueOf(m_MapControl.getMapContext().getScaleView())); |
199 |
PluginServices.getMainFrame().getStatusBar().setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev());
|
200 |
} |
201 |
} |
202 |
|
203 |
public void backColorChanged(ColorEvent e) { |
204 |
} |
205 |
|
206 |
public void projectionChanged(ProjectionEvent e) { |
207 |
m_MapLoc.setProjection(e.getNewProjection()); |
208 |
} |
209 |
}; |
210 |
m_MapControl.getViewPort().addViewPortListener(viewPortListener); |
211 |
} |
212 |
} |
213 |
|
214 |
public JConsole getConsolePanel(){
|
215 |
if (console==null){ |
216 |
console=new JConsole();
|
217 |
// Para distinguir cuando se est? escribiendo sobre la consola y cuando no.
|
218 |
console.setJTextName("CADConsole");
|
219 |
} |
220 |
return console;
|
221 |
} |
222 |
|
223 |
private JDockPanel getDockConsole()
|
224 |
{ |
225 |
if (dockConsole == null) |
226 |
{ |
227 |
dockConsole = new JDockPanel(getConsolePanel());
|
228 |
} |
229 |
return dockConsole;
|
230 |
} |
231 |
|
232 |
|
233 |
public void addConsoleListener(String prefix, ResponseListener listener) { |
234 |
consoleResponseAdapter.putSpaceListener(prefix, listener); |
235 |
|
236 |
} |
237 |
|
238 |
public void removeConsoleListener(ResponseListener listener) { |
239 |
consoleResponseAdapter.deleteListener(listener); |
240 |
|
241 |
} |
242 |
|
243 |
public void focusConsole(String text) { |
244 |
getConsolePanel().addResponseText(text); |
245 |
// TODO: HACE ESTO CON EL KEYBOARDFOCUSMANAGER
|
246 |
// KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
247 |
// kfm.focusNextComponent(getConsolePanel());
|
248 |
System.err.println("Asigno el foco a la consola"); |
249 |
|
250 |
JEditTextArea jeta=getConsolePanel().getTxt(); |
251 |
jeta.requestFocusInWindow(); |
252 |
jeta.setCaretPosition(jeta.getText().length()); |
253 |
|
254 |
|
255 |
// FocusManager fm=FocusManager.getCurrentManager();
|
256 |
// fm.focusNextComponent(getConsolePanel());
|
257 |
|
258 |
} |
259 |
|
260 |
|
261 |
public void hideConsole() { |
262 |
isShowConsole=false;
|
263 |
/* removeAll();
|
264 |
//JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
265 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
266 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
267 |
if (!isPalette()){
|
268 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
269 |
tempSplitToc.setTopComponent((TOC) m_TOC);
|
270 |
tempSplitToc.setBottomComponent(m_MapLoc);
|
271 |
tempSplitToc.setResizeWeight(0.7);
|
272 |
tempMainSplit.setLeftComponent(tempSplitToc);
|
273 |
}else{
|
274 |
tempMainSplit.setLeftComponent(m_TOC);
|
275 |
}
|
276 |
m_TOC.setVisible(true);
|
277 |
tempMainSplit.setRightComponent(m_MapControl);
|
278 |
//split.setBottomComponent(getConsolePanel());
|
279 |
//split.setTopComponent(tempMainSplit);
|
280 |
// split.setResizeWeight(0.9);
|
281 |
this.setLayout(new BorderLayout());
|
282 |
this.add(tempMainSplit, BorderLayout.CENTER); */
|
283 |
getDockConsole().setVisible(false);
|
284 |
|
285 |
} |
286 |
|
287 |
public void showConsole() { |
288 |
if (isShowConsole)
|
289 |
return;
|
290 |
isShowConsole=true;
|
291 |
/* removeAll();
|
292 |
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
293 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
294 |
tempMainSplit.setPreferredSize(new Dimension(500, 300));
|
295 |
if (!isPalette()){
|
296 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
297 |
tempSplitToc.setTopComponent((TOC) m_TOC);
|
298 |
tempSplitToc.setBottomComponent(m_MapLoc);
|
299 |
tempSplitToc.setResizeWeight(0.7);
|
300 |
tempMainSplit.setLeftComponent(tempSplitToc);
|
301 |
}else{
|
302 |
tempMainSplit.setLeftComponent(m_TOC);
|
303 |
}
|
304 |
m_TOC.setVisible(true);
|
305 |
tempMainSplit.setRightComponent(m_MapControl);
|
306 |
split.setBottomComponent(getConsolePanel());
|
307 |
split.setTopComponent(tempMainSplit);
|
308 |
split.setResizeWeight(0.9);
|
309 |
this.setLayout(new BorderLayout());
|
310 |
this.add(split, BorderLayout.CENTER); */
|
311 |
getMapControl().remove(getDockConsole()); |
312 |
// getConsolePanel().setPreferredSize(new Dimension(200, 150));
|
313 |
getMapControl().setLayout(new BorderLayout()); |
314 |
getMapControl().add(getDockConsole(), BorderLayout.SOUTH);
|
315 |
getDockConsole().setVisible(true);
|
316 |
|
317 |
} |
318 |
|
319 |
private class ResponseAdapter implements ResponseListener{ |
320 |
|
321 |
private HashMap spaceListener = new HashMap(); |
322 |
|
323 |
public void putSpaceListener(String namespace, ResponseListener listener){ |
324 |
spaceListener.put(namespace, listener); |
325 |
} |
326 |
|
327 |
/**
|
328 |
* @see com.iver.utiles.console.ResponseListener#acceptResponse(java.lang.String)
|
329 |
*/
|
330 |
public void acceptResponse(String response) { |
331 |
boolean nameSpace = false; |
332 |
int n = -1; |
333 |
if (response != null){ |
334 |
if ((n = response.indexOf(':')) != -1){ |
335 |
nameSpace = true;
|
336 |
} |
337 |
} |
338 |
|
339 |
if (nameSpace){
|
340 |
ResponseListener listener = (ResponseListener) spaceListener.get(response.substring(0, n));
|
341 |
if (listener != null) |
342 |
listener.acceptResponse(response.substring(n+1));
|
343 |
}else{
|
344 |
Iterator i = spaceListener.values().iterator();
|
345 |
while (i.hasNext()) {
|
346 |
ResponseListener listener = (ResponseListener) i.next(); |
347 |
listener.acceptResponse(response); |
348 |
} |
349 |
} |
350 |
} |
351 |
|
352 |
/**
|
353 |
* @param listener
|
354 |
*/
|
355 |
public void deleteListener(ResponseListener listener) { |
356 |
Iterator i = spaceListener.keySet().iterator();
|
357 |
while (i.hasNext()) {
|
358 |
String namespace = (String) i.next(); |
359 |
ResponseListener l = (ResponseListener) spaceListener.get(namespace); |
360 |
if (l == listener){
|
361 |
spaceListener.remove(namespace); |
362 |
} |
363 |
} |
364 |
} |
365 |
|
366 |
} |
367 |
|
368 |
|
369 |
|
370 |
|
371 |
/**
|
372 |
* DOCUMENT ME!
|
373 |
*/
|
374 |
protected void initComponents() { // GEN-BEGIN:initComponents |
375 |
m_MapControl = new MapControl(); // Default is paintEnabled = false. |
376 |
// Remember to activate it
|
377 |
m_MapControl.addExceptionListener(mapControlExceptionListener); |
378 |
m_TOC = new TOC();
|
379 |
|
380 |
// Ponemos el localizador
|
381 |
m_MapLoc = new MapOverview(m_MapControl);
|
382 |
removeAll(); |
383 |
tempMainSplit = new ViewSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
384 |
|
385 |
if (windowData==null) { |
386 |
m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
387 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
388 |
} |
389 |
|
390 |
if (!isPalette()){
|
391 |
tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
392 |
tempSplitToc.setTopComponent(m_TOC); |
393 |
tempSplitToc.setBottomComponent(m_MapLoc); |
394 |
tempSplitToc.setResizeWeight(0.7);
|
395 |
tempMainSplit.setLeftComponent(tempSplitToc); |
396 |
}else{
|
397 |
tempMainSplit.setLeftComponent(m_TOC); |
398 |
} |
399 |
m_TOC.setVisible(true);
|
400 |
tempMainSplit.setRightComponent(m_MapControl); |
401 |
//split.setBottomComponent(getConsolePanel());
|
402 |
//split.setTopComponent(tempMainSplit);
|
403 |
// split.setResizeWeight(0.9);
|
404 |
this.setLayout(new BorderLayout()); |
405 |
this.add(tempMainSplit, BorderLayout.CENTER); |
406 |
|
407 |
|
408 |
if (windowData!=null) { |
409 |
try {
|
410 |
tempMainSplit.setDividerLocation(Integer.valueOf(windowData.get("MainDivider.Location")).intValue()); |
411 |
if (windowData.get("TOCDivider.Location")!=null) { |
412 |
tempSplitToc.setDividerLocation(Integer.valueOf(windowData.get("TOCDivider.Location")).intValue()); |
413 |
} |
414 |
} |
415 |
catch (NumberFormatException ex) { |
416 |
PluginServices.getLogger().error("Error restoring View properties");
|
417 |
} |
418 |
} |
419 |
|
420 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado
|
421 |
StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
422 |
|
423 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
424 |
// No es dibujando un rect?ngulo, es solo pinchando.
|
425 |
|
426 |
ZoomOutListener zol = new ZoomOutListener(m_MapControl);
|
427 |
m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
428 |
|
429 |
// pan
|
430 |
|
431 |
PanListener pl = new PanListener(m_MapControl);
|
432 |
m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
433 |
|
434 |
// Medir
|
435 |
|
436 |
MeasureListener mli = new MeasureListener(m_MapControl);
|
437 |
m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
438 |
|
439 |
// Area
|
440 |
|
441 |
AreaListener ali = new AreaListener(m_MapControl);
|
442 |
m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
443 |
|
444 |
//Seleccion por punto
|
445 |
PointSelectListener psl = new PointSelectListener(m_MapControl);
|
446 |
m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
447 |
|
448 |
//Info por punto
|
449 |
InfoListener il = new InfoListener(m_MapControl);
|
450 |
m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
451 |
|
452 |
// Link por punto
|
453 |
LinkListener ll = new LinkListener(m_MapControl);
|
454 |
m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
455 |
|
456 |
//Selecci?n por rect?ngulo
|
457 |
RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl);
|
458 |
m_MapControl.addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
459 |
|
460 |
//Selecci?n por pol?gono
|
461 |
PolygonSelectListener poligSel = new PolygonSelectListener(m_MapControl);
|
462 |
m_MapControl.addMapTool("polSelection", new Behavior[]{new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl)}); |
463 |
|
464 |
// Zoom por rect?ngulo
|
465 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl);
|
466 |
ZoomInListener zil = new ZoomInListener(m_MapControl);
|
467 |
m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
468 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
469 |
|
470 |
SelectImageListener sil = new SelectImageListener(m_MapControl);
|
471 |
m_MapControl.addMapTool("selectImage", new Behavior[]{ |
472 |
new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
473 |
|
474 |
//ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl);
|
475 |
//m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)});
|
476 |
|
477 |
m_MapControl.setTool("zoomIn"); // Por defecto |
478 |
// m_MapControl.setPaintEnabled(true);
|
479 |
} |
480 |
|
481 |
/**
|
482 |
* DOCUMENT ME!
|
483 |
*/
|
484 |
/*public void openPropertiesWindow() {
|
485 |
}
|
486 |
*/
|
487 |
/**
|
488 |
* DOCUMENT ME!
|
489 |
*/
|
490 |
/* public void openQueryWindow() {
|
491 |
}
|
492 |
*/
|
493 |
|
494 |
|
495 |
/**
|
496 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
497 |
*/
|
498 |
public void windowActivated() { |
499 |
PluginServices.getMainFrame().getStatusBar().setMessage("units",
|
500 |
PluginServices.getText(this, MapContext.getDistanceNames()[getMapControl().getMapContext().getViewPort().getDistanceUnits()]));
|
501 |
PluginServices.getMainFrame().getStatusBar().setControlValue("scale",String.valueOf(m_MapControl.getMapContext().getScaleView())); |
502 |
PluginServices.getMainFrame().getStatusBar().setMessage("projection", getMapControl().getViewPort().getProjection().getAbrev());
|
503 |
} |
504 |
/**
|
505 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
506 |
*/
|
507 |
public void windowClosed() { |
508 |
super.windowClosed();
|
509 |
if (viewPortListener!=null) |
510 |
getMapControl().getViewPort().removeViewPortListener(viewPortListener); |
511 |
if (getMapOverview()!=null) |
512 |
getMapOverview().getViewPort().removeViewPortListener(getMapOverview()); |
513 |
|
514 |
} |
515 |
public void toPalette() { |
516 |
isPalette=true;
|
517 |
m_MapLoc.setPreferredSize(new Dimension(200,150)); |
518 |
m_MapLoc.setSize(new Dimension(200,150)); |
519 |
movp=new MapOverViewPalette(m_MapLoc,this); |
520 |
PluginServices.getMDIManager().addWindow(movp); |
521 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives();
|
522 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
523 |
if (((FLyrVect)layers[0]).isEditing()){ |
524 |
showConsole(); |
525 |
return;
|
526 |
} |
527 |
} |
528 |
hideConsole(); |
529 |
|
530 |
} |
531 |
|
532 |
public void restore() { |
533 |
isPalette=false;
|
534 |
PluginServices.getMDIManager().closeWindow(movp); |
535 |
FLayer[] layers=getModel().getMapContext().getLayers().getActives();
|
536 |
if (layers.length>0 && layers[0] instanceof FLyrVect){ |
537 |
if (((FLyrVect)layers[0]).isEditing()){ |
538 |
showConsole(); |
539 |
return;
|
540 |
} |
541 |
} |
542 |
hideConsole(); |
543 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
544 |
tempSplitToc.setTopComponent(m_TOC); |
545 |
tempSplitToc.setBottomComponent(m_MapLoc); |
546 |
tempSplitToc.setResizeWeight(0.7);
|
547 |
tempMainSplit.setLeftComponent(tempSplitToc); |
548 |
} |
549 |
|
550 |
/**
|
551 |
* Sets the default map overview background color that will be used in subsequent
|
552 |
* projects.
|
553 |
*
|
554 |
* @param color
|
555 |
*/
|
556 |
public static void setDefaultMapOverViewBackColor(Color color) { |
557 |
if (true) |
558 |
throw new Error("support for map overview back color not yet implemented"); |
559 |
defaultMapOverViewColor = color; |
560 |
} |
561 |
|
562 |
/**
|
563 |
* Returns the current default map overview background color defined which
|
564 |
* is the color defined when the user does not define any other one
|
565 |
* @return java.awt.Color
|
566 |
*/
|
567 |
public static Color getDefaultMapOverViewBackColor() { |
568 |
if (true) |
569 |
throw new Error("support for map overview back color not yet implemented"); |
570 |
// TODO es millorable?
|
571 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
572 |
if (xml.contains("DefaultMapOverViewBackColor")) |
573 |
defaultMapOverViewColor = StringUtilities. |
574 |
string2Color(xml.getStringProperty("DefaultMapOverViewBackColor"));
|
575 |
return defaultMapOverViewColor;
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* Returns the current default view background color defined which is the
|
580 |
* color defined when the user does not define any other one
|
581 |
* @return java.awt.Color
|
582 |
*/
|
583 |
public static Color getDefaultBackColor() { |
584 |
// TODO es millorable?
|
585 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
586 |
if (xml.contains("DefaultViewBackColor")) |
587 |
defaultViewBackColor = StringUtilities. |
588 |
string2Color(xml.getStringProperty("DefaultViewBackColor"));
|
589 |
return defaultViewBackColor;
|
590 |
} |
591 |
|
592 |
/**
|
593 |
* Sets the default view background color that will be used in subsequent
|
594 |
* projects.
|
595 |
*
|
596 |
* @param color
|
597 |
*/
|
598 |
public static void setDefaultBackColor(Color color) { |
599 |
defaultViewBackColor = color; |
600 |
} |
601 |
|
602 |
|
603 |
} |