Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_899 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / ImageFrame.java @ 10517

History | View | Annotate | Download (3.5 KB)

1 1100 fjp
/* 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 213 fernando
package com.iver.cit.gvsig.fmap.demo;
42
43 1199 fernando
import java.awt.Dimension;
44
import java.awt.image.BufferedImage;
45 306 fjp
import java.io.File;
46
47 1199 fernando
import javax.swing.ImageIcon;
48 306 fjp
import javax.swing.JFrame;
49 1199 fernando
import javax.swing.JLabel;
50 306 fjp
51 1828 fernando
import com.hardcode.driverManager.DriverLoadException;
52 657 fjp
import com.iver.cit.gvsig.fmap.DriverException;
53 6878 cesar
import com.iver.cit.gvsig.fmap.MapContext;
54 1199 fernando
import com.iver.cit.gvsig.fmap.ViewPort;
55 6164 luisw2
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
56 1828 fernando
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
57 573 fjp
import com.iver.cit.gvsig.fmap.layers.FLayer;
58 230 fernando
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
59 286 vcaballero
60
61
/**
62
 * DOCUMENT ME!
63
 *
64
 * @author Vicente Caballero Navarro
65
 */
66 213 fernando
public class ImageFrame extends JFrame {
67 1199 fernando
        private javax.swing.JPanel jContentPane = null;
68
        /**
69
         * This is the default constructor
70
         */
71
        public ImageFrame() {
72
                super();
73
                initialize();
74
        }
75 213 fernando
76 1199 fernando
        /**
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 213 fernando
85 1199 fernando
                FLayer l;
86 230 fernando
87 1199 fernando
                try {
88
                        LayerFactory.setDriversPath(
89 1200 fjp
                                "d:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
90 286 vcaballero
91 1828 fernando
                        l = LayerFactory.createLayer("Provin",
92
                                        (VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
93 1200 fjp
                                        new File("C:/Documents and Settings/fjp/Mis documentos/provin.shp"),
94 6164 luisw2
                                        CRSFactory.getCRS("EPSG:23030"));
95 286 vcaballero
96 6164 luisw2
                        ViewPort vp = new ViewPort(CRSFactory.getCRS("EPSG:23030"));
97 1200 fjp
                        vp.setImageSize(new Dimension(getWidth(), getHeight()));
98 286 vcaballero
99 6878 cesar
                        MapContext mapa = new MapContext(vp);
100 1199 fernando
                        mapa.getLayers().addLayer(l);
101 286 vcaballero
102 1200 fjp
                        BufferedImage img = new BufferedImage(getWidth(), getHeight(),
103 1199 fernando
                                        BufferedImage.TYPE_INT_ARGB);
104 2531 caballero
                        mapa.draw(img, img.createGraphics(),mapa.getScaleView());
105 1199 fernando
                        JLabel lbl = new JLabel(new ImageIcon(img));
106
                        getJContentPane().add(lbl, java.awt.BorderLayout.CENTER);
107
                } catch (DriverException e) {
108
                        e.printStackTrace();
109 1828 fernando
                } catch (DriverLoadException e) {
110
                        e.printStackTrace();
111 1199 fernando
                }
112
113
114
        }
115 286 vcaballero
116 1199 fernando
        /**
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 286 vcaballero
127 1199 fernando
                return jContentPane;
128
        }
129 286 vcaballero
}