root / branches / FMap_SLD / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / DBStrategy.java @ 1755
History | View | Annotate | Download (4.15 KB)
1 |
/*
|
---|---|
2 |
* Created on 08-mar-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.fmap.operations.strategies; |
45 |
|
46 |
import java.awt.Graphics2D; |
47 |
import java.awt.geom.Point2D; |
48 |
import java.awt.geom.Rectangle2D; |
49 |
import java.awt.image.BufferedImage; |
50 |
import java.sql.SQLException; |
51 |
import java.util.BitSet; |
52 |
|
53 |
import org.cresques.cts.ICoordTrans; |
54 |
|
55 |
import com.iver.cit.gvsig.fmap.DriverException; |
56 |
import com.iver.cit.gvsig.fmap.ViewPort; |
57 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
58 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
59 |
import com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator; |
60 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
61 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
62 |
import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter; |
63 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
64 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer; |
65 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
66 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
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 |
public class DBStrategy extends DefaultStrategy { |
75 |
|
76 |
public DBStrategy(FLayer capa) {
|
77 |
super(capa);
|
78 |
} |
79 |
|
80 |
|
81 |
/* (non-Javadoc)
|
82 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
|
83 |
*/
|
84 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) throws DriverException { |
85 |
// Nos aprovechamos del SQL para lanzar la consulta
|
86 |
// teniendo en cuenta el boundingbox que toca.
|
87 |
FLayer capa = getCapa(); |
88 |
VectorialDBAdapter dbAdapter = (VectorialDBAdapter) ((SingleLayer) capa).getSource(); |
89 |
dbAdapter.start(); |
90 |
String strEPSG = viewPort.getProjection().getAbrev().substring(5); |
91 |
GeometryIterator geomIt = dbAdapter.getGeometryIterator(viewPort.getAdjustedExtent(), strEPSG); |
92 |
VectorialLegend l = (VectorialLegend) ((ClassifiableVectorial) capa).getLegend(); |
93 |
try {
|
94 |
while (geomIt.hasNext())
|
95 |
{ |
96 |
if (cancel.isCanceled()) {
|
97 |
dbAdapter.stop(); |
98 |
break;
|
99 |
} |
100 |
|
101 |
IGeometry geom = geomIt.next(); |
102 |
// TODO: CORREGIR LO DE LOS SIMBOLOS
|
103 |
// Es probable que necesitemos generar un Feature
|
104 |
// (Geometr?a + Atributos) para que opere con esa feature
|
105 |
// el gestor de leyendas. A la leyenda le pasar?amos un
|
106 |
// feature, y nos devolver? la colecci?n de s?mbolos a
|
107 |
// aplicar. Similar a lo de "processStylers" de GT2
|
108 |
geom.draw(g,viewPort,l.getDefaultSymbol()); |
109 |
} |
110 |
} catch (SQLException e) { |
111 |
e.printStackTrace(); |
112 |
throw new DriverException(e); |
113 |
} |
114 |
dbAdapter.stop(); |
115 |
|
116 |
} |
117 |
|
118 |
|
119 |
} |