svn-gvsig-desktop / branches / Fmap_GisPlanet / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / ImageFrame.java @ 1848
History | View | Annotate | Download (3.56 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.demo; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.image.BufferedImage; |
45 |
import java.io.File; |
46 |
|
47 |
import javax.swing.ImageIcon; |
48 |
import javax.swing.JFrame; |
49 |
import javax.swing.JLabel; |
50 |
import javax.swing.JPanel; |
51 |
|
52 |
import org.cresques.cts.IProjection; |
53 |
import org.cresques.cts.ProjectionPool; |
54 |
|
55 |
import com.hardcode.driverManager.DriverLoadException; |
56 |
import com.iver.cit.gvsig.fmap.DriverException; |
57 |
import com.iver.cit.gvsig.fmap.FMap; |
58 |
import com.iver.cit.gvsig.fmap.MapControl; |
59 |
import com.iver.cit.gvsig.fmap.ViewPort; |
60 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
61 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
62 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
63 |
|
64 |
|
65 |
/**
|
66 |
* DOCUMENT ME!
|
67 |
*
|
68 |
* @author Vicente Caballero Navarro
|
69 |
*/
|
70 |
public class ImageFrame extends JFrame { |
71 |
private javax.swing.JPanel jContentPane = null; |
72 |
/**
|
73 |
* This is the default constructor
|
74 |
*/
|
75 |
public ImageFrame() {
|
76 |
super();
|
77 |
initialize(); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* This method initializes this
|
82 |
*/
|
83 |
private void initialize() { |
84 |
this.setSize(300, 200); |
85 |
this.setContentPane(getJContentPane());
|
86 |
this.setTitle("JFrame"); |
87 |
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
88 |
|
89 |
FLayer l; |
90 |
|
91 |
try {
|
92 |
LayerFactory.setDriversPath( |
93 |
"d:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
94 |
|
95 |
l = LayerFactory.createLayer("Provin",
|
96 |
(VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
|
97 |
new File("C:/Documents and Settings/fjp/Mis documentos/provin.shp"), |
98 |
ProjectionPool.get("EPSG:23030"));
|
99 |
|
100 |
ViewPort vp = new ViewPort(ProjectionPool.get("EPSG:23030")); |
101 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
102 |
|
103 |
FMap mapa = new FMap(vp);
|
104 |
mapa.getLayers().addLayer(l); |
105 |
|
106 |
BufferedImage img = new BufferedImage(getWidth(), getHeight(), |
107 |
BufferedImage.TYPE_INT_ARGB);
|
108 |
mapa.draw(img, img.createGraphics()); |
109 |
JLabel lbl = new JLabel(new ImageIcon(img)); |
110 |
getJContentPane().add(lbl, java.awt.BorderLayout.CENTER); |
111 |
} catch (DriverException e) {
|
112 |
e.printStackTrace(); |
113 |
} catch (DriverLoadException e) {
|
114 |
e.printStackTrace(); |
115 |
} |
116 |
|
117 |
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* This method initializes jContentPane
|
122 |
*
|
123 |
* @return javax.swing.JPanel
|
124 |
*/
|
125 |
private javax.swing.JPanel getJContentPane() {
|
126 |
if (jContentPane == null) { |
127 |
jContentPane = new javax.swing.JPanel();
|
128 |
jContentPane.setLayout(new java.awt.BorderLayout());
|
129 |
} |
130 |
|
131 |
return jContentPane;
|
132 |
} |
133 |
} |