root / tags / v1_0_RELEASE / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrGT2_old.java @ 9167
History | View | Annotate | Download (4.91 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 javax.print.attribute.PrintRequestAttributeSet; |
56 |
|
57 |
import org.geotools.data.FeatureSource; |
58 |
import org.geotools.map.DefaultMapContext; |
59 |
import org.geotools.map.MapContext; |
60 |
import org.geotools.map.MapLayer; |
61 |
import org.geotools.renderer.lite.LiteRenderer2; |
62 |
|
63 |
import com.iver.cit.gvsig.fmap.DriverException; |
64 |
import com.iver.cit.gvsig.fmap.ViewPort; |
65 |
import com.iver.utiles.swing.threads.Cancellable; |
66 |
import com.vividsolutions.jts.geom.Envelope; |
67 |
|
68 |
/**
|
69 |
* @author FJP
|
70 |
*
|
71 |
* TODO To change the template for this generated type comment go to
|
72 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
73 |
*/
|
74 |
// TODO: Cuando no sea para pruebas, habr? que ponerla privada
|
75 |
public class FLyrGT2_old extends FLyrDefault { |
76 |
|
77 |
private MapLayer m_lyrGT2;
|
78 |
private LiteRenderer2 liteR2;
|
79 |
private MapContext mapContextGT2;
|
80 |
|
81 |
public FLyrGT2_old(MapLayer lyrGT2)
|
82 |
{ |
83 |
m_lyrGT2 = lyrGT2; |
84 |
setName(lyrGT2.getTitle()); |
85 |
mapContextGT2 = new DefaultMapContext();
|
86 |
mapContextGT2.addLayer(lyrGT2); |
87 |
liteR2 = new LiteRenderer2(mapContextGT2);
|
88 |
} |
89 |
|
90 |
/* (non-Javadoc)
|
91 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
92 |
*/
|
93 |
public Rectangle2D getFullExtent() throws DriverException { |
94 |
FeatureSource fs = m_lyrGT2.getFeatureSource(); |
95 |
Envelope bounds = null;
|
96 |
try {
|
97 |
bounds = fs.getBounds(); |
98 |
if (bounds == null) |
99 |
{ |
100 |
bounds = fs.getFeatures().getBounds(); |
101 |
} |
102 |
} catch (IOException e) { |
103 |
e.printStackTrace(); |
104 |
} |
105 |
return new Rectangle2D.Double(bounds.getMinX(), bounds.getMinY(), |
106 |
bounds.getWidth(), bounds.getHeight()); |
107 |
} |
108 |
|
109 |
/* (non-Javadoc)
|
110 |
* @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)
|
111 |
*/
|
112 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) throws DriverException { |
113 |
try {
|
114 |
if (isWithinScale(scale)){
|
115 |
// mapExtent = this.context.getAreaOfInterest();
|
116 |
m_lyrGT2.setVisible(isVisible()); |
117 |
Envelope envelope = new Envelope(viewPort.getExtent().getMinX(),
|
118 |
viewPort.getExtent().getMinY(), viewPort.getExtent().getMaxX(), |
119 |
viewPort.getExtent().getMaxY()); |
120 |
mapContextGT2.setAreaOfInterest(envelope); |
121 |
/* FeatureResults results = queryLayer(m_lyrGT2, envelope,
|
122 |
destinationCrs);
|
123 |
|
124 |
// extract the feature type stylers from the style object
|
125 |
// and process them
|
126 |
processStylers(g, results,
|
127 |
m_lyrGT2.getStyle().getFeatureTypeStyles(), viewPort.getAffineTransform(),
|
128 |
mapContextGT2.getCoordinateReferenceSystem()); */
|
129 |
Rectangle r = new Rectangle(viewPort.getImageSize()); |
130 |
long t1 = System.currentTimeMillis(); |
131 |
liteR2.paint(g,r, viewPort.getAffineTransform()); |
132 |
long t2 = System.currentTimeMillis(); |
133 |
System.out.println("Tiempo en pintar capa " + getName() + " de GT2:" + (t2- t1) + " milisegundos"); |
134 |
} |
135 |
} catch (Exception exception) { |
136 |
exception.printStackTrace(); |
137 |
} |
138 |
|
139 |
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable)
|
144 |
*/
|
145 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale, PrintRequestAttributeSet properties) throws DriverException { |
146 |
} |
147 |
|
148 |
} |