Statistics
| Revision:

svn-gvsig-desktop / branches / Fmap_GisPlanet / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / MapImage.java @ 1848

History | View | Annotate | Download (3.47 KB)

1
/*
2
 * Created on 26-ene-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 
21
USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.fmap.demo;
46

    
47
import java.io.File;
48

    
49
import javax.swing.JFrame;
50

    
51
import org.cresques.cts.ProjectionPool;
52

    
53
import com.hardcode.driverManager.DriverLoadException;
54
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.iver.cit.gvsig.fmap.MapControl;
56
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
57
import com.iver.cit.gvsig.fmap.layers.FLayer;
58
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
59
import com.iver.cit.gvsig.fmap.tools.ZoomInListenerImpl;
60
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior;
61
public class MapImage extends JFrame {
62

    
63
        private javax.swing.JPanel jContentPane = null;
64

    
65
        private MapControl newMapControl = null;
66
        /**
67
         * This is the default constructor
68
         */
69
        public MapImage() {
70
                super();
71
                initialize();
72
        }
73
        /**
74
         * This method initializes this
75
         * 
76
         * @return void
77
         */
78
        private void initialize() {
79
                this.setSize(300,200);
80
                this.setContentPane(getJContentPane());
81
                this.setTitle("JFrame");
82
        }
83
        /**
84
         * This method initializes jContentPane
85
         * 
86
         * @return javax.swing.JPanel
87
         */
88
        private javax.swing.JPanel getJContentPane() {
89
                if(jContentPane == null) {
90
                        jContentPane = new javax.swing.JPanel();
91
                        jContentPane.setLayout(new java.awt.BorderLayout());
92
                        jContentPane.add(getNewMapControl(), java.awt.BorderLayout.CENTER);
93
                }
94
                return jContentPane;
95
        }
96
        /**
97
         * This method initializes newMapControl        
98
         *         
99
         * @return com.iver.cit.gvsig.fmap.NewMapControl        
100
         */    
101
        private MapControl getNewMapControl() {
102
                if (newMapControl == null) {
103
                        newMapControl = new MapControl();
104
                        LayerFactory.setDriversPath(
105
                        "C:\\eclipse3\\workspace\\Andami\\gvSIG\\extensiones\\com.iver.cit.gvsig\\drivers");
106

    
107
                        try {
108
                                FLayer l = LayerFactory.createLayer("Vias", 
109
                                        (VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
110
                                        new File("C:/Documents and Settings/fernando/Mis documentos/vias.shp"),
111
                                        ProjectionPool.get("EPSG:23030"));
112
                                newMapControl.getMapContext().getLayers().addLayer(l);
113
                                newMapControl.addMapTool("zoom", new RectangleBehavior(new ZoomInListenerImpl(newMapControl)));
114
                                newMapControl.setTool("zoom");
115
                        } catch (DriverException e) {
116
                                e.printStackTrace();
117
                        } catch (DriverLoadException e) {
118
                                e.printStackTrace();
119
                        }
120

    
121
                        
122
                }
123
                return newMapControl;
124
        }
125
 }