svn-gvsig-desktop / tags / v1_0_2_Build_914 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / Gt2Geometry.java @ 12200
History | View | Annotate | Download (7.91 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.FLabel; |
61 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
62 |
import com.vividsolutions.jts.geom.Geometry; |
63 |
|
64 |
|
65 |
/**
|
66 |
* Geometr?a.
|
67 |
*
|
68 |
* @author FJP
|
69 |
*/
|
70 |
public class Gt2Geometry implements IGeometry { |
71 |
/**
|
72 |
*
|
73 |
*/
|
74 |
private static final long serialVersionUID = 1587400440363673610L; |
75 |
private FLiteShape shp;
|
76 |
|
77 |
|
78 |
|
79 |
/**
|
80 |
* Crea un nuevo FGeometry.
|
81 |
*
|
82 |
* @param shp DOCUMENT ME!
|
83 |
*/
|
84 |
Gt2Geometry(FLiteShape shp) { |
85 |
this.shp = shp;
|
86 |
} |
87 |
|
88 |
/* (non-Javadoc)
|
89 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
|
90 |
*/
|
91 |
public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) { |
92 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
93 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
94 |
// SHAPE
|
95 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
96 |
transform(vp.getAffineTransform()); |
97 |
|
98 |
switch (shp.getShapeType()) {
|
99 |
case FShape.POINT:
|
100 |
shpPainter.paint(g, shp, symbol.getPointStyle2D(), 0);
|
101 |
|
102 |
break;
|
103 |
|
104 |
case FShape.LINE:
|
105 |
shpPainter.paint(g, shp, symbol.getLineStyle2D(), 0);
|
106 |
|
107 |
break;
|
108 |
|
109 |
case FShape.POLYGON:
|
110 |
shpPainter.paint(g, shp, symbol.getPolygonStyle2D(), 0);
|
111 |
|
112 |
break;
|
113 |
|
114 |
case FShape.TEXT:
|
115 |
shpPainter.paint(g, shp, symbol.getTextStyle2D(), 0);
|
116 |
} |
117 |
} |
118 |
|
119 |
/**
|
120 |
* Dibuja la geometria actual en el graphics que se le pasa como par?metro,
|
121 |
* aplicandole las caracter?sticas del s?mbolo.
|
122 |
*
|
123 |
* @param g Graphics2D.
|
124 |
* @param vp ViewPort.
|
125 |
* @param symbol S?mbolo.
|
126 |
*/
|
127 |
public void draw(Graphics2D g, ViewPort vp, ISymbol symbol) { |
128 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
129 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
130 |
// SHAPE
|
131 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
132 |
transform(vp.getAffineTransform()); |
133 |
symbol.draw(g, vp.getAffineTransform(), shp); |
134 |
// FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), shp, symbol);
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* Aplica la transformaci?n a la geometr?a de la matriz de transformaci?n
|
139 |
* que se pasa como par?metro.
|
140 |
*
|
141 |
* @param at Matriz de transformaci?n.
|
142 |
*/
|
143 |
public void transform(AffineTransform at) { |
144 |
shp.transform(at); |
145 |
} |
146 |
|
147 |
/* (non-Javadoc)
|
148 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
149 |
*/
|
150 |
public boolean intersects(Rectangle2D r) { |
151 |
return shp.intersects(r);
|
152 |
} |
153 |
|
154 |
/* (non-Javadoc)
|
155 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
|
156 |
*/
|
157 |
public Rectangle2D getBounds2D() { |
158 |
return shp.getBounds2D();
|
159 |
} |
160 |
|
161 |
/* (non-Javadoc)
|
162 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
163 |
*/
|
164 |
public Geometry toJTSGeometry() {
|
165 |
return shp.getGeometry();
|
166 |
} |
167 |
|
168 |
/* (non-Javadoc)
|
169 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
170 |
*/
|
171 |
public FLabel[] createLabels(int position, boolean duplicates) { |
172 |
FLabel[] aux = new FLabel[1]; |
173 |
aux[0] = FLabel.createFLabel(shp);
|
174 |
|
175 |
return aux;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
180 |
*/
|
181 |
public int getGeometryType() { |
182 |
return shp.getShapeType();
|
183 |
} |
184 |
|
185 |
/* (non-Javadoc)
|
186 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
187 |
*/
|
188 |
public IGeometry cloneGeometry() {
|
189 |
return new Gt2Geometry(new FLiteShape(shp.getGeometry())); |
190 |
} |
191 |
|
192 |
/* (non-Javadoc)
|
193 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
194 |
*/
|
195 |
public void reProject(ICoordTrans ct) { |
196 |
shp.reProject(ct); |
197 |
} |
198 |
|
199 |
/**
|
200 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
|
201 |
*/
|
202 |
public PathIterator getPathIterator(AffineTransform at) { |
203 |
return (GeneralPathXIterator)shp.getPathIterator(null); |
204 |
} |
205 |
|
206 |
/* (non-Javadoc)
|
207 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
|
208 |
*/
|
209 |
public boolean fastIntersects(double x, double y, double w, double h) { |
210 |
return shp.intersects(x,y,w,h);
|
211 |
} |
212 |
|
213 |
/* (non-Javadoc)
|
214 |
* @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)
|
215 |
*/
|
216 |
public void drawInts(Graphics2D g, ViewPort vp, ISymbol symbol) { |
217 |
draw(g, vp, symbol); |
218 |
} |
219 |
|
220 |
/* (non-Javadoc)
|
221 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB()
|
222 |
*/
|
223 |
public byte[] toWKB() throws IOException { |
224 |
// TODO Auto-generated method stub
|
225 |
return null; |
226 |
} |
227 |
|
228 |
public Handler[] getHandlers(int type) { |
229 |
if (type == IGeometry.SELECTHANDLER)
|
230 |
return shp.getSelectHandlers();
|
231 |
return shp.getStretchingHandlers();
|
232 |
|
233 |
} |
234 |
|
235 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
236 |
return (GeneralPathXIterator)shp.getPathIterator(at, flatness);
|
237 |
} |
238 |
|
239 |
public boolean contains(double x, double y) { |
240 |
return shp.contains(x,y);
|
241 |
} |
242 |
|
243 |
public boolean contains(double x, double y, double w, double h) { |
244 |
return shp.contains(x,y,w,h);
|
245 |
} |
246 |
|
247 |
public boolean intersects(double x, double y, double w, double h) { |
248 |
return shp.intersects(x,y,w,h);
|
249 |
} |
250 |
|
251 |
public Rectangle getBounds() { |
252 |
return shp.getBounds();
|
253 |
} |
254 |
|
255 |
public boolean contains(Point2D p) { |
256 |
return shp.contains(p);
|
257 |
} |
258 |
|
259 |
public boolean contains(Rectangle2D r) { |
260 |
return shp.contains(r);
|
261 |
} |
262 |
|
263 |
public Shape getInternalShape() { |
264 |
return shp;
|
265 |
} |
266 |
|
267 |
} |
268 |
|
269 |
|