Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / ImageFrame.java @ 2531

History | View | Annotate | Download (3.48 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 org.cresques.cts.ProjectionPool;
52

    
53
import com.hardcode.driverManager.DriverLoadException;
54
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.iver.cit.gvsig.fmap.FMap;
56
import com.iver.cit.gvsig.fmap.ViewPort;
57
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
58
import com.iver.cit.gvsig.fmap.layers.FLayer;
59
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
60

    
61

    
62
/**
63
 * DOCUMENT ME!
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class ImageFrame extends JFrame {
68
        private javax.swing.JPanel jContentPane = null;
69
        /**
70
         * This is the default constructor
71
         */
72
        public ImageFrame() {
73
                super();
74
                initialize();
75
        }
76

    
77
        /**
78
         * This method initializes this
79
         */
80
        private void initialize() {
81
                this.setSize(300, 200);
82
                this.setContentPane(getJContentPane());
83
                this.setTitle("JFrame");
84
                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
85

    
86
                FLayer l;
87

    
88
                try {
89
                        LayerFactory.setDriversPath(
90
                                "d:/java/eclipse30/eclipse/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
91

    
92
                        l = LayerFactory.createLayer("Provin", 
93
                                        (VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
94
                                        new File("C:/Documents and Settings/fjp/Mis documentos/provin.shp"),
95
                                        ProjectionPool.get("EPSG:23030"));
96

    
97
                        ViewPort vp = new ViewPort(ProjectionPool.get("EPSG:23030"));
98
                        vp.setImageSize(new Dimension(getWidth(), getHeight()));
99

    
100
                        FMap mapa = new FMap(vp);
101
                        mapa.getLayers().addLayer(l);
102

    
103
                        BufferedImage img = new BufferedImage(getWidth(), getHeight(),
104
                                        BufferedImage.TYPE_INT_ARGB);
105
                        mapa.draw(img, img.createGraphics(),mapa.getScaleView());
106
                        JLabel lbl = new JLabel(new ImageIcon(img));
107
                        getJContentPane().add(lbl, java.awt.BorderLayout.CENTER);
108
                } catch (DriverException e) {
109
                        e.printStackTrace();
110
                } catch (DriverLoadException e) {
111
                        e.printStackTrace();
112
                }
113
                
114
                
115
        }
116

    
117
        /**
118
         * This method initializes jContentPane
119
         *
120
         * @return javax.swing.JPanel
121
         */
122
        private javax.swing.JPanel getJContentPane() {
123
                if (jContentPane == null) {
124
                        jContentPane = new javax.swing.JPanel();
125
                        jContentPane.setLayout(new java.awt.BorderLayout());
126
                }
127

    
128
                return jContentPane;
129
        }
130
}