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