root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / DEMO / SingleView.java @ 7771
History | View | Annotate | Download (28.6 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-may-2003
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.DEMO; |
48 |
|
49 |
import java.awt.BorderLayout; |
50 |
import java.awt.Color; |
51 |
import java.awt.Dimension; |
52 |
import java.awt.Point; |
53 |
import java.awt.event.KeyAdapter; |
54 |
import java.awt.event.KeyEvent; |
55 |
import java.awt.event.WindowEvent; |
56 |
import java.awt.event.WindowListener; |
57 |
import java.awt.geom.Point2D; |
58 |
import java.awt.image.ImageObserver; |
59 |
import java.util.Locale; |
60 |
|
61 |
import javax.swing.ButtonGroup; |
62 |
import javax.swing.JButton; |
63 |
import javax.swing.JDialog; |
64 |
import javax.swing.JFrame; |
65 |
import javax.swing.JMenu; |
66 |
import javax.swing.JMenuItem; |
67 |
import javax.swing.JPanel; |
68 |
import javax.swing.JScrollPane; |
69 |
import javax.swing.JSplitPane; |
70 |
import javax.swing.JTextArea; |
71 |
import javax.swing.JTextField; |
72 |
import javax.swing.JToggleButton; |
73 |
import javax.swing.JToolBar; |
74 |
import javax.swing.UIManager; |
75 |
|
76 |
import org.apache.log4j.Logger; |
77 |
import org.apache.log4j.PropertyConfigurator; |
78 |
|
79 |
import com.iver.andami.messages.Messages; |
80 |
import com.iver.cit.gvsig.fmap.MapControl; |
81 |
import com.iver.cit.gvsig.fmap.ViewPort; |
82 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
83 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
84 |
import com.iver.cit.gvsig.fmap.tools.PanListenerImpl; |
85 |
import com.iver.cit.gvsig.fmap.tools.RectangleSelectionListener; |
86 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutListenerImpl; |
87 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
88 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
89 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
90 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MoveBehavior; |
91 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
92 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
93 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
94 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
95 |
import com.iver.cit.gvsig.gui.panels.FPanelAbout; |
96 |
import com.iver.cit.gvsig.project.documents.view.MapOverview; |
97 |
import com.iver.cit.gvsig.project.documents.view.gui.IView; |
98 |
import com.iver.cit.gvsig.project.documents.view.info.gui.FInfoDialog; |
99 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC; |
100 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.AreaListener; |
101 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener; |
102 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.MeasureListener; |
103 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
104 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomInListener; |
105 |
|
106 |
|
107 |
/* import java.awt.GridBagLayout;
|
108 |
import java.awt.GridBagConstraints;
|
109 |
import java.awt.Insets;
|
110 |
import java.awt.Dimension; */
|
111 |
|
112 |
/**
|
113 |
* @author Administrador
|
114 |
*
|
115 |
* To change the template for this generated type comment go to
|
116 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
117 |
*/
|
118 |
public class SingleView extends JFrame implements IView, WindowListener { |
119 |
public static ImageObserver m_ImageObserver = null; |
120 |
private static Logger logger = Logger.getLogger(SingleView.class.getName()); |
121 |
|
122 |
public JPanel panelvista = null; |
123 |
|
124 |
//public FLegend jLeyenda;
|
125 |
//private TOC vTOC;
|
126 |
public MapControl m_MapControl;
|
127 |
public FInfoDialog m_dlgInfo;
|
128 |
// public FProjection m_Projection;
|
129 |
private JScrollPane jscrollTOC; |
130 |
private TOC m_TOC;
|
131 |
private MapOverview m_MapLoc;
|
132 |
private String m_Name = null; |
133 |
// private com.iver.cit.opensig.project.View modelo;
|
134 |
|
135 |
private javax.swing.JMenuItem aboutMenuItem;
|
136 |
private javax.swing.JButton btn_FullExtent;
|
137 |
private javax.swing.JMenuItem contentsMenuItem;
|
138 |
private javax.swing.JMenuItem copyMenuItem;
|
139 |
private javax.swing.JMenuItem cutMenuItem;
|
140 |
private javax.swing.JMenuItem deleteMenuItem;
|
141 |
private javax.swing.JMenu editMenu;
|
142 |
private javax.swing.JMenuItem exitMenuItem;
|
143 |
private javax.swing.JMenu fileMenu;
|
144 |
private javax.swing.JMenu helpMenu;
|
145 |
private javax.swing.JLabel jLabel1;
|
146 |
private javax.swing.JPanel jPanel1;
|
147 |
private javax.swing.JTextField jTextField1;
|
148 |
private javax.swing.JToolBar jToolBar1;
|
149 |
public Export jExport;
|
150 |
private ComandosListener m_acL;
|
151 |
|
152 |
private javax.swing.JMenuBar menuBar;
|
153 |
|
154 |
private class myKeyAdapter extends KeyAdapter { |
155 |
/* (non-Javadoc)
|
156 |
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
157 |
*/
|
158 |
public void keyReleased(KeyEvent arg0) { |
159 |
System.out.println("Hola colega"); |
160 |
super.keyReleased(arg0);
|
161 |
} |
162 |
|
163 |
} |
164 |
private myKeyAdapter m_OrejaTeclado = new myKeyAdapter(); |
165 |
/** Button group for pan, zoom, and all exclusive tools */
|
166 |
private ButtonGroup myButtonGroup = new ButtonGroup(); |
167 |
private javax.swing.JMenuItem openMenuItem;
|
168 |
private javax.swing.JMenuItem exportMenuItem;
|
169 |
private javax.swing.JMenuItem pasteMenuItem;
|
170 |
private javax.swing.JMenuItem saveAsMenuItem;
|
171 |
private javax.swing.JMenuItem saveMenuItem;
|
172 |
private javax.swing.JMenu CapaMenu;
|
173 |
private javax.swing.JMenuItem verTabla;
|
174 |
private javax.swing.JMenu VistaMenu;
|
175 |
private JTextArea m_txt; |
176 |
private JTextField m_txtCoords; |
177 |
|
178 |
|
179 |
SingleView() { |
180 |
m_ImageObserver = this;
|
181 |
setSize(640, 480); |
182 |
initComponents(); |
183 |
|
184 |
// setExtendedState(MAXIMIZED_BOTH);
|
185 |
addWindowListener((WindowListener) this); |
186 |
// m_Map.addMouseListener(this);
|
187 |
m_dlgInfo = new FInfoDialog();
|
188 |
// addMouseListener(this);
|
189 |
// addKeyListener((KeyListener) this);
|
190 |
addKeyListener(m_OrejaTeclado); |
191 |
|
192 |
// LayerFactory.setDriversPath("D:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
193 |
LayerFactory.setDriversPath("D:/java/eclipse30/eclipse/workspace/FMap 03/driversDebug");
|
194 |
// m_MapControl.addTool(MapControl.ZOOM_MAS);
|
195 |
// m_MapControl.addCoordsListener(this);
|
196 |
|
197 |
} |
198 |
|
199 |
|
200 |
public MapControl getMapControl()
|
201 |
{ |
202 |
return m_MapControl;
|
203 |
} |
204 |
public MapControl getMapOverview()
|
205 |
{ |
206 |
return m_MapLoc;
|
207 |
} |
208 |
|
209 |
public static void main(String[] args) { |
210 |
try {
|
211 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
212 |
} catch (Exception e) { |
213 |
System.out.println(UIManager.getCrossPlatformLookAndFeelClassName()); |
214 |
} |
215 |
PropertyConfigurator.configure(SingleView.class.getClassLoader() |
216 |
.getResource("log4j.properties"));
|
217 |
|
218 |
Locale loc = null; |
219 |
|
220 |
if (args.length == 0) { |
221 |
loc = Locale.getDefault();
|
222 |
} else {
|
223 |
loc = new Locale(args[0]); |
224 |
} |
225 |
|
226 |
Messages.init(loc); |
227 |
|
228 |
|
229 |
SingleView testApp = new SingleView();
|
230 |
|
231 |
// testApp.getContentPane().add(elMapa);
|
232 |
testApp.show(); |
233 |
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* Add the tools to the tools panel.
|
238 |
*/
|
239 |
private void addTools(JToolBar inPanel, MapControl inDisplay) { |
240 |
/* inPanel.setLayout(new GridBagLayout());
|
241 |
GridBagConstraints c = new GridBagConstraints();
|
242 |
c.fill = c.HORIZONTAL;
|
243 |
c.insets = new Insets(1,1,1,1);
|
244 |
c.weightx = 1;
|
245 |
|
246 |
// set the width of the panel.
|
247 |
inPanel.setPreferredSize(new Dimension(40,40));
|
248 |
inPanel.setMinimumSize(new Dimension(40,10));
|
249 |
|
250 |
|
251 |
|
252 |
c.gridy = 0;
|
253 |
c.gridx = 0; */
|
254 |
|
255 |
inPanel.setLayout(new BorderLayout()); |
256 |
|
257 |
JToolBar tempPanel = new JToolBar(); |
258 |
|
259 |
JButton btnSymbolManager = new JButton(); |
260 |
btnSymbolManager.setIcon(new javax.swing.ImageIcon(
|
261 |
"images/Link.png"));
|
262 |
btnSymbolManager.setActionCommand("SYMBOL_MANAGER");
|
263 |
btnSymbolManager.addActionListener(m_acL); |
264 |
tempPanel.add(btnSymbolManager); |
265 |
|
266 |
|
267 |
btn_FullExtent.setIcon(new javax.swing.ImageIcon(
|
268 |
"images/MapContents.png"));
|
269 |
btn_FullExtent.setActionCommand("ZOOM_TODO");
|
270 |
btn_FullExtent.addActionListener(m_acL); |
271 |
tempPanel.add(btn_FullExtent); |
272 |
|
273 |
JButton btnZoomPrevio = new JButton(); |
274 |
btnZoomPrevio.setIcon(new javax.swing.ImageIcon(
|
275 |
"images/ZoomPrevio.png"));
|
276 |
btnZoomPrevio.setActionCommand("ZOOM_PREVIO");
|
277 |
btnZoomPrevio.addActionListener(m_acL); |
278 |
tempPanel.add(btnZoomPrevio); |
279 |
|
280 |
tempPanel.add(new JToolBar.Separator(new java.awt.Dimension(16,16))); |
281 |
// inPanel.add(new JToolBar.Separator());
|
282 |
|
283 |
// the select tool not that it does anything
|
284 |
// the zoom in tool
|
285 |
// c.gridy++;
|
286 |
// JRadioButton tempGISButton = new JRadioButton("Zoom In", ? new ZoomInCommand(this));
|
287 |
// JRadioButton tempGISButton = new JRadioButton("Zoom In");
|
288 |
JToggleButton tempGISButton = new JToggleButton("Zoom por rect?ngulo"); |
289 |
tempGISButton.setBorder(null);
|
290 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/zoomIn.png")); |
291 |
|
292 |
// tempGISButton.setSelectedIcon(new javax.swing.ImageIcon("images/zoomPrev.gif"));
|
293 |
// tempGISButton.setRolloverIcon(tempGISButton.getSelectedIcon());
|
294 |
tempGISButton.setRolloverEnabled(true);
|
295 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
296 |
tempGISButton.setText("");
|
297 |
tempGISButton.setSelected(true);
|
298 |
tempGISButton.setActionCommand("ZOOM_MAS");
|
299 |
tempGISButton.addActionListener(m_acL); |
300 |
|
301 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado
|
302 |
StatusBarListener sbl = new StatusBarListener(m_MapControl);
|
303 |
|
304 |
// Zoom por rect?ngulo
|
305 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl);
|
306 |
ZoomInListener zil = new ZoomInListener(m_MapControl);
|
307 |
m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
308 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
309 |
|
310 |
m_MapControl.setTool("zoomIn"); // Por defecto |
311 |
|
312 |
//TODO: Antes funcionaba con esto
|
313 |
/* ZoomInListenerImpl zili = new ZoomInListenerImpl(m_MapControl);
|
314 |
m_MapControl.setCursor(zili.getCursor());
|
315 |
m_MapControl.addMapTool("zoomrect",
|
316 |
new RectangleBehavior(zili));
|
317 |
m_MapControl.setTool("zoomrect");
|
318 |
*/
|
319 |
myButtonGroup.add(tempGISButton); |
320 |
|
321 |
// inPanel.add(tempGISButton, c);
|
322 |
tempPanel.add(tempGISButton); |
323 |
|
324 |
// the zoom out tool
|
325 |
// c.gridy++;
|
326 |
tempGISButton = new JToggleButton("Alejar"); //, new ZoomOutCommand(this)); |
327 |
tempGISButton.setBorder(null);
|
328 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/zoomOut.png")); |
329 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s).
|
330 |
// No es dibujando un rect?ngulo, es solo pinchando.
|
331 |
|
332 |
ZoomOutListenerImpl zoli = new ZoomOutListenerImpl(m_MapControl);
|
333 |
m_MapControl.addMapTool("zoomout", new PointBehavior(zoli)); |
334 |
m_MapControl.setCursor(zoli.getCursor()); |
335 |
|
336 |
// pan
|
337 |
|
338 |
PanListenerImpl pli = new PanListenerImpl(m_MapControl);
|
339 |
m_MapControl.setCursor(pli.getCursor()); |
340 |
m_MapControl.addMapTool("pan", new MoveBehavior(pli)); |
341 |
|
342 |
// info
|
343 |
//Info por punto
|
344 |
InfoListener il = new InfoListener(m_MapControl);
|
345 |
//il.setModel(modelo);
|
346 |
m_MapControl.addMapTool("info", new PointBehavior(il)); |
347 |
|
348 |
//Selecci?n por rect?ngulo
|
349 |
RectangleSelectionListener rsl = new RectangleSelectionListener(m_MapControl);
|
350 |
m_MapControl.addMapTool("rectSelection",
|
351 |
new RectangleBehavior(rsl));
|
352 |
|
353 |
// Medir
|
354 |
|
355 |
MeasureListener mli = new MeasureListener(m_MapControl);
|
356 |
m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)}); |
357 |
|
358 |
// Area
|
359 |
|
360 |
AreaListener ali = new AreaListener(m_MapControl);
|
361 |
m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
362 |
|
363 |
|
364 |
// tempGISButton.setSelectedIcon(getIcon("ZoomOutActive.png"));
|
365 |
// tempGISButton.setRolloverIcon(tempGISButton.getSelectedIcon());
|
366 |
// tempGISButton.setRolloverEnabled(true);
|
367 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
368 |
tempGISButton.setText("");
|
369 |
tempGISButton.setActionCommand("ZOOM_MENOS");
|
370 |
tempGISButton.addActionListener(m_acL); |
371 |
|
372 |
myButtonGroup.add(tempGISButton); |
373 |
|
374 |
// inPanel.add(tempGISButton, c);
|
375 |
tempPanel.add(tempGISButton); |
376 |
|
377 |
// The Pan Tool
|
378 |
// c.gridy++;
|
379 |
tempGISButton = new JToggleButton("Pan Around"); // , new PanCommand(this)); |
380 |
tempGISButton.setBorder(null);
|
381 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/pan.png")); // getIcon("PanInactive.png")); |
382 |
|
383 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
384 |
tempGISButton.setText("");
|
385 |
tempGISButton.setActionCommand("PAN");
|
386 |
tempGISButton.addActionListener(m_acL); |
387 |
|
388 |
myButtonGroup.add(tempGISButton); |
389 |
tempPanel.add(tempGISButton); |
390 |
|
391 |
tempGISButton = new JToggleButton("Info"); // , new PanCommand(this)); |
392 |
tempGISButton.setBorder(null);
|
393 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/identify.png")); // getIcon("PanInactive.png")); |
394 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
395 |
tempGISButton.setText("");
|
396 |
tempGISButton.setActionCommand("INFO");
|
397 |
tempGISButton.addActionListener(m_acL); |
398 |
|
399 |
myButtonGroup.add(tempGISButton); |
400 |
tempPanel.add(tempGISButton); |
401 |
|
402 |
tempGISButton = new JToggleButton("Selecci?n por rect?ngulo"); |
403 |
tempGISButton.setBorder(null);
|
404 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/Select.png")); |
405 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
406 |
tempGISButton.setText("");
|
407 |
tempGISButton.setActionCommand("SELRECT");
|
408 |
tempGISButton.addActionListener(m_acL); |
409 |
|
410 |
myButtonGroup.add(tempGISButton); |
411 |
tempPanel.add(tempGISButton); |
412 |
|
413 |
|
414 |
tempGISButton = new JToggleButton("Medir distancia"); // , new PanCommand(this)); |
415 |
tempGISButton.setBorder(null);
|
416 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/medir.png")); // getIcon("PanInactive.png")); |
417 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
418 |
tempGISButton.setText("");
|
419 |
tempGISButton.setActionCommand("MEDICION");
|
420 |
tempGISButton.addActionListener(m_acL); |
421 |
|
422 |
myButtonGroup.add(tempGISButton); |
423 |
tempPanel.add(tempGISButton); |
424 |
|
425 |
tempGISButton = new JToggleButton("Medir area"); // , new PanCommand(this)); |
426 |
tempGISButton.setBorder(null);
|
427 |
tempGISButton.setIcon(new javax.swing.ImageIcon("images/poligono16.png")); // getIcon("PanInactive.png")); |
428 |
tempGISButton.setToolTipText(tempGISButton.getText()); |
429 |
tempGISButton.setText("");
|
430 |
tempGISButton.setActionCommand("MEDIRAREA");
|
431 |
tempGISButton.addActionListener(m_acL); |
432 |
|
433 |
myButtonGroup.add(tempGISButton); |
434 |
tempPanel.add(tempGISButton); |
435 |
|
436 |
|
437 |
|
438 |
|
439 |
inPanel.setRollover(true);
|
440 |
|
441 |
/* tempMenuButton = new GISMenuButton(tempEditNodesCommand, tempRadioButton);
|
442 |
tempEditNodesCommand.setButton(tempMenuButton);
|
443 |
tempMenuButton.initPanel();
|
444 |
inPanel.add(tempMenuButton, c); */
|
445 |
|
446 |
// Add a panel for the additional buttons.
|
447 |
m_txtCoords = new JTextField(); |
448 |
m_txtCoords.setPreferredSize(new Dimension(300,20)); |
449 |
|
450 |
inPanel.add(tempPanel,BorderLayout.WEST);
|
451 |
inPanel.add(m_txtCoords, BorderLayout.EAST);
|
452 |
|
453 |
/* c.gridy++;
|
454 |
c.anchor = c.NORTH;
|
455 |
c.weighty = 1;
|
456 |
c.fill = c.HORIZONTAL;
|
457 |
inPanel.add(new JPanel(), c); */
|
458 |
|
459 |
// inPanel.add(myAuxillaryButtonPanel, c);
|
460 |
|
461 |
} |
462 |
|
463 |
/** Exit the Application */
|
464 |
private void exitForm(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_exitForm |
465 |
System.exit(0); |
466 |
} |
467 |
|
468 |
//GEN-LAST:event_exitForm
|
469 |
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_exitMenuItemActionPerformed |
470 |
System.exit(0); |
471 |
} |
472 |
|
473 |
private void info(Point pScreen){ |
474 |
ViewPort vp = m_MapControl.getMapContext().getViewPort(); |
475 |
Point2D pReal = vp.toMapPoint(pScreen);
|
476 |
|
477 |
FLayer[] sel = m_MapControl.getMapContext().getLayers().getActives();
|
478 |
|
479 |
// Denro de queryByPoint tenemos que separar los registros que vienen asociados a una
|
480 |
// capa o a otra. Supongo que lo correcto ser?a que montaramos un XML y usar el visor
|
481 |
// de XML que ha empezado Fernando.
|
482 |
// String strResul = m_MapControl.queryByPoint(pScreen,m_MapControl.toMapDistance(3),"");
|
483 |
|
484 |
JDialog dlg = new JDialog(); |
485 |
m_dlgInfo.setPreferredSize(m_dlgInfo.getSize()); |
486 |
//m_dlgInfo.clearAll();
|
487 |
|
488 |
// if (strResul == "" ) return;
|
489 |
String strResul;
|
490 |
|
491 |
for (int i=0; i< sel.length; i++) |
492 |
{ |
493 |
FLayer laCapa = sel[i]; |
494 |
|
495 |
/* if (laCapa instanceof FLyrWMS)
|
496 |
{
|
497 |
strResul = laCapa.QueryByPoint(pScreen,m_MapControl.toMapDistance(3),"" );
|
498 |
// System.out.println("LWS: strResul="+strResul);
|
499 |
m_dlgInfo.addLayerInfo(laCapa.getName(), strResul);
|
500 |
}
|
501 |
else
|
502 |
{
|
503 |
strResul = laCapa.QueryByPoint(pReal,m_MapControl.toMapDistance(3),"" );
|
504 |
|
505 |
String[] arraySplit = null;
|
506 |
arraySplit = strResul.split("\n");
|
507 |
|
508 |
if (arraySplit.length > 1)
|
509 |
{
|
510 |
// System.out.println("LWS: strResul="+strResul);
|
511 |
String descrip = "";
|
512 |
if (laCapa.getParentLayer() != null)
|
513 |
descrip = laCapa.getParentLayer().getName() + "_";
|
514 |
m_dlgInfo.addLayerInfo(descrip + laCapa.getName(), strResul);
|
515 |
}
|
516 |
|
517 |
} */
|
518 |
} |
519 |
//m_dlgInfo.refresh();
|
520 |
dlg.getContentPane().add(m_dlgInfo); |
521 |
dlg.setModal(true);
|
522 |
dlg.pack(); |
523 |
dlg.show(); |
524 |
|
525 |
} |
526 |
|
527 |
//GEN-LAST:event_exitMenuItemActionPerformed
|
528 |
private void initComponents() { //GEN-BEGIN:initComponents |
529 |
jToolBar1 = new javax.swing.JToolBar();
|
530 |
btn_FullExtent = new javax.swing.JButton();
|
531 |
jLabel1 = new javax.swing.JLabel();
|
532 |
jTextField1 = new javax.swing.JTextField();
|
533 |
|
534 |
jPanel1 = new javax.swing.JPanel();
|
535 |
menuBar = new javax.swing.JMenuBar();
|
536 |
fileMenu = new javax.swing.JMenu();
|
537 |
openMenuItem = new javax.swing.JMenuItem();
|
538 |
saveMenuItem = new javax.swing.JMenuItem();
|
539 |
saveAsMenuItem = new javax.swing.JMenuItem();
|
540 |
exportMenuItem = new javax.swing.JMenuItem();
|
541 |
exitMenuItem = new javax.swing.JMenuItem();
|
542 |
editMenu = new javax.swing.JMenu();
|
543 |
cutMenuItem = new javax.swing.JMenuItem();
|
544 |
copyMenuItem = new javax.swing.JMenuItem();
|
545 |
pasteMenuItem = new javax.swing.JMenuItem();
|
546 |
deleteMenuItem = new javax.swing.JMenuItem();
|
547 |
helpMenu = new javax.swing.JMenu();
|
548 |
contentsMenuItem = new javax.swing.JMenuItem();
|
549 |
aboutMenuItem = new javax.swing.JMenuItem();
|
550 |
|
551 |
VistaMenu = new JMenu(); |
552 |
CapaMenu = new JMenu(); |
553 |
verTabla = new JMenuItem(); |
554 |
|
555 |
m_txt = new JTextArea(0,0); |
556 |
// jToolBar1.add(m_txt);
|
557 |
// m_txt.addKeyListener(m_OrejaTeclado);
|
558 |
|
559 |
addWindowListener(new java.awt.event.WindowAdapter() {
|
560 |
public void windowClosing(java.awt.event.WindowEvent evt) { |
561 |
exitForm(evt); |
562 |
} |
563 |
}); |
564 |
|
565 |
jLabel1.setText("Escala:");
|
566 |
|
567 |
// jToolBar1.add(jLabel1);
|
568 |
jTextField1.setText("jTextField1");
|
569 |
|
570 |
// jToolBar1.add(jTextField1);
|
571 |
|
572 |
m_MapControl = new MapControl();
|
573 |
|
574 |
m_MapControl.getMapContext().getViewPort() |
575 |
.setBackColor(new Color(220,220,255)); |
576 |
|
577 |
m_TOC = new TOC();
|
578 |
m_TOC.setMapContext(m_MapControl.getMapContext()); |
579 |
m_MapLoc = new MapOverview(m_MapControl);
|
580 |
m_MapLoc.setPreferredSize(new Dimension(150,200)); |
581 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
582 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
583 |
// jscrollTOC = new JScrollPane(m_TOC);
|
584 |
|
585 |
//jscrollTOC.setPreferredSize(new Dimension(200, 1000));
|
586 |
// jscrollTOC.setSize(300, 600);
|
587 |
|
588 |
//jscrollTOC.setAutoscrolls(true);
|
589 |
//jscrollTOC.setVisible(true);
|
590 |
// tempMainSplit.setLeftComponent(jscrollTOC);
|
591 |
|
592 |
// Ponemos el localizador
|
593 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
594 |
|
595 |
tempSplitToc.setTopComponent(m_TOC); |
596 |
tempSplitToc.setBottomComponent(m_MapLoc); |
597 |
tempSplitToc.setResizeWeight(0.7);
|
598 |
tempMainSplit.setLeftComponent(tempSplitToc); |
599 |
|
600 |
m_TOC.setVisible(true);
|
601 |
|
602 |
tempMainSplit.setRightComponent(m_MapControl); |
603 |
|
604 |
this.getContentPane().setLayout(new BorderLayout()); |
605 |
|
606 |
getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); |
607 |
|
608 |
// getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
|
609 |
|
610 |
|
611 |
this.getContentPane().add(tempMainSplit, BorderLayout.CENTER); |
612 |
|
613 |
|
614 |
m_acL = new ComandosListener(m_MapControl, this); |
615 |
|
616 |
fileMenu.setText("Fichero");
|
617 |
openMenuItem.setText("A?adir capa...");
|
618 |
openMenuItem.setActionCommand("ADD_LAYER");
|
619 |
openMenuItem.addActionListener(m_acL); |
620 |
fileMenu.add(openMenuItem); |
621 |
|
622 |
JMenuItem abrirEnMemoria = new JMenuItem(); |
623 |
abrirEnMemoria.setText("A?adir capa en memoria...");
|
624 |
abrirEnMemoria.setActionCommand("ADD_MEMORY_LAYER");
|
625 |
abrirEnMemoria.addActionListener(m_acL); |
626 |
fileMenu.add(abrirEnMemoria); |
627 |
|
628 |
|
629 |
// a submenu
|
630 |
JMenu abrirGT2 = new JMenu(); |
631 |
abrirGT2.setText("Abrir capa GT2");
|
632 |
|
633 |
JMenuItem abrirGT2_Shp = new JMenuItem(); |
634 |
abrirGT2_Shp.setText("Shp");
|
635 |
abrirGT2_Shp.setActionCommand("ADD_GT2_SHP");
|
636 |
abrirGT2_Shp.addActionListener(m_acL); |
637 |
abrirGT2.add(abrirGT2_Shp); |
638 |
|
639 |
JMenuItem abrirGT2_PostGIS_propio = new JMenuItem(); |
640 |
abrirGT2_PostGIS_propio.setText("PostGIS propio");
|
641 |
abrirGT2_PostGIS_propio.setActionCommand("ADD_GT2_POSTGIS_PROPIO");
|
642 |
abrirGT2_PostGIS_propio.addActionListener(m_acL); |
643 |
abrirGT2.add(abrirGT2_PostGIS_propio); |
644 |
|
645 |
// ADD_GT2_MYSQL_PROPIO
|
646 |
JMenuItem abrirGT2_MySQL_propio = new JMenuItem(); |
647 |
abrirGT2_MySQL_propio.setText("mySQL propio");
|
648 |
abrirGT2_MySQL_propio.setActionCommand("ADD_GT2_MYSQL_PROPIO");
|
649 |
abrirGT2_MySQL_propio.addActionListener(m_acL); |
650 |
abrirGT2.add(abrirGT2_MySQL_propio); |
651 |
|
652 |
// ADD_GT2_ARCSDE_PROPIO
|
653 |
JMenuItem abrirGT2_ArcSDE_propio = new JMenuItem(); |
654 |
abrirGT2_ArcSDE_propio.setText("ArcSDE propio");
|
655 |
abrirGT2_ArcSDE_propio.setActionCommand("ADD_GT2_ARCSDE_PROPIO");
|
656 |
abrirGT2_ArcSDE_propio.addActionListener(m_acL); |
657 |
abrirGT2.add(abrirGT2_ArcSDE_propio); |
658 |
|
659 |
JMenuItem abrirGT2_PostGIS = new JMenuItem(); |
660 |
abrirGT2_PostGIS.setText("PostGIS");
|
661 |
abrirGT2_PostGIS.setActionCommand("ADD_GT2_POSTGIS");
|
662 |
abrirGT2_PostGIS.addActionListener(m_acL); |
663 |
abrirGT2.add(abrirGT2_PostGIS); |
664 |
|
665 |
JMenuItem abrirGT2_ArcSDE = new JMenuItem(); |
666 |
abrirGT2_ArcSDE.setText("ArcSDE");
|
667 |
abrirGT2_ArcSDE.setActionCommand("ADD_GT2_ARCSDE");
|
668 |
abrirGT2_ArcSDE.addActionListener(m_acL); |
669 |
abrirGT2.add(abrirGT2_ArcSDE); |
670 |
|
671 |
fileMenu.add(abrirGT2); |
672 |
|
673 |
fileMenu.addSeparator(); |
674 |
|
675 |
JMenuItem prueba = new JMenuItem(); |
676 |
prueba.setText("Probar breaks");
|
677 |
prueba.setActionCommand("PRUEBA");
|
678 |
prueba.addActionListener(m_acL); |
679 |
fileMenu.add(prueba); |
680 |
|
681 |
/* saveMenuItem.setText("Guardar");
|
682 |
fileMenu.add(saveMenuItem);
|
683 |
saveAsMenuItem.setText("Guardar como ...");
|
684 |
fileMenu.add(saveAsMenuItem);
|
685 |
*/
|
686 |
exportMenuItem.setText("Exportar vista a...");
|
687 |
exportMenuItem.setActionCommand("EXPORT");
|
688 |
exportMenuItem.addActionListener(m_acL); |
689 |
fileMenu.add(exportMenuItem); |
690 |
|
691 |
exitMenuItem.setText("Salir");
|
692 |
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
693 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
694 |
exitMenuItemActionPerformed(evt); |
695 |
} |
696 |
}); |
697 |
|
698 |
fileMenu.add(exitMenuItem); |
699 |
|
700 |
menuBar.add(fileMenu); |
701 |
|
702 |
/*editMenu.setText("Editar");
|
703 |
cutMenuItem.setText("Cortar");
|
704 |
editMenu.add(cutMenuItem);
|
705 |
copyMenuItem.setText("Copiar");
|
706 |
editMenu.add(copyMenuItem);
|
707 |
pasteMenuItem.setText("Pegar");
|
708 |
editMenu.add(pasteMenuItem);
|
709 |
deleteMenuItem.setText("Borrar");
|
710 |
editMenu.add(deleteMenuItem);
|
711 |
menuBar.add(editMenu);
|
712 |
*/
|
713 |
VistaMenu.setText("Vista");
|
714 |
|
715 |
JMenuItem mnuOpenLocator = new JMenuItem(); |
716 |
mnuOpenLocator.setText("Abrir localizador");
|
717 |
mnuOpenLocator.setActionCommand("OPEN_LOCATOR");
|
718 |
mnuOpenLocator.addActionListener(m_acL); |
719 |
VistaMenu.add(mnuOpenLocator); |
720 |
|
721 |
menuBar.add(VistaMenu); |
722 |
|
723 |
CapaMenu.setText("Capaa");
|
724 |
verTabla.setText("Ver tabla de la capa activa...");
|
725 |
verTabla.setActionCommand("VIEW_TABLE");
|
726 |
verTabla.addActionListener(m_acL); |
727 |
|
728 |
CapaMenu.add(verTabla); |
729 |
menuBar.add(CapaMenu); |
730 |
|
731 |
helpMenu.setText("Ayuda");
|
732 |
contentsMenuItem.setText("Temas de Ayuda");
|
733 |
helpMenu.add(contentsMenuItem); |
734 |
|
735 |
aboutMenuItem.setText("Acerca de...");
|
736 |
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
737 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
738 |
JDialog dlg = new JDialog(); |
739 |
FPanelAbout panelAbout = new FPanelAbout();
|
740 |
panelAbout.setPreferredSize(panelAbout.getSize()); |
741 |
dlg.getContentPane().add(panelAbout); |
742 |
dlg.pack(); |
743 |
dlg.setResizable(false);
|
744 |
dlg.setModal(true);
|
745 |
dlg.show(); |
746 |
} |
747 |
}); |
748 |
|
749 |
helpMenu.add(aboutMenuItem); |
750 |
menuBar.add(helpMenu); |
751 |
|
752 |
setJMenuBar(menuBar); |
753 |
|
754 |
|
755 |
// m_TOC.refresh();
|
756 |
|
757 |
|
758 |
addTools(jToolBar1, m_MapControl); |
759 |
} |
760 |
|
761 |
//GEN-END:initComponents
|
762 |
|
763 |
/* (non-Javadoc)
|
764 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
765 |
*/
|
766 |
/* public void mouseClicked(MouseEvent E) {
|
767 |
if (m_Map.m_Estado == FMap.INFO) {
|
768 |
if (m_Map.m_Layers.size() == 0) {
|
769 |
return;
|
770 |
}
|
771 |
|
772 |
Point pScreen = E.getPoint();
|
773 |
Point2D.Double pReal = m_Map.ToMapPoint(pScreen);
|
774 |
FLyrVect laCapa = m_TOC.getFirstLayerSelected(); // m_Mapa.GetLayer(0);
|
775 |
String strResul = laCapa.QueryByPoint(pReal, 10);
|
776 |
|
777 |
// System.out.println(pScreen);
|
778 |
// System.out.println(pReal);
|
779 |
System.out.println("strResul = " + strResul);
|
780 |
|
781 |
// DlgInfo dlgInfo = new DlgInfo(this, true);
|
782 |
m_dlgInfo.clearAll();
|
783 |
m_dlgInfo.addLayerInfo(laCapa.m_LayerName, strResul);
|
784 |
m_dlgInfo.refresh();
|
785 |
m_dlgInfo.show();
|
786 |
}
|
787 |
} */
|
788 |
|
789 |
public void repaintMap() { |
790 |
m_MapControl.drawMap(false);
|
791 |
repaint(); |
792 |
// m_Map.refresh();
|
793 |
} |
794 |
|
795 |
|
796 |
|
797 |
public void windowActivated(WindowEvent e) { |
798 |
} |
799 |
|
800 |
public void windowClosed(WindowEvent e) { |
801 |
System.out.println("Salgo"); |
802 |
} |
803 |
|
804 |
/**
|
805 |
* class for handling messages from the window expecially the window closing event to end
|
806 |
* the process when the window closes.
|
807 |
*/
|
808 |
public void windowClosing(WindowEvent e) { |
809 |
System.out.println("Salgo"); |
810 |
System.exit(0); |
811 |
} |
812 |
|
813 |
public void windowDeactivated(WindowEvent e) { |
814 |
} |
815 |
|
816 |
public void windowDeiconified(WindowEvent e) { |
817 |
} |
818 |
|
819 |
public void windowIconified(WindowEvent e) { |
820 |
} |
821 |
|
822 |
public void windowOpened(WindowEvent e) { |
823 |
} |
824 |
|
825 |
|
826 |
/* (non-Javadoc)
|
827 |
* @see com.iver.cit.opensig.gui.IView#getTOC()
|
828 |
*/
|
829 |
/*public IToc getTOC() {
|
830 |
return m_TOC;
|
831 |
} */
|
832 |
|
833 |
public void showCoords(double x, double y) |
834 |
{ |
835 |
m_txtCoords.setText("x= " + x + " y= " + y); |
836 |
} |
837 |
|
838 |
/* (non-Javadoc)
|
839 |
* @see com.iver.cit.opensig.gui.IView#getViewName()
|
840 |
*/
|
841 |
public String getViewName() { |
842 |
return "Ejemplo de Visor sencillo"; |
843 |
} |
844 |
|
845 |
|
846 |
/* (non-Javadoc)
|
847 |
* @see com.iver.cit.opensig.gui.IView#setViewName(java.lang.String)
|
848 |
*/
|
849 |
public void setViewName(String viewName) { |
850 |
m_Name = viewName; |
851 |
|
852 |
} |
853 |
|
854 |
|
855 |
/* (non-Javadoc)
|
856 |
* @see com.iver.cit.gvsig.fmap.ICoordsListener#coordsChanged(double, double)
|
857 |
*/
|
858 |
public void coordsChanged(double x, double y) { |
859 |
showCoords(x, y); |
860 |
|
861 |
} |
862 |
|
863 |
|
864 |
|
865 |
public TOC getTOC() {
|
866 |
return m_TOC;
|
867 |
} |
868 |
} |