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