root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / Gt2Geometry.java @ 38563
History | View | Annotate | Download (8.29 KB)
1 | 2943 | fjp | /*
|
---|---|---|---|
2 | * Created on 20-sep-2005
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | 4711 | caballero | *
|
6 | 2943 | fjp | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 | 4711 | caballero | *
|
8 | 2943 | fjp | * 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 | 4711 | caballero | *
|
13 | 2943 | fjp | * 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 | 4711 | caballero | *
|
18 | 2943 | fjp | * 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 | 4711 | caballero | *
|
22 | 2943 | fjp | * 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 | 4711 | caballero | *
|
34 | 2943 | fjp | * or
|
35 | 4711 | caballero | *
|
36 | 2943 | fjp | * IVER T.I. S.A
|
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | 4711 | caballero | *
|
41 | 2943 | fjp | * +34 963163400
|
42 | * dac@iver.es
|
||
43 | */
|
||
44 | package com.iver.cit.gvsig.fmap.core; |
||
45 | |||
46 | |||
47 | 4879 | fjp | import java.awt.Graphics2D; |
48 | import java.awt.Rectangle; |
||
49 | 5008 | fjp | import java.awt.Shape; |
50 | 4879 | fjp | import java.awt.geom.AffineTransform; |
51 | import java.awt.geom.PathIterator; |
||
52 | import java.awt.geom.Point2D; |
||
53 | import java.awt.geom.Rectangle2D; |
||
54 | import java.io.IOException; |
||
55 | |||
56 | import org.cresques.cts.ICoordTrans; |
||
57 | |||
58 | 2943 | fjp | import com.iver.cit.gvsig.fmap.ViewPort; |
59 | import com.iver.cit.gvsig.fmap.core.gt2.FLiteShape; |
||
60 | 9641 | jaume | import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
61 | 2943 | fjp | import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
62 | 13953 | jaume | import com.iver.utiles.swing.threads.Cancellable; |
63 | 2943 | fjp | import com.vividsolutions.jts.geom.Geometry; |
64 | |||
65 | |||
66 | /**
|
||
67 | * Geometr?a.
|
||
68 | *
|
||
69 | * @author FJP
|
||
70 | */
|
||
71 | 14205 | jdominguez | public class Gt2Geometry extends AbstractGeometry { |
72 | 4879 | fjp | /**
|
73 | 12467 | jaume | *
|
74 | 4879 | fjp | */
|
75 | private static final long serialVersionUID = 1587400440363673610L; |
||
76 | private FLiteShape shp;
|
||
77 | 2943 | fjp | |
78 | 3904 | fjp | |
79 | 5880 | fjp | |
80 | 2943 | fjp | /**
|
81 | * Crea un nuevo FGeometry.
|
||
82 | *
|
||
83 | * @param shp DOCUMENT ME!
|
||
84 | */
|
||
85 | Gt2Geometry(FLiteShape shp) { |
||
86 | this.shp = shp;
|
||
87 | } |
||
88 | |||
89 | /* (non-Javadoc)
|
||
90 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
|
||
91 | */
|
||
92 | 14205 | jdominguez | // public void draw(Graphics2D g, ViewPort vp, ISymbol symbol) {
|
93 | // // OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
||
94 | // // O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
||
95 | // // SHAPE
|
||
96 | // // Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
||
97 | // transform(vp.getAffineTransform());
|
||
98 | //
|
||
99 | // switch (shp.getShapeType()) {
|
||
100 | // case FShape.POINT:
|
||
101 | // shpPainter.paint(g, shp, symbol.getPointStyle2D(), 0);
|
||
102 | //
|
||
103 | // break;
|
||
104 | //
|
||
105 | // case FShape.LINE:
|
||
106 | // shpPainter.paint(g, shp, symbol.getLineStyle2D(), 0);
|
||
107 | //
|
||
108 | // break;
|
||
109 | //
|
||
110 | // case FShape.POLYGON:
|
||
111 | // shpPainter.paint(g, shp, symbol.getPolygonStyle2D(), 0);
|
||
112 | //
|
||
113 | // break;
|
||
114 | //
|
||
115 | // case FShape.TEXT:
|
||
116 | // shpPainter.paint(g, shp, symbol.getTextStyle2D(), 0);
|
||
117 | // }
|
||
118 | // }
|
||
119 | 2943 | fjp | |
120 | /**
|
||
121 | * Dibuja la geometria actual en el graphics que se le pasa como par?metro,
|
||
122 | * aplicandole las caracter?sticas del s?mbolo.
|
||
123 | *
|
||
124 | * @param g Graphics2D.
|
||
125 | * @param vp ViewPort.
|
||
126 | * @param symbol S?mbolo.
|
||
127 | */
|
||
128 | 13953 | jaume | public void draw(Graphics2D g, ViewPort vp, ISymbol symbol, Cancellable cancel) { |
129 | 2943 | fjp | // OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
130 | 4711 | caballero | // O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
131 | 2943 | fjp | // SHAPE
|
132 | // Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
||
133 | transform(vp.getAffineTransform()); |
||
134 | 13953 | jaume | symbol.draw(g, vp.getAffineTransform(), shp, cancel); |
135 | 7659 | fjp | // FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), shp, symbol);
|
136 | 2943 | fjp | } |
137 | |||
138 | /**
|
||
139 | * Aplica la transformaci?n a la geometr?a de la matriz de transformaci?n
|
||
140 | * que se pasa como par?metro.
|
||
141 | *
|
||
142 | * @param at Matriz de transformaci?n.
|
||
143 | */
|
||
144 | 3904 | fjp | public void transform(AffineTransform at) { |
145 | 2943 | fjp | shp.transform(at); |
146 | } |
||
147 | |||
148 | /* (non-Javadoc)
|
||
149 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
||
150 | */
|
||
151 | public boolean intersects(Rectangle2D r) { |
||
152 | return shp.intersects(r);
|
||
153 | } |
||
154 | |||
155 | /* (non-Javadoc)
|
||
156 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
|
||
157 | */
|
||
158 | public Rectangle2D getBounds2D() { |
||
159 | return shp.getBounds2D();
|
||
160 | } |
||
161 | |||
162 | /* (non-Javadoc)
|
||
163 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
||
164 | */
|
||
165 | public Geometry toJTSGeometry() {
|
||
166 | return shp.getGeometry();
|
||
167 | } |
||
168 | |||
169 | /* (non-Javadoc)
|
||
170 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
||
171 | */
|
||
172 | public FLabel[] createLabels(int position, boolean duplicates) { |
||
173 | FLabel[] aux = new FLabel[1]; |
||
174 | aux[0] = FLabel.createFLabel(shp);
|
||
175 | |||
176 | return aux;
|
||
177 | } |
||
178 | |||
179 | /**
|
||
180 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
||
181 | */
|
||
182 | public int getGeometryType() { |
||
183 | return shp.getShapeType();
|
||
184 | } |
||
185 | |||
186 | /* (non-Javadoc)
|
||
187 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
||
188 | */
|
||
189 | public IGeometry cloneGeometry() {
|
||
190 | return new Gt2Geometry(new FLiteShape(shp.getGeometry())); |
||
191 | } |
||
192 | |||
193 | /* (non-Javadoc)
|
||
194 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
||
195 | */
|
||
196 | public void reProject(ICoordTrans ct) { |
||
197 | shp.reProject(ct); |
||
198 | } |
||
199 | |||
200 | /**
|
||
201 | 4879 | fjp | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
|
202 | 2943 | fjp | */
|
203 | 4879 | fjp | public PathIterator getPathIterator(AffineTransform at) { |
204 | 2943 | fjp | return (GeneralPathXIterator)shp.getPathIterator(null); |
205 | } |
||
206 | |||
207 | /* (non-Javadoc)
|
||
208 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
|
||
209 | */
|
||
210 | public boolean fastIntersects(double x, double y, double w, double h) { |
||
211 | return shp.intersects(x,y,w,h);
|
||
212 | } |
||
213 | |||
214 | /* (non-Javadoc)
|
||
215 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
|
||
216 | */
|
||
217 | 13953 | jaume | public void drawInts(Graphics2D g, ViewPort vp, ISymbol symbol, Cancellable cancel) { |
218 | draw(g, vp, symbol, cancel); |
||
219 | 2943 | fjp | } |
220 | |||
221 | /* (non-Javadoc)
|
||
222 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB()
|
||
223 | */
|
||
224 | public byte[] toWKB() throws IOException { |
||
225 | // TODO Auto-generated method stub
|
||
226 | return null; |
||
227 | } |
||
228 | 3904 | fjp | |
229 | public Handler[] getHandlers(int type) { |
||
230 | if (type == IGeometry.SELECTHANDLER)
|
||
231 | return shp.getSelectHandlers();
|
||
232 | return shp.getStretchingHandlers();
|
||
233 | |||
234 | } |
||
235 | 4799 | fjp | |
236 | 4879 | fjp | public PathIterator getPathIterator(AffineTransform at, double flatness) { |
237 | 4799 | fjp | return (GeneralPathXIterator)shp.getPathIterator(at, flatness);
|
238 | } |
||
239 | 4879 | fjp | |
240 | public boolean contains(double x, double y) { |
||
241 | return shp.contains(x,y);
|
||
242 | } |
||
243 | |||
244 | public boolean contains(double x, double y, double w, double h) { |
||
245 | return shp.contains(x,y,w,h);
|
||
246 | } |
||
247 | |||
248 | public boolean intersects(double x, double y, double w, double h) { |
||
249 | return shp.intersects(x,y,w,h);
|
||
250 | } |
||
251 | |||
252 | public Rectangle getBounds() { |
||
253 | return shp.getBounds();
|
||
254 | } |
||
255 | |||
256 | public boolean contains(Point2D p) { |
||
257 | return shp.contains(p);
|
||
258 | } |
||
259 | |||
260 | public boolean contains(Rectangle2D r) { |
||
261 | return shp.contains(r);
|
||
262 | } |
||
263 | |||
264 | 5008 | fjp | public Shape getInternalShape() { |
265 | return shp;
|
||
266 | } |
||
267 | |||
268 | 18621 | jdominguez | public void drawInts(Graphics2D graphics2D, ViewPort viewPort, |
269 | double dpi, CartographicSupport cartographicSymbol,
|
||
270 | Cancellable cancel) { |
||
271 | // TODO Auto-generated method stub
|
||
272 | 12467 | jaume | throw new Error("Not yet implemented!"); |
273 | 18621 | jdominguez | |
274 | 12467 | jaume | } |
275 | |||
276 | 4717 | caballero | } |
277 | 4711 | caballero |