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