root / branches / pilotoDWG / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / ImageFrame.java @ 1786
History | View | Annotate | Download (3.45 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.iver.cit.gvsig.fmap.DriverException; |
56 |
import com.iver.cit.gvsig.fmap.FMap; |
57 |
import com.iver.cit.gvsig.fmap.MapControl; |
58 |
import com.iver.cit.gvsig.fmap.ViewPort; |
59 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
60 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
61 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
62 |
|
63 |
|
64 |
/**
|
65 |
* DOCUMENT ME!
|
66 |
*
|
67 |
* @author Vicente Caballero Navarro
|
68 |
*/
|
69 |
public class ImageFrame extends JFrame { |
70 |
private javax.swing.JPanel jContentPane = null; |
71 |
/**
|
72 |
* This is the default constructor
|
73 |
*/
|
74 |
public ImageFrame() {
|
75 |
super();
|
76 |
initialize(); |
77 |
} |
78 |
|
79 |
/**
|
80 |
* This method initializes this
|
81 |
*/
|
82 |
private void initialize() { |
83 |
this.setSize(300, 200); |
84 |
this.setContentPane(getJContentPane());
|
85 |
this.setTitle("JFrame"); |
86 |
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
87 |
|
88 |
FLayer l; |
89 |
|
90 |
try {
|
91 |
LayerFactory.setDriversPath( |
92 |
"d:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
93 |
|
94 |
l = LayerFactory.createLayer("Provin", "gvSIG shp driver", |
95 |
new File("C:/Documents and Settings/fjp/Mis documentos/provin.shp"), |
96 |
ProjectionPool.get("EPSG:23030"));
|
97 |
|
98 |
ViewPort vp = new ViewPort(ProjectionPool.get("EPSG:23030")); |
99 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
100 |
|
101 |
FMap mapa = new FMap(vp);
|
102 |
mapa.getLayers().addLayer(l); |
103 |
|
104 |
BufferedImage img = new BufferedImage(getWidth(), getHeight(), |
105 |
BufferedImage.TYPE_INT_ARGB);
|
106 |
mapa.draw(img, img.createGraphics()); |
107 |
JLabel lbl = new JLabel(new ImageIcon(img)); |
108 |
getJContentPane().add(lbl, java.awt.BorderLayout.CENTER); |
109 |
} catch (DriverException e) {
|
110 |
e.printStackTrace(); |
111 |
}catch (DriverIOException ex) {
|
112 |
ex.printStackTrace(); |
113 |
} |
114 |
|
115 |
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* This method initializes jContentPane
|
120 |
*
|
121 |
* @return javax.swing.JPanel
|
122 |
*/
|
123 |
private javax.swing.JPanel getJContentPane() {
|
124 |
if (jContentPane == null) { |
125 |
jContentPane = new javax.swing.JPanel();
|
126 |
jContentPane.setLayout(new java.awt.BorderLayout());
|
127 |
} |
128 |
|
129 |
return jContentPane;
|
130 |
} |
131 |
} |