Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrGT2.java @ 1691

History | View | Annotate | Download (4.75 KB)

1
/*
2
 * Created on 16-dic-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.fmap.layers;
48

    
49
import java.awt.Graphics2D;
50
import java.awt.Rectangle;
51
import java.awt.geom.Rectangle2D;
52
import java.awt.image.BufferedImage;
53
import java.io.IOException;
54

    
55
import org.geotools.data.FeatureSource;
56
import org.geotools.map.DefaultMapContext;
57
import org.geotools.map.MapContext;
58
import org.geotools.map.MapLayer;
59
import org.geotools.renderer.lite.LiteRenderer2;
60

    
61
import com.iver.cit.gvsig.fmap.DriverException;
62
import com.iver.cit.gvsig.fmap.ViewPort;
63
import com.iver.cit.gvsig.fmap.operations.Cancellable;
64
import com.vividsolutions.jts.geom.Envelope;
65

    
66
/**
67
 * @author FJP
68
 *
69
 * TODO To change the template for this generated type comment go to
70
 * Window - Preferences - Java - Code Generation - Code and Comments
71
 */
72
// TODO: Cuando no sea para pruebas, habr? que ponerla privada
73
public class FLyrGT2 extends FLyrDefault {
74
        
75
        private MapLayer m_lyrGT2;
76
        private LiteRenderer2 liteR2; 
77
        private MapContext mapContextGT2;
78
        
79
        public FLyrGT2(MapLayer lyrGT2)
80
        {
81
                m_lyrGT2 = lyrGT2;
82
                setName(lyrGT2.getTitle());
83
                mapContextGT2 = new DefaultMapContext();
84
                mapContextGT2.addLayer(lyrGT2);
85
                liteR2 = new LiteRenderer2(mapContextGT2);
86
        }
87

    
88
        /* (non-Javadoc)
89
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
90
         */
91
        public Rectangle2D getFullExtent() throws DriverException {
92
                FeatureSource fs = m_lyrGT2.getFeatureSource();
93
                Envelope bounds = null;
94
                try {
95
                        bounds = fs.getBounds();
96
                        if (bounds == null)
97
                        {
98
                                bounds = fs.getFeatures().getBounds();
99
                        }
100
                } catch (IOException e) {
101
                        e.printStackTrace();
102
                }
103
                return new Rectangle2D.Double(bounds.getMinX(), bounds.getMinY(), 
104
                                        bounds.getWidth(), bounds.getHeight());
105
        }
106

    
107
        /* (non-Javadoc)
108
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
109
         */
110
        public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) throws DriverException {
111
        try {
112
            // mapExtent = this.context.getAreaOfInterest();            
113
                m_lyrGT2.setVisible(isVisible());
114
                Envelope envelope = new Envelope(viewPort.getExtent().getMinX(),
115
                                viewPort.getExtent().getMinY(), viewPort.getExtent().getMaxX(), 
116
                                viewPort.getExtent().getMaxY());
117
                mapContextGT2.setAreaOfInterest(envelope);
118
            /* FeatureResults results = queryLayer(m_lyrGT2, envelope,
119
                    destinationCrs);
120

121
            // extract the feature type stylers from the style object
122
            // and process them
123
            processStylers(g, results,
124
                            m_lyrGT2.getStyle().getFeatureTypeStyles(), viewPort.getAffineTransform(),
125
                mapContextGT2.getCoordinateReferenceSystem()); */
126
                Rectangle r = new Rectangle(viewPort.getImageSize());
127
                long t1 = System.currentTimeMillis();
128
                liteR2.paint(g,r, viewPort.getAffineTransform());
129
                long t2 = System.currentTimeMillis();
130
                System.out.println("Tiempo en pintar capa " + getName() + " de GT2:" + (t2- t1) + " milisegundos");
131
        } catch (Exception exception) {
132
            exception.printStackTrace();
133
        }
134

    
135
                
136
        }
137

    
138
        /**
139
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
140
         */
141
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel) throws DriverException {
142
        }
143

    
144
}