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