Revision 8303 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/SingleView.java

View differences:

SingleView.java
118 118
public class SingleView extends JFrame implements IView, WindowListener {
119 119
	public static ImageObserver m_ImageObserver = null;
120 120
	private static Logger logger = Logger.getLogger(SingleView.class.getName());
121
	
121

  
122 122
	public JPanel panelvista = null;
123 123

  
124 124
	//public FLegend jLeyenda;
......
131 131
	private MapOverview m_MapLoc;
132 132
	private String m_Name = null;
133 133
	// private com.iver.cit.opensig.project.View modelo;
134
	
134

  
135 135
    private javax.swing.JMenuItem aboutMenuItem;
136 136
    private javax.swing.JButton btn_FullExtent;
137 137
    private javax.swing.JMenuItem contentsMenuItem;
......
148 148
    private javax.swing.JToolBar jToolBar1;
149 149
    public Export jExport;
150 150
    private ComandosListener m_acL;
151
    
151

  
152 152
    private javax.swing.JMenuBar menuBar;
153
    
153

  
154 154
    private class myKeyAdapter extends KeyAdapter {
155 155
    		/* (non-Javadoc)
156 156
		 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
......
174 174
    private javax.swing.JMenu VistaMenu;
175 175
    private JTextArea m_txt;
176 176
    private JTextField m_txtCoords;
177
    
178 177

  
178

  
179 179
    SingleView() {
180 180
    	m_ImageObserver = this;
181 181
        setSize(640, 480);
......
188 188
        // addMouseListener(this);
189 189
        // addKeyListener((KeyListener) this);
190 190
        addKeyListener(m_OrejaTeclado);
191
        
191

  
192 192
		// LayerFactory.setDriversPath("D:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
193
        LayerFactory.setDriversPath("D:/eclipse/workspace/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
193
        LayerFactory.setDriversPath("C:/Workspace-HEAD/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
194 194
        // m_MapControl.addTool(MapControl.ZOOM_MAS);
195 195
        // m_MapControl.addCoordsListener(this);
196
        
196

  
197 197
    }
198 198

  
199 199

  
......
204 204
	public MapControl getMapOverview()
205 205
	{
206 206
		return m_MapLoc;
207
	} 
208
	
207
	}
208

  
209 209
    public static void main(String[] args) {
210 210
		try {
211
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());			
211
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
212 212
		} catch (Exception e) {
213
			System.out.println(UIManager.getCrossPlatformLookAndFeelClassName()); 
214
		} 
213
			System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());
214
		}
215 215
		PropertyConfigurator.configure(SingleView.class.getClassLoader()
216 216
														 .getResource("log4j.properties"));
217 217

  
......
230 230

  
231 231
        // testApp.getContentPane().add(elMapa);
232 232
        testApp.show();
233
        
233

  
234 234
    }
235 235

  
236 236
    /**
......
251 251

  
252 252
        c.gridy = 0;
253 253
        c.gridx = 0; */
254
    	
254

  
255 255
    	inPanel.setLayout(new BorderLayout());
256
    	
256

  
257 257
    	JToolBar tempPanel = new JToolBar();
258 258

  
259 259
        JButton  btnSymbolManager = new JButton();
......
262 262
        btnSymbolManager.setActionCommand("SYMBOL_MANAGER");
263 263
        btnSymbolManager.addActionListener(m_acL);
264 264
        tempPanel.add(btnSymbolManager);
265
    	
266
    	
265

  
266

  
267 267
        btn_FullExtent.setIcon(new javax.swing.ImageIcon(
268 268
                "images/MapContents.png"));
269 269
        btn_FullExtent.setActionCommand("ZOOM_TODO");
270 270
        btn_FullExtent.addActionListener(m_acL);
271 271
        tempPanel.add(btn_FullExtent);
272
        
272

  
273 273
        JButton  btnZoomPrevio = new JButton();
274 274
        btnZoomPrevio.setIcon(new javax.swing.ImageIcon(
275 275
		        "images/ZoomPrevio.png"));
276 276
        btnZoomPrevio.setActionCommand("ZOOM_PREVIO");
277 277
        btnZoomPrevio.addActionListener(m_acL);
278 278
        tempPanel.add(btnZoomPrevio);
279
        
279

  
280 280
        tempPanel.add(new JToolBar.Separator(new java.awt.Dimension(16,16)));
281 281
		// inPanel.add(new JToolBar.Separator());
282 282

  
......
306 306
        ZoomInListener zil = new ZoomInListener(m_MapControl);
307 307
        m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil),
308 308
        				new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
309
        
309

  
310 310
        m_MapControl.setTool("zoomIn"); // Por defecto
311
        
311

  
312 312
        //TODO: Antes funcionaba con esto
313 313
       /*      ZoomInListenerImpl zili = new ZoomInListenerImpl(m_MapControl);
314 314
            m_MapControl.setCursor(zili.getCursor());
315 315
            m_MapControl.addMapTool("zoomrect",
316 316
                    new RectangleBehavior(zili));
317 317
            m_MapControl.setTool("zoomrect");
318
            */ 
318
            */
319 319
        myButtonGroup.add(tempGISButton);
320 320

  
321 321
        // inPanel.add(tempGISButton, c);
......
332 332
        ZoomOutListenerImpl zoli = new ZoomOutListenerImpl(m_MapControl);
333 333
        m_MapControl.addMapTool("zoomout", new PointBehavior(zoli));
334 334
        m_MapControl.setCursor(zoli.getCursor());
335
        
335

  
336 336
        // pan
337 337

  
338 338
        PanListenerImpl pli = new PanListenerImpl(m_MapControl);
339 339
        m_MapControl.setCursor(pli.getCursor());
340 340
        m_MapControl.addMapTool("pan", new MoveBehavior(pli));
341
        
341

  
342 342
        // info
343 343
        //Info por punto
344 344
        InfoListener il = new InfoListener(m_MapControl);
345 345
        //il.setModel(modelo);
346 346
        m_MapControl.addMapTool("info", new PointBehavior(il));
347
        
347

  
348 348
        //Selecci?n por rect?ngulo
349 349
        RectangleSelectionListener rsl = new RectangleSelectionListener(m_MapControl);
350 350
        m_MapControl.addMapTool("rectSelection",
351
                new RectangleBehavior(rsl));   
352
        
351
                new RectangleBehavior(rsl));
352

  
353 353
        // Medir
354 354

  
355 355
        MeasureListener mli = new MeasureListener(m_MapControl);
......
360 360
        AreaListener ali = new AreaListener(m_MapControl);
361 361
        m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
362 362

  
363
        
363

  
364 364
        // tempGISButton.setSelectedIcon(getIcon("ZoomOutActive.png"));
365 365
        // tempGISButton.setRolloverIcon(tempGISButton.getSelectedIcon());
366 366
        // tempGISButton.setRolloverEnabled(true);
......
399 399
        myButtonGroup.add(tempGISButton);
400 400
        tempPanel.add(tempGISButton);
401 401

  
402
        tempGISButton = new JToggleButton("Selecci?n por rect?ngulo"); 
402
        tempGISButton = new JToggleButton("Selecci?n por rect?ngulo");
403 403
        tempGISButton.setBorder(null);
404
        tempGISButton.setIcon(new javax.swing.ImageIcon("images/Select.png")); 
404
        tempGISButton.setIcon(new javax.swing.ImageIcon("images/Select.png"));
405 405
        tempGISButton.setToolTipText(tempGISButton.getText());
406 406
        tempGISButton.setText("");
407 407
        tempGISButton.setActionCommand("SELRECT");
......
409 409

  
410 410
        myButtonGroup.add(tempGISButton);
411 411
        tempPanel.add(tempGISButton);
412
        
413
        
412

  
413

  
414 414
        tempGISButton = new JToggleButton("Medir distancia"); // , new PanCommand(this));
415 415
        tempGISButton.setBorder(null);
416 416
        tempGISButton.setIcon(new javax.swing.ImageIcon("images/medir.png")); // getIcon("PanInactive.png"));
......
421 421

  
422 422
        myButtonGroup.add(tempGISButton);
423 423
        tempPanel.add(tempGISButton);
424
        
424

  
425 425
        tempGISButton = new JToggleButton("Medir area"); // , new PanCommand(this));
426 426
        tempGISButton.setBorder(null);
427 427
        tempGISButton.setIcon(new javax.swing.ImageIcon("images/poligono16.png")); // getIcon("PanInactive.png"));
......
432 432

  
433 433
        myButtonGroup.add(tempGISButton);
434 434
        tempPanel.add(tempGISButton);
435
        
436
        
437 435

  
438
        
436

  
437

  
438

  
439 439
        inPanel.setRollover(true);
440 440

  
441 441
        /* tempMenuButton = new GISMenuButton(tempEditNodesCommand, tempRadioButton);
......
446 446
        // Add a panel for the additional buttons.
447 447
        m_txtCoords = new JTextField();
448 448
        m_txtCoords.setPreferredSize(new Dimension(300,20));
449
        
449

  
450 450
        inPanel.add(tempPanel,BorderLayout.WEST);
451 451
        inPanel.add(m_txtCoords, BorderLayout.EAST);
452 452

  
......
469 469
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_exitMenuItemActionPerformed
470 470
        System.exit(0);
471 471
    }
472
    
472

  
473 473
	private void info(Point pScreen){
474 474
		ViewPort vp = m_MapControl.getMapContext().getViewPort();
475 475
		Point2D pReal = vp.toMapPoint(pScreen);
476 476

  
477 477
		FLayer[] sel = m_MapControl.getMapContext().getLayers().getActives();
478 478

  
479
		// Denro de queryByPoint tenemos que separar los registros que vienen asociados a una 
479
		// Denro de queryByPoint tenemos que separar los registros que vienen asociados a una
480 480
		// capa o a otra. Supongo que lo correcto ser?a que montaramos un XML y usar el visor
481 481
		// de XML que ha empezado Fernando.
482 482
		// String strResul = m_MapControl.queryByPoint(pScreen,m_MapControl.toMapDistance(3),"");
......
484 484
		JDialog dlg = new JDialog();
485 485
		m_dlgInfo.setPreferredSize(m_dlgInfo.getSize());
486 486
		//m_dlgInfo.clearAll();
487
				
487

  
488 488
		// if (strResul == "" ) return;
489 489
		String strResul;
490 490

  
......
501 501
			else
502 502
			{
503 503
				strResul = laCapa.QueryByPoint(pReal,m_MapControl.toMapDistance(3),"" );
504
				
504

  
505 505
		        String[] arraySplit = null;
506 506
		        arraySplit = strResul.split("\n");
507 507

  
......
513 513
						descrip = laCapa.getParentLayer().getName() + "_";
514 514
					m_dlgInfo.addLayerInfo(descrip + laCapa.getName(), strResul);
515 515
				}
516
				
517
			} */			
516

  
517
			} */
518 518
		}
519 519
		//m_dlgInfo.refresh();
520 520
		dlg.getContentPane().add(m_dlgInfo);
521
		dlg.setModal(true);			
521
		dlg.setModal(true);
522 522
		dlg.pack();
523 523
		dlg.show();
524 524

  
525 525
	}
526
 
526

  
527 527
    //GEN-LAST:event_exitMenuItemActionPerformed
528 528
    private void initComponents() { //GEN-BEGIN:initComponents
529 529
        jToolBar1 = new javax.swing.JToolBar();
530 530
        btn_FullExtent = new javax.swing.JButton();
531 531
        jLabel1 = new javax.swing.JLabel();
532 532
        jTextField1 = new javax.swing.JTextField();
533
        
533

  
534 534
        jPanel1 = new javax.swing.JPanel();
535 535
        menuBar = new javax.swing.JMenuBar();
536 536
        fileMenu = new javax.swing.JMenu();
......
547 547
        helpMenu = new javax.swing.JMenu();
548 548
        contentsMenuItem = new javax.swing.JMenuItem();
549 549
        aboutMenuItem = new javax.swing.JMenuItem();
550
     
550

  
551 551
        VistaMenu = new JMenu();
552 552
        CapaMenu = new JMenu();
553 553
        verTabla = new JMenuItem();
554
        
554

  
555 555
        m_txt = new JTextArea(0,0);
556 556
		// jToolBar1.add(m_txt);
557
		// m_txt.addKeyListener(m_OrejaTeclado);        
557
		// m_txt.addKeyListener(m_OrejaTeclado);
558 558

  
559 559
        addWindowListener(new java.awt.event.WindowAdapter() {
560 560
                public void windowClosing(java.awt.event.WindowEvent evt) {
......
573 573

  
574 574
		m_MapControl.getMapContext().getViewPort()
575 575
				.setBackColor(new Color(220,220,255));
576
		
576

  
577 577
		m_TOC = new TOC();
578 578
		m_TOC.setMapContext(m_MapControl.getMapContext());
579 579
		m_MapLoc = new MapOverview(m_MapControl);
......
588 588
		//jscrollTOC.setAutoscrolls(true);
589 589
		//jscrollTOC.setVisible(true);
590 590
		// tempMainSplit.setLeftComponent(jscrollTOC);
591
		
591

  
592 592
		// Ponemos el localizador
593 593
		JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
594
		
594

  
595 595
		tempSplitToc.setTopComponent(m_TOC);
596 596
		tempSplitToc.setBottomComponent(m_MapLoc);
597 597
		tempSplitToc.setResizeWeight(0.7);
598 598
		tempMainSplit.setLeftComponent(tempSplitToc);
599 599

  
600 600
		m_TOC.setVisible(true);
601
		
601

  
602 602
		tempMainSplit.setRightComponent(m_MapControl);
603 603

  
604 604
		this.getContentPane().setLayout(new BorderLayout());
......
618 618
        openMenuItem.setActionCommand("ADD_LAYER");
619 619
        openMenuItem.addActionListener(m_acL);
620 620
        fileMenu.add(openMenuItem);
621
        
621

  
622 622
        JMenuItem generateRedMenu = new JMenuItem("Generar red");
623 623
        generateRedMenu.setActionCommand("NETWORK_GENERATEREDFILE");
624 624
        generateRedMenu.addActionListener(m_acL);
625 625
        fileMenu.add(generateRedMenu);
626 626

  
627
        
628 627

  
629
		JMenuItem abrirEnMemoria = new JMenuItem(); 
628

  
629
		JMenuItem abrirEnMemoria = new JMenuItem();
630 630
		abrirEnMemoria.setText("A?adir capa en memoria...");
631 631
		abrirEnMemoria.setActionCommand("ADD_MEMORY_LAYER");
632 632
		abrirEnMemoria.addActionListener(m_acL);
633 633
		fileMenu.add(abrirEnMemoria);
634
		
635 634

  
635

  
636 636
//		a submenu
637 637
		JMenu abrirGT2 = new JMenu();
638 638
		abrirGT2.setText("Abrir capa GT2");
639
		
640
		JMenuItem abrirGT2_Shp = new JMenuItem(); 
639

  
640
		JMenuItem abrirGT2_Shp = new JMenuItem();
641 641
		abrirGT2_Shp.setText("Shp");
642 642
		abrirGT2_Shp.setActionCommand("ADD_GT2_SHP");
643
		abrirGT2_Shp.addActionListener(m_acL);		
643
		abrirGT2_Shp.addActionListener(m_acL);
644 644
		abrirGT2.add(abrirGT2_Shp);
645 645

  
646
		JMenuItem abrirGT2_PostGIS_propio = new JMenuItem(); 
646
		JMenuItem abrirGT2_PostGIS_propio = new JMenuItem();
647 647
		abrirGT2_PostGIS_propio.setText("PostGIS propio");
648 648
		abrirGT2_PostGIS_propio.setActionCommand("ADD_GT2_POSTGIS_PROPIO");
649
		abrirGT2_PostGIS_propio.addActionListener(m_acL);		
649
		abrirGT2_PostGIS_propio.addActionListener(m_acL);
650 650
		abrirGT2.add(abrirGT2_PostGIS_propio);
651
		
651

  
652 652
		// ADD_GT2_MYSQL_PROPIO
653
		JMenuItem abrirGT2_MySQL_propio = new JMenuItem(); 
653
		JMenuItem abrirGT2_MySQL_propio = new JMenuItem();
654 654
		abrirGT2_MySQL_propio.setText("mySQL propio");
655 655
		abrirGT2_MySQL_propio.setActionCommand("ADD_GT2_MYSQL_PROPIO");
656
		abrirGT2_MySQL_propio.addActionListener(m_acL);		
656
		abrirGT2_MySQL_propio.addActionListener(m_acL);
657 657
		abrirGT2.add(abrirGT2_MySQL_propio);
658
		
658

  
659 659
        // ADD_GT2_ARCSDE_PROPIO
660
        JMenuItem abrirGT2_ArcSDE_propio = new JMenuItem(); 
660
        JMenuItem abrirGT2_ArcSDE_propio = new JMenuItem();
661 661
        abrirGT2_ArcSDE_propio.setText("ArcSDE propio");
662 662
        abrirGT2_ArcSDE_propio.setActionCommand("ADD_GT2_ARCSDE_PROPIO");
663
        abrirGT2_ArcSDE_propio.addActionListener(m_acL);     
663
        abrirGT2_ArcSDE_propio.addActionListener(m_acL);
664 664
        abrirGT2.add(abrirGT2_ArcSDE_propio);
665
		
666
		JMenuItem abrirGT2_PostGIS = new JMenuItem(); 
665

  
666
		JMenuItem abrirGT2_PostGIS = new JMenuItem();
667 667
		abrirGT2_PostGIS.setText("PostGIS");
668 668
		abrirGT2_PostGIS.setActionCommand("ADD_GT2_POSTGIS");
669
		abrirGT2_PostGIS.addActionListener(m_acL);		
669
		abrirGT2_PostGIS.addActionListener(m_acL);
670 670
		abrirGT2.add(abrirGT2_PostGIS);
671 671

  
672
		JMenuItem abrirGT2_ArcSDE = new JMenuItem(); 
672
		JMenuItem abrirGT2_ArcSDE = new JMenuItem();
673 673
		abrirGT2_ArcSDE.setText("ArcSDE");
674 674
		abrirGT2_ArcSDE.setActionCommand("ADD_GT2_ARCSDE");
675
		abrirGT2_ArcSDE.addActionListener(m_acL);		
675
		abrirGT2_ArcSDE.addActionListener(m_acL);
676 676
		abrirGT2.add(abrirGT2_ArcSDE);
677
		
677

  
678 678
		fileMenu.add(abrirGT2);
679 679

  
680 680
		fileMenu.addSeparator();
681
	
682
		JMenuItem prueba = new JMenuItem(); 
681

  
682
		JMenuItem prueba = new JMenuItem();
683 683
		prueba.setText("Probar breaks");
684 684
		prueba.setActionCommand("PRUEBA");
685 685
		prueba.addActionListener(m_acL);
......
718 718
         menuBar.add(editMenu);
719 719
        */
720 720
        VistaMenu.setText("Vista");
721
        
722
		JMenuItem mnuOpenLocator = new JMenuItem(); 
721

  
722
		JMenuItem mnuOpenLocator = new JMenuItem();
723 723
		mnuOpenLocator.setText("Abrir localizador");
724 724
		mnuOpenLocator.setActionCommand("OPEN_LOCATOR");
725 725
		mnuOpenLocator.addActionListener(m_acL);
726 726
		VistaMenu.add(mnuOpenLocator);
727
        
727

  
728 728
        menuBar.add(VistaMenu);
729 729

  
730 730
        CapaMenu.setText("Capaa");
......
744 744
            public void actionPerformed(java.awt.event.ActionEvent evt) {
745 745
                JDialog dlg = new JDialog();
746 746
                FPanelAbout panelAbout = new FPanelAbout();
747
                panelAbout.setPreferredSize(panelAbout.getSize());                
747
                panelAbout.setPreferredSize(panelAbout.getSize());
748 748
                dlg.getContentPane().add(panelAbout);
749 749
                dlg.pack();
750 750
                dlg.setResizable(false);
......
752 752
                dlg.show();
753 753
            }
754 754
        });
755
        
755

  
756 756
        helpMenu.add(aboutMenuItem);
757 757
        menuBar.add(helpMenu);
758
        
758

  
759 759
        setJMenuBar(menuBar);
760 760

  
761 761

  
......
792 792
            m_dlgInfo.show();
793 793
        }
794 794
    } */
795
    
795

  
796 796
	public void repaintMap() {
797 797
		m_MapControl.drawMap(false);
798 798
		repaint();
......
845 845
	/* (non-Javadoc)
846 846
	 * @see com.iver.cit.opensig.gui.IView#getViewName()
847 847
	 */
848
	public String getViewName() {		
848
	public String getViewName() {
849 849
		return "Ejemplo de Visor sencillo";
850 850
	}
851 851

  
......
855 855
	 */
856 856
	public void setViewName(String viewName) {
857 857
		m_Name = viewName;
858
		
858

  
859 859
	}
860 860

  
861 861

  
......
864 864
	 */
865 865
	public void coordsChanged(double x, double y) {
866 866
		showCoords(x, y);
867
		
867

  
868 868
	}
869 869

  
870 870

  

Also available in: Unified diff