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