root / tags / v1_0_2_Build_898 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / MapImage.java @ 10513
History | View | Annotate | Download (3.52 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 com.hardcode.driverManager.DriverLoadException; |
52 |
import com.iver.cit.gvsig.fmap.DriverException; |
53 |
import com.iver.cit.gvsig.fmap.MapControl; |
54 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
55 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
56 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
57 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
58 |
import com.iver.cit.gvsig.fmap.tools.ZoomInListenerImpl; |
59 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
60 |
public class MapImage extends JFrame { |
61 |
|
62 |
private javax.swing.JPanel jContentPane = null; |
63 |
|
64 |
private MapControl newMapControl = null; |
65 |
/**
|
66 |
* This is the default constructor
|
67 |
*/
|
68 |
public MapImage() {
|
69 |
super();
|
70 |
initialize(); |
71 |
} |
72 |
/**
|
73 |
* This method initializes this
|
74 |
*
|
75 |
* @return void
|
76 |
*/
|
77 |
private void initialize() { |
78 |
this.setSize(300,200); |
79 |
this.setContentPane(getJContentPane());
|
80 |
this.setTitle("JFrame"); |
81 |
} |
82 |
/**
|
83 |
* This method initializes jContentPane
|
84 |
*
|
85 |
* @return javax.swing.JPanel
|
86 |
*/
|
87 |
private javax.swing.JPanel getJContentPane() {
|
88 |
if(jContentPane == null) { |
89 |
jContentPane = new javax.swing.JPanel();
|
90 |
jContentPane.setLayout(new java.awt.BorderLayout());
|
91 |
jContentPane.add(getNewMapControl(), java.awt.BorderLayout.CENTER); |
92 |
} |
93 |
return jContentPane;
|
94 |
} |
95 |
/**
|
96 |
* This method initializes newMapControl
|
97 |
*
|
98 |
* @return com.iver.cit.gvsig.fmap.NewMapControl
|
99 |
*/
|
100 |
private MapControl getNewMapControl() {
|
101 |
if (newMapControl == null) { |
102 |
newMapControl = new MapControl();
|
103 |
LayerFactory.setDriversPath( |
104 |
"C:\\eclipse3\\workspace\\Andami\\gvSIG\\extensiones\\com.iver.cit.gvsig\\drivers");
|
105 |
|
106 |
try {
|
107 |
FLayer l = LayerFactory.createLayer("Vias",
|
108 |
(VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
|
109 |
new File("C:/Documents and Settings/fernando/Mis documentos/vias.shp"), |
110 |
CRSFactory.getCRS("EPSG:23030"));
|
111 |
newMapControl.getMapContext().getLayers().addLayer(l); |
112 |
newMapControl.addMapTool("zoom", new RectangleBehavior(new ZoomInListenerImpl(newMapControl))); |
113 |
newMapControl.setTool("zoom");
|
114 |
}/* azabala -modificaciones en layerfactory-
|
115 |
catch (DriverException e) {
|
116 |
e.printStackTrace();
|
117 |
} */
|
118 |
catch (DriverLoadException e) {
|
119 |
e.printStackTrace(); |
120 |
} |
121 |
|
122 |
|
123 |
} |
124 |
return newMapControl;
|
125 |
} |
126 |
} |