root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / Gt2Geometry.java @ 7000
History | View | Annotate | Download (7.96 KB)
1 |
/*
|
---|---|
2 |
* Created on 20-sep-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.core; |
45 |
|
46 |
|
47 |
import java.awt.Graphics2D; |
48 |
import java.awt.Rectangle; |
49 |
import java.awt.Shape; |
50 |
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 |
import com.iver.cit.gvsig.fmap.ViewPort; |
59 |
import com.iver.cit.gvsig.fmap.core.gt2.FLiteShape; |
60 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
61 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
62 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
63 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
64 |
import com.vividsolutions.jts.geom.Geometry; |
65 |
|
66 |
|
67 |
/**
|
68 |
* Geometr?a.
|
69 |
*
|
70 |
* @author FJP
|
71 |
*/
|
72 |
public class Gt2Geometry implements IGeometry { |
73 |
/**
|
74 |
*
|
75 |
*/
|
76 |
private static final long serialVersionUID = 1587400440363673610L; |
77 |
private FLiteShape shp;
|
78 |
|
79 |
|
80 |
|
81 |
/**
|
82 |
* Crea un nuevo FGeometry.
|
83 |
*
|
84 |
* @param shp DOCUMENT ME!
|
85 |
*/
|
86 |
Gt2Geometry(FLiteShape shp) { |
87 |
this.shp = shp;
|
88 |
} |
89 |
|
90 |
/* (non-Javadoc)
|
91 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
|
92 |
*/
|
93 |
public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) { |
94 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
95 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
96 |
// SHAPE
|
97 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
98 |
transform(vp.getAffineTransform()); |
99 |
|
100 |
switch (shp.getShapeType()) {
|
101 |
case FShape.POINT:
|
102 |
shpPainter.paint(g, shp, symbol.getPointStyle2D(), 0);
|
103 |
|
104 |
break;
|
105 |
|
106 |
case FShape.LINE:
|
107 |
shpPainter.paint(g, shp, symbol.getLineStyle2D(), 0);
|
108 |
|
109 |
break;
|
110 |
|
111 |
case FShape.POLYGON:
|
112 |
shpPainter.paint(g, shp, symbol.getPolygonStyle2D(), 0);
|
113 |
|
114 |
break;
|
115 |
|
116 |
case FShape.TEXT:
|
117 |
shpPainter.paint(g, shp, symbol.getTextStyle2D(), 0);
|
118 |
} |
119 |
} |
120 |
|
121 |
/**
|
122 |
* Dibuja la geometria actual en el graphics que se le pasa como par?metro,
|
123 |
* aplicandole las caracter?sticas del s?mbolo.
|
124 |
*
|
125 |
* @param g Graphics2D.
|
126 |
* @param vp ViewPort.
|
127 |
* @param symbol S?mbolo.
|
128 |
*/
|
129 |
public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) { |
130 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
131 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
132 |
// SHAPE
|
133 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
134 |
transform(vp.getAffineTransform()); |
135 |
FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), shp, symbol); |
136 |
} |
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 |
public void transform(AffineTransform at) { |
145 |
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 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
|
202 |
*/
|
203 |
public PathIterator getPathIterator(AffineTransform at) { |
204 |
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 |
public void drawInts(Graphics2D g, ViewPort vp, FSymbol symbol) { |
218 |
draw(g, vp, symbol); |
219 |
} |
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 |
|
229 |
public Handler[] getHandlers(int type) { |
230 |
if (type == IGeometry.SELECTHANDLER)
|
231 |
return shp.getSelectHandlers();
|
232 |
return shp.getStretchingHandlers();
|
233 |
|
234 |
} |
235 |
|
236 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
237 |
return (GeneralPathXIterator)shp.getPathIterator(at, flatness);
|
238 |
} |
239 |
|
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 |
public Shape getInternalShape() { |
265 |
return shp;
|
266 |
} |
267 |
|
268 |
} |
269 |
|
270 |
|