root / tags / Root_Fmap_GisPlanet / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / DBStrategy.java @ 1826
History | View | Annotate | Download (4.47 KB)
1 | 1691 | fjp | /*
|
---|---|---|---|
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.image.BufferedImage; |
||
48 | 1704 | fjp | import java.sql.SQLException; |
49 | 1825 | fjp | import java.util.BitSet; |
50 | 1691 | fjp | |
51 | 1825 | fjp | import org.cresques.cts.ICoordTrans; |
52 | |||
53 | 1691 | fjp | import com.iver.cit.gvsig.fmap.DriverException; |
54 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
55 | 1772 | fjp | import com.iver.cit.gvsig.fmap.core.IFeature; |
56 | 1691 | fjp | import com.iver.cit.gvsig.fmap.core.IGeometry; |
57 | 1825 | fjp | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
58 | 1772 | fjp | import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
59 | 1825 | fjp | import com.iver.cit.gvsig.fmap.layers.FBitSet; |
60 | 1691 | fjp | import com.iver.cit.gvsig.fmap.layers.FLayer; |
61 | import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter; |
||
62 | 1704 | fjp | import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
63 | 1825 | fjp | import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable; |
64 | 1691 | fjp | import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer; |
65 | import com.iver.cit.gvsig.fmap.operations.Cancellable; |
||
66 | 1704 | fjp | import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
67 | 1691 | fjp | |
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 | 1704 | fjp | // 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 | 1755 | fjp | dbAdapter.start(); |
90 | 1825 | fjp | Selectable selection = (Selectable) getCapa(); |
91 | ICoordTrans ct = getCapa().getCoordTrans(); |
||
92 | FBitSet bitSet = selection.getSelection(); |
||
93 | |||
94 | 1704 | fjp | String strEPSG = viewPort.getProjection().getAbrev().substring(5); |
95 | 1772 | fjp | IFeatureIterator geomIt = dbAdapter.getFeatureIterator(viewPort.getAdjustedExtent(), strEPSG); |
96 | 1704 | fjp | VectorialLegend l = (VectorialLegend) ((ClassifiableVectorial) capa).getLegend(); |
97 | try {
|
||
98 | while (geomIt.hasNext())
|
||
99 | { |
||
100 | if (cancel.isCanceled()) {
|
||
101 | 1755 | fjp | dbAdapter.stop(); |
102 | 1704 | fjp | break;
|
103 | } |
||
104 | 1772 | fjp | IFeature feat = geomIt.next(); |
105 | IGeometry geom = feat.getGeometry(); |
||
106 | 1704 | fjp | // TODO: CORREGIR LO DE LOS SIMBOLOS
|
107 | // Es probable que necesitemos generar un Feature
|
||
108 | // (Geometr?a + Atributos) para que opere con esa feature
|
||
109 | // el gestor de leyendas. A la leyenda le pasar?amos un
|
||
110 | // feature, y nos devolver? la colecci?n de s?mbolos a
|
||
111 | 1825 | fjp | // aplicar. Similar a lo de "processStylers" de GT2
|
112 | // if (bitSet.get(i)) {
|
||
113 | // symbol = FSymbol.getSymbolForSelection(symbol);
|
||
114 | //}
|
||
115 | |||
116 | 1704 | fjp | geom.draw(g,viewPort,l.getDefaultSymbol()); |
117 | } |
||
118 | } catch (SQLException e) { |
||
119 | e.printStackTrace(); |
||
120 | throw new DriverException(e); |
||
121 | } |
||
122 | 1755 | fjp | dbAdapter.stop(); |
123 | 1704 | fjp | |
124 | 1691 | fjp | } |
125 | |||
126 | |||
127 | } |