root / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfFeatureMaker.java @ 185
History | View | Annotate | Download (56.6 KB)
1 | 44 | jmorell | package org.cresques.px.dxf; |
---|---|---|---|
2 | |||
3 | 94 | luisw | import org.cresques.cts.ICoordTrans; |
4 | import org.cresques.cts.IProjection; |
||
5 | 44 | jmorell | import org.cresques.geo.Point3D; |
6 | import org.cresques.geo.Projected; |
||
7 | 91 | luisw | import org.cresques.geo.ViewPortData; |
8 | 44 | jmorell | import org.cresques.io.DxfFile; |
9 | import org.cresques.io.DxfGroup; |
||
10 | import org.cresques.io.DxfGroupVector; |
||
11 | import org.cresques.px.Extent; |
||
12 | 96 | luisw | import org.cresques.px.IObjList; |
13 | 44 | jmorell | import org.cresques.px.gml.Feature; |
14 | 73 | jmorell | import org.cresques.px.gml.FeatureCollection; |
15 | import org.cresques.px.gml.InsPoint; |
||
16 | 44 | jmorell | import org.cresques.px.gml.LineString; |
17 | import org.cresques.px.gml.Point; |
||
18 | import org.cresques.px.gml.Polygon; |
||
19 | import java.util.Iterator; |
||
20 | import java.util.Vector; |
||
21 | import java.awt.Graphics2D; |
||
22 | import java.awt.geom.Point2D; |
||
23 | |||
24 | public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected { |
||
25 | 94 | luisw | IProjection proj = null;
|
26 | 139 | jmorell | //Feature lastFeature = null;
|
27 | 131 | jmorell | Feature lastFeaBordes = null;
|
28 | Feature lastFeaFondos = null;
|
||
29 | 136 | jmorell | boolean isDoubleFeatured = false; |
30 | 96 | luisw | FeatureCollection features = null;
|
31 | 44 | jmorell | double bulge = 0.0; |
32 | double xtruX=0.0, xtruY=0.0, xtruZ=1.0; |
||
33 | int polylineFlag = 0; |
||
34 | Point2D firstPt = new Point2D.Double(); |
||
35 | 179 | jmorell | Point2D ptAnterior = null; |
36 | 57 | jmorell | |
37 | boolean addingToBlock = false; |
||
38 | 73 | jmorell | int iterator = 0; |
39 | FeatureCollection blk = null;
|
||
40 | Vector blkList = null; |
||
41 | 128 | jmorell | DxfTable layers = null;
|
42 | 57 | jmorell | |
43 | 125 | luisw | public DxfFeatureMaker(IProjection proj) {
|
44 | 44 | jmorell | this.proj = proj;
|
45 | 128 | jmorell | layers = new DxfTable();
|
46 | 96 | luisw | features = new FeatureCollection(proj);
|
47 | 73 | jmorell | blkList = new Vector(); |
48 | 44 | jmorell | } |
49 | |||
50 | 57 | jmorell | public void setAddingToBlock(boolean a) { addingToBlock = a; } |
51 | |||
52 | 44 | jmorell | public void createLayer(DxfGroupVector v) throws Exception { |
53 | 128 | jmorell | int color = v.getDataAsInt(62); |
54 | DxfLayer layer = new DxfLayer(v.getDataAsString(2), Math.abs(v.getDataAsInt(62))); |
||
55 | if (color < 0) { |
||
56 | layer.isOff = true;
|
||
57 | } |
||
58 | layer.lType = v.getDataAsString(6);
|
||
59 | layer.setFlags(v.getDataAsInt(70));
|
||
60 | // compruebo flags
|
||
61 | if ((layer.flags & 0x01) == 0x01) { |
||
62 | layer.frozen = true;
|
||
63 | } |
||
64 | if ((layer.flags & 0x02) == 0x02) { |
||
65 | layer.frozen = true;
|
||
66 | } |
||
67 | System.out.println("LAYER color="+layer.getColor()); |
||
68 | |||
69 | layers.add(layer); |
||
70 | 44 | jmorell | } |
71 | |||
72 | public void createPolyline(DxfGroupVector grp) throws Exception { |
||
73 | LineString lineString = new LineString();
|
||
74 | Polygon polygon = new Polygon(); |
||
75 | 139 | jmorell | //Feature feature= new Feature();
|
76 | 131 | jmorell | Feature feaBordes= new Feature();
|
77 | Feature feaFondos= new Feature();
|
||
78 | 44 | jmorell | double x = 0.0, y = 0.0, z = 0.0; |
79 | int flags = 0; |
||
80 | 54 | jmorell | |
81 | 139 | jmorell | //feature.setProp("dxfEntity", "Polyline");
|
82 | 133 | jmorell | feaBordes.setProp("dxfEntity", "Polyline"); |
83 | feaFondos.setProp("dxfEntity", "Polyline"); |
||
84 | 131 | jmorell | if (grp.hasCode(8)) { |
85 | 139 | jmorell | //feature.setProp("layer", grp.getDataAsString(8));
|
86 | 132 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
87 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
88 | 131 | jmorell | } |
89 | 124 | jmorell | if (grp.hasCode(39)) { |
90 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
91 | String string = doub.toString();
|
||
92 | 139 | jmorell | //feature.setProp("thickness", string);
|
93 | 132 | jmorell | feaBordes.setProp("thickness", string);
|
94 | feaFondos.setProp("thickness", string);
|
||
95 | 124 | jmorell | } else {
|
96 | Double doub = new Double(0.0); |
||
97 | 139 | jmorell | //feature.setProp("thickness", doub.toString());
|
98 | 132 | jmorell | feaBordes.setProp("thickness", doub.toString());
|
99 | feaFondos.setProp("thickness", doub.toString());
|
||
100 | 124 | jmorell | } |
101 | 55 | jmorell | if (grp.hasCode(62)) { |
102 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
103 | String string = integer.toString();
|
||
104 | 139 | jmorell | //feature.setProp("color", string);
|
105 | 132 | jmorell | feaBordes.setProp("color", string);
|
106 | feaFondos.setProp("color", string);
|
||
107 | 166 | jmorell | feaBordes.setProp("colorByLayer", "false"); |
108 | feaFondos.setProp("colorByLayer", "false"); |
||
109 | 55 | jmorell | } else {
|
110 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
111 | int clr = layer.colorNumber;
|
||
112 | Integer integer = new Integer(clr); |
||
113 | String string = integer.toString();
|
||
114 | 139 | jmorell | //feature.setProp("color", string);
|
115 | 132 | jmorell | feaBordes.setProp("color", string);
|
116 | feaFondos.setProp("color", string);
|
||
117 | 166 | jmorell | feaBordes.setProp("colorByLayer", "true"); |
118 | feaFondos.setProp("colorByLayer", "true"); |
||
119 | 54 | jmorell | } |
120 | 44 | jmorell | if (grp.hasCode(10)) |
121 | x = grp.getDataAsDouble(10);
|
||
122 | if (grp.hasCode(20)) |
||
123 | y = grp.getDataAsDouble(20);
|
||
124 | 124 | jmorell | if (grp.hasCode(30)) { |
125 | 44 | jmorell | z = grp.getDataAsDouble(30);
|
126 | 124 | jmorell | Double doub = new Double(z); |
127 | String string = doub.toString();
|
||
128 | 139 | jmorell | //feature.setProp("elevation", string);
|
129 | 132 | jmorell | feaBordes.setProp("elevation", string);
|
130 | feaFondos.setProp("elevation", string);
|
||
131 | 124 | jmorell | } |
132 | 44 | jmorell | if (grp.hasCode(70)) |
133 | flags = grp.getDataAsInt(70);
|
||
134 | if (grp.hasCode(210)) |
||
135 | xtruX = grp.getDataAsDouble(210);
|
||
136 | if (grp.hasCode(220)) |
||
137 | xtruY = grp.getDataAsDouble(220);
|
||
138 | if (grp.hasCode(230)) |
||
139 | xtruZ = grp.getDataAsDouble(230);
|
||
140 | 77 | jmorell | if ((flags & 0x01) == 0x00) { |
141 | 139 | jmorell | feaBordes.setGeometry(lineString); |
142 | lastFeaBordes = feaBordes; |
||
143 | 136 | jmorell | isDoubleFeatured = false;
|
144 | 77 | jmorell | } else if ((flags & 0x01) == 0x01) { |
145 | 131 | jmorell | feaBordes.setGeometry(lineString); |
146 | feaFondos.setGeometry(polygon); |
||
147 | lastFeaBordes = feaBordes; |
||
148 | lastFeaFondos = feaFondos; |
||
149 | 136 | jmorell | isDoubleFeatured = true;
|
150 | 44 | jmorell | } else {
|
151 | 77 | jmorell | System.out.println("Detectada una Polyline Flag que no corresponde"); |
152 | System.out.println("a una Polyline corriente, ni a una Closed Polyline"); |
||
153 | 44 | jmorell | } |
154 | } |
||
155 | |||
156 | public void endSeq() throws Exception { |
||
157 | 136 | jmorell | if (isDoubleFeatured) {
|
158 | 131 | jmorell | Feature feaBordes = lastFeaBordes; |
159 | Feature feaFondos = lastFeaFondos; |
||
160 | LineString lineString = (LineString)feaBordes.getGeometry(); |
||
161 | 136 | jmorell | Polygon polygon = (Polygon)feaFondos.getGeometry(); |
162 | 137 | jmorell | lineString.add(firstPt); |
163 | 136 | jmorell | polygon.add(firstPt); |
164 | 131 | jmorell | if (!(bulge==0)) { |
165 | int cnt = lineString.pointNr();
|
||
166 | bulge = 0.0;
|
||
167 | } |
||
168 | lastFeaBordes.setGeometry(lineString); |
||
169 | 136 | jmorell | lastFeaFondos.setGeometry(polygon); |
170 | 131 | jmorell | if (addingToBlock == false) { |
171 | features.add(lastFeaBordes); |
||
172 | features.add(lastFeaFondos); |
||
173 | } else {
|
||
174 | blk.add(lastFeaBordes); |
||
175 | blk.add(lastFeaFondos); |
||
176 | } |
||
177 | lastFeaBordes = null;
|
||
178 | lastFeaFondos = null;
|
||
179 | } else {
|
||
180 | 171 | jmorell | if (lastFeaBordes.getGeometry() instanceof LineString) { |
181 | Feature feaBordes = lastFeaBordes; |
||
182 | LineString lineString = (LineString)feaBordes.getGeometry(); |
||
183 | 182 | jmorell | if (bulge!=0) { |
184 | //if (bulge<0) lineString.remove(0);
|
||
185 | 180 | jmorell | /*int cnt = lineString.pointNr();
|
186 | 179 | jmorell | Vector arc = createArc(ptAnterior, (Point2D)(lineString.get(cnt-1)), bulge);
|
187 | 171 | jmorell | lineString.remove(cnt-1);
|
188 | for (int i=0; i<arc.size(); i++) {
|
||
189 | 179 | jmorell | Point2D ptAux = new Point2D.Double();
|
190 | ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
|
||
191 | lineString.add(ptAux);
|
||
192 | if (lineString.pointNr() == 1) firstPt = ptAux;
|
||
193 | 180 | jmorell | }*/
|
194 | 171 | jmorell | bulge = 0.0;
|
195 | 131 | jmorell | } |
196 | 171 | jmorell | lastFeaBordes.setGeometry(lineString); |
197 | if (addingToBlock == false) { |
||
198 | features.add(lastFeaBordes); |
||
199 | } else {
|
||
200 | blk.add(lastFeaBordes); |
||
201 | } |
||
202 | lastFeaBordes = null;
|
||
203 | 131 | jmorell | } else {
|
204 | 171 | jmorell | // Se trata de un SEQEND despues de un ATTRIB
|
205 | 131 | jmorell | } |
206 | } |
||
207 | 44 | jmorell | xtruX = 0.0;
|
208 | xtruY = 0.0;
|
||
209 | xtruZ = 1.0;
|
||
210 | bulge = 0.0;
|
||
211 | 136 | jmorell | isDoubleFeatured = false;
|
212 | 44 | jmorell | } |
213 | |||
214 | public void addVertex(DxfGroupVector grp) throws Exception { |
||
215 | double x = 0.0, y = 0.0, z = 0.0; |
||
216 | 183 | jmorell | int vFlags = 0; |
217 | 136 | jmorell | if (isDoubleFeatured) {
|
218 | 131 | jmorell | Feature feaBordes = lastFeaBordes; |
219 | Feature feaFondos = lastFeaFondos; |
||
220 | LineString lineString = (LineString)feaBordes.getGeometry(); |
||
221 | 135 | jmorell | Polygon polygon = (Polygon)feaFondos.getGeometry(); |
222 | 131 | jmorell | if (grp.hasCode(8)) |
223 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
224 | 135 | jmorell | feaFondos.setProp("layer", grp.getDataAsString(8)); |
225 | 131 | jmorell | x = grp.getDataAsDouble(10);
|
226 | y = grp.getDataAsDouble(20);
|
||
227 | if (grp.hasCode(30)) { |
||
228 | z = grp.getDataAsDouble(30);
|
||
229 | } |
||
230 | Point3D point_in = new Point3D(x, y, z);
|
||
231 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
232 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
233 | x = point_out.getX(); |
||
234 | y = point_out.getY(); |
||
235 | Point2D pt = proj.createPoint( x, y);
|
||
236 | lineString.add(pt); |
||
237 | 135 | jmorell | polygon.add(pt); |
238 | 131 | jmorell | if (lineString.pointNr() == 1) { |
239 | firstPt = pt; |
||
240 | } |
||
241 | if (bulge == 0.0) { |
||
242 | if (grp.hasCode(42)) { |
||
243 | bulge = grp.getDataAsDouble(42);
|
||
244 | } else { bulge = 0.0; } |
||
245 | } else {
|
||
246 | double bulge_aux = 0.0; |
||
247 | if (grp.hasCode(42)) { |
||
248 | bulge_aux = grp.getDataAsDouble(42);
|
||
249 | } else { bulge_aux = 0.0; } |
||
250 | int cnt = lineString.pointNr();
|
||
251 | Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge); |
||
252 | lineString.remove(cnt-1);
|
||
253 | 135 | jmorell | polygon.remove(cnt-1);
|
254 | 131 | jmorell | for (int i=0; i<arc.size(); i++) { |
255 | pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
||
256 | lineString.add(pt); |
||
257 | 135 | jmorell | polygon.add(pt); |
258 | 131 | jmorell | if (lineString.pointNr() == 1) firstPt = pt; |
259 | } |
||
260 | bulge = bulge_aux; |
||
261 | } |
||
262 | } else {
|
||
263 | 139 | jmorell | Feature feaBordes = lastFeaBordes; |
264 | LineString lineString = (LineString)feaBordes.getGeometry(); |
||
265 | 131 | jmorell | if (grp.hasCode(8)) |
266 | 139 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
267 | 183 | jmorell | if (grp.hasCode(70)) { |
268 | vFlags = grp.getDataAsInt(70);
|
||
269 | } |
||
270 | 131 | jmorell | x = grp.getDataAsDouble(10);
|
271 | y = grp.getDataAsDouble(20);
|
||
272 | if (grp.hasCode(30)) { |
||
273 | z = grp.getDataAsDouble(30);
|
||
274 | } |
||
275 | Point3D point_in = new Point3D(x, y, z);
|
||
276 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
277 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
278 | x = point_out.getX(); |
||
279 | y = point_out.getY(); |
||
280 | 183 | jmorell | if (vFlags != 16) { |
281 | Point2D pt = proj.createPoint( x, y);
|
||
282 | lineString.add(pt); |
||
283 | System.out.println("addVertex: pt = " + pt); |
||
284 | if (lineString.pointNr() == 1) { |
||
285 | firstPt = pt; |
||
286 | System.out.println("addVertex(Primer pto de la lineString, firstPt=pt): firstPt = " + firstPt); |
||
287 | } |
||
288 | if (bulge == 0.0) { |
||
289 | if (grp.hasCode(42)) { |
||
290 | bulge = grp.getDataAsDouble(42);
|
||
291 | } else { bulge = 0.0; } |
||
292 | System.out.println("addVertex: El vertice anterior tenia bulge=0.0"); |
||
293 | } else {
|
||
294 | System.out.println("addVertex: El vertice anterior tiene bulge = " + bulge); |
||
295 | double bulge_aux = 0.0; |
||
296 | if (grp.hasCode(42)) { |
||
297 | bulge_aux = grp.getDataAsDouble(42);
|
||
298 | } else { bulge_aux = 0.0; } |
||
299 | //int cnt = lineString.pointNr();
|
||
300 | System.out.println("addVertex: El vertice anterior tenia bulge. Se va a crear el"); |
||
301 | System.out.println("addVertex: arco del ptAnterior al ptActual."); |
||
302 | System.out.println("addVertex: ptAnterior = " + ptAnterior + ", ptActual = " + pt); |
||
303 | // Borro los puntos inicio y final del arco.
|
||
304 | lineString.remove(lineString.pointNr()-1);
|
||
305 | lineString.remove(lineString.pointNr()-1);
|
||
306 | Vector arc = createArc((Point2D)ptAnterior, pt, bulge); |
||
307 | //lineString.remove(lineString.pointNr()-1);
|
||
308 | if (bulge>0) { |
||
309 | for (int i=0; i<arc.size(); i++) { |
||
310 | Point2D ptAux = new Point2D.Double(); |
||
311 | ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
||
312 | lineString.add(ptAux); |
||
313 | if (lineString.pointNr() == 1) firstPt = ptAux; |
||
314 | } |
||
315 | } else {
|
||
316 | for (int i=arc.size()-1; i>=0; i--) { |
||
317 | Point2D ptAux = new Point2D.Double(); |
||
318 | ptAux = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY()); |
||
319 | lineString.add(ptAux); |
||
320 | if (lineString.pointNr() == 1) firstPt = ptAux; |
||
321 | } |
||
322 | 182 | jmorell | } |
323 | 183 | jmorell | bulge = bulge_aux; |
324 | 131 | jmorell | } |
325 | 183 | jmorell | ptAnterior = pt; |
326 | 131 | jmorell | } |
327 | } |
||
328 | 44 | jmorell | } |
329 | |||
330 | public void createLwPolyline(DxfGroupVector grp) throws Exception { |
||
331 | 124 | jmorell | double x = 0.0, y = 0.0; |
332 | double elev = 0.0; |
||
333 | 44 | jmorell | DxfGroup g = null;
|
334 | 142 | jmorell | LineString lineString = new LineString();
|
335 | Polygon polygon = new Polygon(); |
||
336 | //Geometry geometria;
|
||
337 | //Feature feature= new Feature();
|
||
338 | Feature feaBordes= new Feature();
|
||
339 | Feature feaFondos= new Feature();
|
||
340 | 44 | jmorell | int flags = 0; |
341 | |||
342 | 142 | jmorell | //feature.setProp("dxfEntity", "LwPolyline");
|
343 | feaBordes.setProp("dxfEntity", "LwPolyline"); |
||
344 | feaFondos.setProp("dxfEntity", "LwPolyline"); |
||
345 | 55 | jmorell | if (grp.hasCode(8)) |
346 | 142 | jmorell | //feature.setProp("layer", grp.getDataAsString(8));
|
347 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
348 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
349 | 124 | jmorell | if (grp.hasCode(38)) { |
350 | elev = grp.getDataAsDouble(38);
|
||
351 | Double doub = new Double(elev); |
||
352 | String string = doub.toString();
|
||
353 | 142 | jmorell | //feature.setProp("elevation", string);
|
354 | feaBordes.setProp("elevation", string);
|
||
355 | feaFondos.setProp("elevation", string);
|
||
356 | 124 | jmorell | } else {
|
357 | Double doub = new Double(0.0); |
||
358 | 142 | jmorell | //feature.setProp("elevation", doub.toString());
|
359 | feaBordes.setProp("elevation", doub.toString());
|
||
360 | feaFondos.setProp("elevation", doub.toString());
|
||
361 | 124 | jmorell | } |
362 | if (grp.hasCode(39)) { |
||
363 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
364 | String string = doub.toString();
|
||
365 | 142 | jmorell | //feature.setProp("thickness", string);
|
366 | feaBordes.setProp("thickness", string);
|
||
367 | feaFondos.setProp("thickness", string);
|
||
368 | 124 | jmorell | } else {
|
369 | Double doub = new Double(0.0); |
||
370 | 142 | jmorell | //feature.setProp("thickness", doub.toString());
|
371 | feaBordes.setProp("thickness", doub.toString());
|
||
372 | feaFondos.setProp("thickness", doub.toString());
|
||
373 | 124 | jmorell | } |
374 | 55 | jmorell | if (grp.hasCode(62)) { |
375 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
376 | String string = integer.toString();
|
||
377 | 142 | jmorell | //feature.setProp("color", string);
|
378 | feaBordes.setProp("color", string);
|
||
379 | feaFondos.setProp("color", string);
|
||
380 | 166 | jmorell | feaBordes.setProp("colorByLayer", "false"); |
381 | feaFondos.setProp("colorByLayer", "false"); |
||
382 | 55 | jmorell | } else {
|
383 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
384 | int clr = layer.colorNumber;
|
||
385 | Integer integer = new Integer(clr); |
||
386 | String string = integer.toString();
|
||
387 | 142 | jmorell | //feature.setProp("color", string);
|
388 | feaBordes.setProp("color", string);
|
||
389 | feaFondos.setProp("color", string);
|
||
390 | 166 | jmorell | feaBordes.setProp("colorByLayer", "true"); |
391 | feaFondos.setProp("colorByLayer", "true"); |
||
392 | 54 | jmorell | } |
393 | 107 | jmorell | if (grp.hasCode(70)) |
394 | flags = grp.getDataAsInt(70);
|
||
395 | if ((flags & 0x01) == 0x01) { |
||
396 | 142 | jmorell | //geometria = new Polygon();
|
397 | feaBordes.setGeometry(lineString); |
||
398 | feaFondos.setGeometry(polygon); |
||
399 | isDoubleFeatured = true;
|
||
400 | 107 | jmorell | } else {
|
401 | 142 | jmorell | //geometria = new LineString();
|
402 | feaBordes.setGeometry(lineString); |
||
403 | isDoubleFeatured = false;
|
||
404 | 107 | jmorell | } |
405 | 106 | jmorell | |
406 | 107 | jmorell | int j = 0; |
407 | double firstX = 0.0; |
||
408 | double firstY = 0.0; |
||
409 | 44 | jmorell | for (int i=0; i<grp.size(); i++) { |
410 | g = (DxfGroup) grp.get(i); |
||
411 | 106 | jmorell | if (g.getCode() == 10) { |
412 | 107 | jmorell | j++; |
413 | 82 | jmorell | x = ((Double) g.getData()).doubleValue();
|
414 | 106 | jmorell | } else if (g.getCode() == 20) { |
415 | 82 | jmorell | y = ((Double) g.getData()).doubleValue();
|
416 | 107 | jmorell | //if (y <= 1.0) throw new Exception("Y == "+y);
|
417 | //lineString.add( proj.createPoint( x, y ) );
|
||
418 | //polygon.add( proj.createPoint( x, y ) );
|
||
419 | 142 | jmorell | //geometria.add( proj.createPoint( x, y ) );
|
420 | lineString.add( proj.createPoint( x, y ) ); |
||
421 | if (isDoubleFeatured) polygon.add( proj.createPoint( x, y ) );
|
||
422 | 107 | jmorell | if (j == 1) { |
423 | firstX = x; |
||
424 | 106 | jmorell | firstY = y; |
425 | 107 | jmorell | } |
426 | 44 | jmorell | x = 0.0; y = 0.0; |
427 | } |
||
428 | } |
||
429 | 142 | jmorell | if (isDoubleFeatured) {
|
430 | //geometria.add(proj.createPoint(firstX, firstY));
|
||
431 | lineString.add(proj.createPoint(firstX, firstY)); |
||
432 | polygon.add(proj.createPoint(firstX, firstY)); |
||
433 | 44 | jmorell | } |
434 | 107 | jmorell | |
435 | 142 | jmorell | lastFeaBordes = feaBordes; |
436 | if (isDoubleFeatured) lastFeaFondos = feaFondos;
|
||
437 | 74 | jmorell | //features.add(feature);
|
438 | if (addingToBlock == false) { |
||
439 | 142 | jmorell | features.add(feaBordes); |
440 | if (isDoubleFeatured) features.add(feaFondos);
|
||
441 | 74 | jmorell | } else {
|
442 | 102 | jmorell | //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
443 | 142 | jmorell | blk.add(feaBordes); |
444 | if (isDoubleFeatured) blk.add(feaFondos);
|
||
445 | 74 | jmorell | } |
446 | 142 | jmorell | isDoubleFeatured = false;
|
447 | 44 | jmorell | } |
448 | |||
449 | public void createLine(DxfGroupVector grp) throws Exception { |
||
450 | double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0; |
||
451 | 124 | jmorell | double elev = 0.0; |
452 | 44 | jmorell | DxfGroup g = null;
|
453 | Point2D pt1 = null, pt2 = null; |
||
454 | LineString lineString = new LineString();
|
||
455 | Feature feature = new Feature();
|
||
456 | |||
457 | 124 | jmorell | feature.setProp("dxfEntity", "Line"); |
458 | 55 | jmorell | if (grp.hasCode(8)) |
459 | 54 | jmorell | feature.setProp("layer", grp.getDataAsString(8)); |
460 | 124 | jmorell | if (grp.hasCode(39)) { |
461 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
462 | String string = doub.toString();
|
||
463 | feature.setProp("thickness", string);
|
||
464 | } else {
|
||
465 | Double doub = new Double(0.0); |
||
466 | feature.setProp("thickness", doub.toString());
|
||
467 | } |
||
468 | 55 | jmorell | if (grp.hasCode(62)) { |
469 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
470 | String string = integer.toString();
|
||
471 | feature.setProp("color", string);
|
||
472 | 166 | jmorell | feature.setProp("colorByLayer", "false"); |
473 | 55 | jmorell | } else {
|
474 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
475 | int clr = layer.colorNumber;
|
||
476 | Integer integer = new Integer(clr); |
||
477 | String string = integer.toString();
|
||
478 | feature.setProp("color", string);
|
||
479 | 166 | jmorell | feature.setProp("colorByLayer", "true"); |
480 | 54 | jmorell | } |
481 | 44 | jmorell | x = grp.getDataAsDouble(10);
|
482 | y = grp.getDataAsDouble(20);
|
||
483 | 124 | jmorell | if (grp.hasCode(30)) { |
484 | z1 = grp.getDataAsDouble(30);
|
||
485 | elev = z1; |
||
486 | Double doub = new Double(elev); |
||
487 | String string = doub.toString();
|
||
488 | feature.setProp("elevation", string);
|
||
489 | } |
||
490 | 44 | jmorell | pt1 = proj.createPoint(x, y); |
491 | x = grp.getDataAsDouble(11);
|
||
492 | y = grp.getDataAsDouble(21);
|
||
493 | 124 | jmorell | if (grp.hasCode(31)) { |
494 | z2 = grp.getDataAsDouble(31);
|
||
495 | } |
||
496 | 44 | jmorell | pt2 = proj.createPoint(x, y); |
497 | if (grp.hasCode(210)) |
||
498 | xtruX = grp.getDataAsDouble(210);
|
||
499 | if (grp.hasCode(220)) |
||
500 | 73 | jmorell | xtruY = grp.getDataAsDouble(220);
|
501 | 44 | jmorell | if (grp.hasCode(230)) |
502 | 73 | jmorell | xtruZ = grp.getDataAsDouble(230);
|
503 | 44 | jmorell | Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
|
504 | Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
|
||
505 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
506 | Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
||
507 | Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
||
508 | pt1.setLocation(point_out1); |
||
509 | pt2.setLocation(point_out2); |
||
510 | lineString.add(pt1); |
||
511 | lineString.add(pt2); |
||
512 | 57 | jmorell | |
513 | 44 | jmorell | feature.setGeometry(lineString); |
514 | 74 | jmorell | //features.add(feature);
|
515 | if (addingToBlock == false) { |
||
516 | 102 | jmorell | //System.out.println("createLine(): A?adimos una linea a la lista de entidades");
|
517 | 74 | jmorell | features.add(feature); |
518 | } else {
|
||
519 | 102 | jmorell | //System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
|
520 | 74 | jmorell | blk.add(feature); |
521 | } |
||
522 | 44 | jmorell | } |
523 | |||
524 | /* (non-Javadoc)
|
||
525 | * @see org.cresques.io.DxfFile.EntityFactory#createText(org.cresques.io.DxfGroupVector)
|
||
526 | */
|
||
527 | public void createText(DxfGroupVector grp) throws Exception { |
||
528 | double x = 0.0, y = 0.0, z = 0.0, h= 0.0, rot= 0.0; |
||
529 | DxfGroup g = null;
|
||
530 | Point2D pt1 = null, pt2 = null; |
||
531 | Point2D pt = null; |
||
532 | Point point = new Point(); |
||
533 | 122 | jmorell | |
534 | point.isText = true;
|
||
535 | |||
536 | 44 | jmorell | Feature feature = new Feature();
|
537 | |||
538 | 124 | jmorell | feature.setProp("dxfEntity", "Text"); |
539 | 55 | jmorell | if (grp.hasCode(8)) |
540 | 54 | jmorell | feature.setProp("layer", grp.getDataAsString(8)); |
541 | 124 | jmorell | if (grp.hasCode(39)) { |
542 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
543 | String string = doub.toString();
|
||
544 | feature.setProp("thickness", string);
|
||
545 | } else {
|
||
546 | Double doub = new Double(0.0); |
||
547 | feature.setProp("thickness", doub.toString());
|
||
548 | } |
||
549 | 55 | jmorell | if (grp.hasCode(62)) { |
550 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
551 | String string = integer.toString();
|
||
552 | feature.setProp("color", string);
|
||
553 | 166 | jmorell | feature.setProp("colorByLayer", "false"); |
554 | 55 | jmorell | } else {
|
555 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
556 | int clr = layer.colorNumber;
|
||
557 | Integer integer = new Integer(clr); |
||
558 | String string = integer.toString();
|
||
559 | feature.setProp("color", string);
|
||
560 | 166 | jmorell | feature.setProp("colorByLayer", "true"); |
561 | 54 | jmorell | } |
562 | 55 | jmorell | if (grp.hasCode(1)) { |
563 | 116 | jmorell | String strAux1 = grp.getDataAsString(1); |
564 | strAux1 = DxfConvTexts.ConvertText(strAux1); |
||
565 | feature.setProp("text", strAux1);
|
||
566 | 55 | jmorell | } else {
|
567 | 122 | jmorell | feature.setProp("text", "No Text Code"); |
568 | 55 | jmorell | } |
569 | 108 | jmorell | if (grp.hasCode(40)) { |
570 | Double heightD = new Double(grp.getDataAsDouble(40)); |
||
571 | String heightS = heightD.toString();
|
||
572 | feature.setProp("textHeight", heightS);
|
||
573 | } else {
|
||
574 | feature.setProp("textHeight", "20.0"); |
||
575 | } |
||
576 | if (grp.hasCode(50)) { |
||
577 | Double rotD = new Double(grp.getDataAsDouble(50)); |
||
578 | String rotS = rotD.toString();
|
||
579 | feature.setProp("textRotation", rotS);
|
||
580 | 177 | jmorell | //System.out.println("rotS = " + rotS);
|
581 | 108 | jmorell | } else {
|
582 | feature.setProp("textRotation", "0.0"); |
||
583 | } |
||
584 | 44 | jmorell | x = grp.getDataAsDouble(10);
|
585 | y = grp.getDataAsDouble(20);
|
||
586 | 124 | jmorell | if (grp.hasCode(30)){ |
587 | z = grp.getDataAsDouble(30);
|
||
588 | Double doub = new Double(z); |
||
589 | String string = doub.toString();
|
||
590 | feature.setProp("elevation", string);
|
||
591 | } |
||
592 | 44 | jmorell | if (grp.hasCode(210)) |
593 | xtruX = grp.getDataAsDouble(210);
|
||
594 | if (grp.hasCode(220)) |
||
595 | xtruY = grp.getDataAsDouble(220);
|
||
596 | if (grp.hasCode(230)) |
||
597 | xtruZ = grp.getDataAsDouble(230);
|
||
598 | Point3D point_in = new Point3D(x, y, z);
|
||
599 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
600 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
601 | x = point_out.getX(); |
||
602 | y = point_out.getY(); |
||
603 | //entity.setPt1(proj.createPoint(x, y));
|
||
604 | //point.add(proj.createPoint(x, y));
|
||
605 | //lineText.add(proj.createPoint(x, y));
|
||
606 | /*if (grp.hasCode(11)) {
|
||
607 | x = grp.getDataAsDouble(11);
|
||
608 | y = grp.getDataAsDouble(21);
|
||
609 | //entity.setPt2(proj.createPoint(x, y));
|
||
610 | lineText.add(proj.createPoint(x, y));
|
||
611 | }
|
||
612 | entity.h = grp.getDataAsDouble(40);
|
||
613 | if (grp.hasCode(50))
|
||
614 | entity.rot = grp.getDataAsDouble(50);
|
||
615 | if (grp.hasCode(62))
|
||
616 | entity.dxfColor = grp.getDataAsInt(62);
|
||
617 | if (grp.hasCode(72))
|
||
618 | entity.align = grp.getDataAsInt(72);*/
|
||
619 | point.add(new Point2D.Double(x, y)); |
||
620 | feature.setGeometry(point); |
||
621 | //entities.add(entity);
|
||
622 | 74 | jmorell | //features.add(feature);
|
623 | if (addingToBlock == false) { |
||
624 | features.add(feature); |
||
625 | } else {
|
||
626 | 102 | jmorell | //System.out.println("createText(): A?adimos un text al bloque " + iterator);
|
627 | 74 | jmorell | blk.add(feature); |
628 | } |
||
629 | 44 | jmorell | } |
630 | |||
631 | public void createPoint(DxfGroupVector grp) throws Exception { |
||
632 | double x = 0.0, y = 0.0, z = 0.0; |
||
633 | DxfGroup g = null;
|
||
634 | Point2D pt = null; |
||
635 | Point point = new Point(); |
||
636 | Feature feature = new Feature();
|
||
637 | |||
638 | 124 | jmorell | feature.setProp("dxfEntity", "Point"); |
639 | 55 | jmorell | if (grp.hasCode(8)) |
640 | 54 | jmorell | feature.setProp("layer", grp.getDataAsString(8)); |
641 | 124 | jmorell | if (grp.hasCode(39)) { |
642 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
643 | String string = doub.toString();
|
||
644 | feature.setProp("thickness", string);
|
||
645 | } else {
|
||
646 | Double doub = new Double(0.0); |
||
647 | feature.setProp("thickness", doub.toString());
|
||
648 | } |
||
649 | 55 | jmorell | if (grp.hasCode(62)) { |
650 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
651 | String string = integer.toString();
|
||
652 | feature.setProp("color", string);
|
||
653 | 166 | jmorell | feature.setProp("colorByLayer", "false"); |
654 | 55 | jmorell | } else {
|
655 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
656 | int clr = layer.colorNumber;
|
||
657 | Integer integer = new Integer(clr); |
||
658 | String string = integer.toString();
|
||
659 | feature.setProp("color", string);
|
||
660 | 166 | jmorell | feature.setProp("colorByLayer", "true"); |
661 | 54 | jmorell | } |
662 | 44 | jmorell | x = grp.getDataAsDouble(10);
|
663 | y = grp.getDataAsDouble(20);
|
||
664 | 124 | jmorell | if (grp.hasCode(30)) { |
665 | z = grp.getDataAsDouble(30);
|
||
666 | Double doub = new Double(z); |
||
667 | String string = doub.toString();
|
||
668 | feature.setProp("elevation", string);
|
||
669 | } |
||
670 | 44 | jmorell | if (grp.hasCode(210)) |
671 | xtruX = grp.getDataAsDouble(210);
|
||
672 | if (grp.hasCode(220)) |
||
673 | xtruY = grp.getDataAsDouble(220);
|
||
674 | if (grp.hasCode(230)) |
||
675 | xtruZ = grp.getDataAsDouble(230);
|
||
676 | Point3D point_in = new Point3D(x, y, z);
|
||
677 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
678 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
679 | x = point_out.getX(); |
||
680 | y = point_out.getY(); |
||
681 | point.add(new Point2D.Double(x, y)); |
||
682 | 57 | jmorell | |
683 | 44 | jmorell | feature.setGeometry(point); |
684 | 74 | jmorell | //features.add(feature);
|
685 | if (addingToBlock == false) { |
||
686 | features.add(feature); |
||
687 | } else {
|
||
688 | 102 | jmorell | //System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
|
689 | 74 | jmorell | blk.add(feature); |
690 | } |
||
691 | 44 | jmorell | } |
692 | |||
693 | public void createCircle(DxfGroupVector grp) throws Exception { |
||
694 | double x = 0.0, y = 0.0, z = 0.0; |
||
695 | double r = 0.0; |
||
696 | DxfGroup g = null;
|
||
697 | 142 | jmorell | LineString lineString = new LineString();
|
698 | 44 | jmorell | Polygon polygon = new Polygon(); |
699 | 142 | jmorell | Feature feaBordes = new Feature();
|
700 | Feature feaFondos = new Feature();
|
||
701 | 44 | jmorell | |
702 | 142 | jmorell | feaBordes.setProp("dxfEntity", "Circle"); |
703 | feaFondos.setProp("dxfEntity", "Circle"); |
||
704 | 55 | jmorell | if (grp.hasCode(8)) |
705 | 142 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
706 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
707 | 124 | jmorell | if (grp.hasCode(39)) { |
708 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
709 | String string = doub.toString();
|
||
710 | 142 | jmorell | feaBordes.setProp("thickness", string);
|
711 | feaFondos.setProp("thickness", string);
|
||
712 | 124 | jmorell | } else {
|
713 | Double doub = new Double(0.0); |
||
714 | 142 | jmorell | feaBordes.setProp("thickness", doub.toString());
|
715 | feaFondos.setProp("thickness", doub.toString());
|
||
716 | 124 | jmorell | } |
717 | 55 | jmorell | if (grp.hasCode(62)) { |
718 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
719 | String string = integer.toString();
|
||
720 | 142 | jmorell | feaBordes.setProp("color", string);
|
721 | feaFondos.setProp("color", string);
|
||
722 | 166 | jmorell | feaBordes.setProp("colorByLayer", "false"); |
723 | feaFondos.setProp("colorByLayer", "false"); |
||
724 | 55 | jmorell | } else {
|
725 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
726 | int clr = layer.colorNumber;
|
||
727 | Integer integer = new Integer(clr); |
||
728 | String string = integer.toString();
|
||
729 | 142 | jmorell | feaBordes.setProp("color", string);
|
730 | feaFondos.setProp("color", string);
|
||
731 | 166 | jmorell | feaBordes.setProp("colorByLayer", "true"); |
732 | feaFondos.setProp("colorByLayer", "true"); |
||
733 | 54 | jmorell | } |
734 | 44 | jmorell | x = grp.getDataAsDouble(10);
|
735 | y = grp.getDataAsDouble(20);
|
||
736 | 124 | jmorell | if (grp.hasCode(30)) { |
737 | z = grp.getDataAsDouble(30);
|
||
738 | Double doub = new Double(z); |
||
739 | String string = doub.toString();
|
||
740 | 142 | jmorell | feaBordes.setProp("elevation", string);
|
741 | feaFondos.setProp("elevation", string);
|
||
742 | 124 | jmorell | } |
743 | 44 | jmorell | if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
744 | if (grp.hasCode(210)) |
||
745 | xtruX = grp.getDataAsDouble(210);
|
||
746 | if (grp.hasCode(220)) |
||
747 | 73 | jmorell | xtruY = grp.getDataAsDouble(220);
|
748 | 44 | jmorell | if (grp.hasCode(230)) |
749 | 73 | jmorell | xtruZ = grp.getDataAsDouble(230);
|
750 | 44 | jmorell | Point3D point_in = new Point3D(x, y, z);
|
751 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
752 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
753 | x = point_out.getX(); |
||
754 | y = point_out.getY(); |
||
755 | |||
756 | Point2D center = proj.createPoint( x, y);
|
||
757 | Point2D[] pts = new Point2D[360]; |
||
758 | int angulo = 0; |
||
759 | for (angulo=0; angulo<360; angulo++) { |
||
760 | pts[angulo] = new Point2D.Double(center.getX(), center.getY()); |
||
761 | pts[angulo].setLocation(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
||
762 | if (pts.length == 1) { |
||
763 | firstPt = pts[angulo]; |
||
764 | } |
||
765 | } |
||
766 | for (int i=0; i<pts.length; i++) { |
||
767 | 142 | jmorell | lineString.add(pts[i]); |
768 | 44 | jmorell | polygon.add(pts[i]); |
769 | } |
||
770 | 57 | jmorell | |
771 | 142 | jmorell | feaBordes.setGeometry(lineString); |
772 | feaFondos.setGeometry(polygon); |
||
773 | 74 | jmorell | //features.add(feature);
|
774 | if (addingToBlock == false) { |
||
775 | 102 | jmorell | //System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
|
776 | 142 | jmorell | features.add(feaBordes); |
777 | features.add(feaFondos); |
||
778 | 74 | jmorell | } else {
|
779 | 102 | jmorell | //System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
|
780 | 142 | jmorell | blk.add(feaBordes); |
781 | blk.add(feaFondos); |
||
782 | 74 | jmorell | } |
783 | 44 | jmorell | } |
784 | |||
785 | public void createArc(DxfGroupVector grp) throws Exception { |
||
786 | double x = 0.0, y = 0.0, z = 0.0; |
||
787 | double r = 0.0, empieza = 0.0, acaba = 0.0; |
||
788 | DxfGroup g = null;
|
||
789 | LineString lineString = new LineString();
|
||
790 | Feature feature = new Feature();
|
||
791 | |||
792 | 124 | jmorell | feature.setProp("dxfEntity", "Arc"); |
793 | 55 | jmorell | if (grp.hasCode(8)) |
794 | 54 | jmorell | feature.setProp("layer", grp.getDataAsString(8)); |
795 | 124 | jmorell | if (grp.hasCode(39)) { |
796 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
797 | String string = doub.toString();
|
||
798 | feature.setProp("thickness", string);
|
||
799 | } else {
|
||
800 | Double doub = new Double(0.0); |
||
801 | feature.setProp("thickness", doub.toString());
|
||
802 | } |
||
803 | 55 | jmorell | if (grp.hasCode(62)) { |
804 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
805 | String string = integer.toString();
|
||
806 | feature.setProp("color", string);
|
||
807 | 166 | jmorell | feature.setProp("colorByLayer", "false"); |
808 | 55 | jmorell | } else {
|
809 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
810 | int clr = layer.colorNumber;
|
||
811 | Integer integer = new Integer(clr); |
||
812 | String string = integer.toString();
|
||
813 | feature.setProp("color", string);
|
||
814 | 166 | jmorell | feature.setProp("colorByLayer", "true"); |
815 | 54 | jmorell | } |
816 | 44 | jmorell | x = grp.getDataAsDouble(10);
|
817 | y = grp.getDataAsDouble(20);
|
||
818 | 124 | jmorell | if (grp.hasCode(30)) { |
819 | z = grp.getDataAsDouble(30);
|
||
820 | Double doub = new Double(z); |
||
821 | String string = doub.toString();
|
||
822 | feature.setProp("elevation", string);
|
||
823 | } |
||
824 | 44 | jmorell | if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
825 | if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50); |
||
826 | if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51); |
||
827 | if (grp.hasCode(210)) |
||
828 | xtruX = grp.getDataAsDouble(210);
|
||
829 | if (grp.hasCode(220)) |
||
830 | 73 | jmorell | xtruY = grp.getDataAsDouble(220);
|
831 | 44 | jmorell | if (grp.hasCode(230)) |
832 | 73 | jmorell | xtruZ = grp.getDataAsDouble(230);
|
833 | 44 | jmorell | Point3D point_in = new Point3D(x, y, z);
|
834 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
835 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
836 | x = point_out.getX(); |
||
837 | y = point_out.getY(); |
||
838 | |||
839 | Point2D center = proj.createPoint( x, y);
|
||
840 | 102 | jmorell | //System.out.println("empieza = " + empieza + ", acaba = " + acaba);
|
841 | 44 | jmorell | int iempieza = (int)empieza; |
842 | int iacaba = (int)acaba; |
||
843 | 102 | jmorell | //System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
|
844 | 44 | jmorell | double angulo = 0; |
845 | Point2D[] pts = null; |
||
846 | if (empieza <= acaba) {
|
||
847 | pts = new Point2D[(iacaba-iempieza)+2]; |
||
848 | angulo = empieza; |
||
849 | pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
850 | for (int i=1; i<=(iacaba-iempieza)+1; i++) { |
||
851 | angulo = (double)(iempieza+i);
|
||
852 | pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
853 | } |
||
854 | angulo = acaba; |
||
855 | pts[(iacaba-iempieza)+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
856 | } else {
|
||
857 | pts = new Point2D[(360-iempieza)+iacaba+2]; |
||
858 | angulo = empieza; |
||
859 | 102 | jmorell | //System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
|
860 | 44 | jmorell | pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
861 | for (int i=1; i<=(360-iempieza); i++) { |
||
862 | angulo = (double)(iempieza+i);
|
||
863 | pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
864 | } |
||
865 | for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) { |
||
866 | angulo = (double)(i-(360-iempieza)); |
||
867 | pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
868 | } |
||
869 | angulo = acaba; |
||
870 | pts[(360-iempieza)+iacaba+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
||
871 | } |
||
872 | for (int i=0; i<pts.length; i++) { |
||
873 | lineString.add(pts[i]); |
||
874 | } |
||
875 | 57 | jmorell | |
876 | 44 | jmorell | feature.setGeometry(lineString); |
877 | 74 | jmorell | //features.add(feature);
|
878 | if (addingToBlock == false) { |
||
879 | features.add(feature); |
||
880 | } else {
|
||
881 | 102 | jmorell | //System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
|
882 | 74 | jmorell | blk.add(feature); |
883 | } |
||
884 | 44 | jmorell | } |
885 | |||
886 | public void createInsert(DxfGroupVector grp) throws Exception { |
||
887 | double x = 0.0, y = 0.0, z = 0.0; |
||
888 | DxfGroup g = null;
|
||
889 | 73 | jmorell | Point2D pt = new Point2D.Double(0.0, 0.0); |
890 | Point2D scaleFactor = new Point2D.Double(1.0, 1.0); |
||
891 | double rotAngle = 0.0; |
||
892 | 44 | jmorell | String blockName = ""; |
893 | |||
894 | 73 | jmorell | InsPoint insert = new InsPoint();
|
895 | 44 | jmorell | Feature feature = new Feature();
|
896 | 74 | jmorell | Point secondGeom = new Point(); |
897 | Feature secondFeat = new Feature();
|
||
898 | 44 | jmorell | |
899 | 124 | jmorell | feature.setProp("dxfEntity", "Insert"); |
900 | 128 | jmorell | secondFeat.setProp("dxfEntity", "Insert"); |
901 | 73 | jmorell | if (grp.hasCode(2)) { |
902 | 44 | jmorell | blockName = grp.getDataAsString(2);
|
903 | 74 | jmorell | //feature.setProp("blockName", blockName);
|
904 | insert.setBlockName(blockName); |
||
905 | 73 | jmorell | } |
906 | 74 | jmorell | if (grp.hasCode(8)) { |
907 | 54 | jmorell | feature.setProp("layer", grp.getDataAsString(8)); |
908 | 74 | jmorell | secondFeat.setProp("layer", grp.getDataAsString(8)); |
909 | } |
||
910 | 127 | jmorell | |
911 | Double doub = new Double(0.0); |
||
912 | secondFeat.setProp("thickness", doub.toString());
|
||
913 | |||
914 | 55 | jmorell | if (grp.hasCode(62)) { |
915 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
916 | String string = integer.toString();
|
||
917 | feature.setProp("color", string);
|
||
918 | 74 | jmorell | secondFeat.setProp("color", string);
|
919 | 166 | jmorell | feature.setProp("colorByLayer", "false"); |
920 | secondFeat.setProp("colorByLayer", "false"); |
||
921 | 55 | jmorell | } else {
|
922 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
923 | int clr = layer.colorNumber;
|
||
924 | Integer integer = new Integer(clr); |
||
925 | String string = integer.toString();
|
||
926 | feature.setProp("color", string);
|
||
927 | secondFeat.setProp("color", string);
|
||
928 | 166 | jmorell | feature.setProp("colorByLayer", "true"); |
929 | secondFeat.setProp("colorByLayer", "true"); |
||
930 | 54 | jmorell | } |
931 | 73 | jmorell | if (grp.hasCode(10)) x = grp.getDataAsDouble(10); |
932 | if (grp.hasCode(20)) y = grp.getDataAsDouble(20); |
||
933 | 124 | jmorell | if (grp.hasCode(30)) { |
934 | z = grp.getDataAsDouble(30);
|
||
935 | 127 | jmorell | Double doubz = new Double(z); |
936 | String string = doubz.toString();
|
||
937 | 124 | jmorell | feature.setProp("elevation", string);
|
938 | 127 | jmorell | secondFeat.setProp("elevation", string);
|
939 | 124 | jmorell | } |
940 | 73 | jmorell | if (grp.hasCode(41)) { |
941 | scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
|
||
942 | 74 | jmorell | //Double scaleFactorX = new Double(scaleFactor.getX());
|
943 | //feature.setProp("scaleFactorX", scaleFactorX.toString());
|
||
944 | insert.setScaleFactor(scaleFactor); |
||
945 | 73 | jmorell | } else {
|
946 | 74 | jmorell | //Double scaleFactorX = new Double(scaleFactor.getX());
|
947 | //feature.setProp("scaleFactorX", scaleFactorX.toString());
|
||
948 | insert.setScaleFactor(scaleFactor); |
||
949 | 73 | jmorell | } |
950 | if (grp.hasCode(42)) { |
||
951 | scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
|
||
952 | 74 | jmorell | //Double scaleFactorY = new Double(scaleFactor.getY());
|
953 | //feature.setProp("scaleFactorY", scaleFactorY.toString());
|
||
954 | insert.setScaleFactor(scaleFactor); |
||
955 | 73 | jmorell | } else {
|
956 | 74 | jmorell | //Double scaleFactorY = new Double(scaleFactor.getY());
|
957 | //feature.setProp("scaleFactorY", scaleFactorY.toString());
|
||
958 | insert.setScaleFactor(scaleFactor); |
||
959 | 73 | jmorell | } |
960 | 75 | jmorell | if (grp.hasCode(43)) { |
961 | 73 | jmorell | // TODO La coordenada z
|
962 | 75 | jmorell | } |
963 | if (grp.hasCode(50)) { |
||
964 | 73 | jmorell | rotAngle = grp.getDataAsDouble(50);
|
965 | 74 | jmorell | //Double objRotAngle = new Double(rotAngle);
|
966 | //feature.setProp("rotAngle", objRotAngle.toString());
|
||
967 | insert.setRotAngle(rotAngle); |
||
968 | 73 | jmorell | } |
969 | 44 | jmorell | if (grp.hasCode(210)) |
970 | xtruX = grp.getDataAsDouble(210);
|
||
971 | if (grp.hasCode(220)) |
||
972 | xtruY = grp.getDataAsDouble(220);
|
||
973 | if (grp.hasCode(230)) |
||
974 | xtruZ = grp.getDataAsDouble(230);
|
||
975 | Point3D point_in = new Point3D(x, y, z);
|
||
976 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
977 | Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
||
978 | x = point_out.getX(); |
||
979 | y = point_out.getY(); |
||
980 | |||
981 | 73 | jmorell | insert.setBlkList(blkList); |
982 | 44 | jmorell | |
983 | 73 | jmorell | insert.encuentraBloque(blockName); |
984 | 44 | jmorell | |
985 | 74 | jmorell | insert.add(new Point2D.Double(x, y)); |
986 | secondGeom.add(new Point2D.Double(x, y)); |
||
987 | 73 | jmorell | |
988 | 74 | jmorell | feature.setGeometry(insert); |
989 | secondFeat.setGeometry(secondGeom); |
||
990 | |||
991 | 168 | jmorell | if (insert.getBlockFound()==true) gestionaInsert(feature); |
992 | 73 | jmorell | |
993 | if (addingToBlock == false) { |
||
994 | 74 | jmorell | features.add(secondFeat); |
995 | 44 | jmorell | } |
996 | 168 | jmorell | // 040929: Modificado para a?adir el insert aunque no se haya encontrado
|
997 | // el bloque.
|
||
998 | if (addingToBlock == true/* && insert.getBlockFound() == true*/) { |
||
999 | 102 | jmorell | //System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
|
1000 | 73 | jmorell | blk.add(feature); |
1001 | } |
||
1002 | 44 | jmorell | } |
1003 | |||
1004 | 82 | jmorell | public void createSolid(DxfGroupVector grp) throws Exception { |
1005 | double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0, z3 = 0.0, z4 = 0.0; |
||
1006 | DxfGroup g = null;
|
||
1007 | //Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
|
||
1008 | Point2D[] pts = new Point2D[4]; |
||
1009 | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1010 | 44 | jmorell | |
1011 | 142 | jmorell | LineString lineString = new LineString();
|
1012 | 82 | jmorell | Polygon polygon = new Polygon(); |
1013 | 142 | jmorell | Feature feaBordes = new Feature();
|
1014 | Feature feaFondos = new Feature();
|
||
1015 | 124 | jmorell | double elev = 0; |
1016 | 82 | jmorell | |
1017 | 142 | jmorell | feaBordes.setProp("dxfEntity", "Solid"); |
1018 | feaFondos.setProp("dxfEntity", "Solid"); |
||
1019 | 128 | jmorell | if (grp.hasCode(8)) |
1020 | 142 | jmorell | feaBordes.setProp("layer", grp.getDataAsString(8)); |
1021 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
1022 | 82 | jmorell | x = grp.getDataAsDouble(10);
|
1023 | y = grp.getDataAsDouble(20);
|
||
1024 | 124 | jmorell | if (grp.hasCode(30)) { |
1025 | z1 = grp.getDataAsDouble(30);
|
||
1026 | elev = z1; |
||
1027 | Double doub = new Double(elev); |
||
1028 | String string = doub.toString();
|
||
1029 | 142 | jmorell | feaBordes.setProp("elevation", string);
|
1030 | feaFondos.setProp("elevation", string);
|
||
1031 | 124 | jmorell | } |
1032 | 82 | jmorell | pts[0] = proj.createPoint(x, y);
|
1033 | x = grp.getDataAsDouble(11);
|
||
1034 | y = grp.getDataAsDouble(21);
|
||
1035 | if (grp.hasCode(31)) z2 = grp.getDataAsDouble(31); |
||
1036 | pts[1] = proj.createPoint(x, y);
|
||
1037 | x = grp.getDataAsDouble(12);
|
||
1038 | y = grp.getDataAsDouble(22);
|
||
1039 | if (grp.hasCode(32)) z3 = grp.getDataAsDouble(32); |
||
1040 | pts[2] = proj.createPoint(x, y);
|
||
1041 | x = grp.getDataAsDouble(13);
|
||
1042 | y = grp.getDataAsDouble(23);
|
||
1043 | if (grp.hasCode(33)) z2 = grp.getDataAsDouble(33); |
||
1044 | pts[3] = proj.createPoint(x, y);
|
||
1045 | 124 | jmorell | if (grp.hasCode(39)) { |
1046 | Double doub = new Double(grp.getDataAsDouble(39)); |
||
1047 | String string = doub.toString();
|
||
1048 | 142 | jmorell | feaBordes.setProp("thickness", string);
|
1049 | feaFondos.setProp("thickness", string);
|
||
1050 | 124 | jmorell | } else {
|
1051 | Double doub = new Double(0.0); |
||
1052 | 142 | jmorell | feaBordes.setProp("thickness", doub.toString());
|
1053 | feaFondos.setProp("thickness", doub.toString());
|
||
1054 | 124 | jmorell | } |
1055 | 82 | jmorell | if (grp.hasCode(62)) { |
1056 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1057 | String string = integer.toString();
|
||
1058 | 142 | jmorell | feaBordes.setProp("color", string);
|
1059 | feaFondos.setProp("color", string);
|
||
1060 | 166 | jmorell | feaBordes.setProp("colorByLayer", "false"); |
1061 | feaFondos.setProp("colorByLayer", "false"); |
||
1062 | 82 | jmorell | } else {
|
1063 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1064 | int clr = layer.colorNumber;
|
||
1065 | Integer integer = new Integer(clr); |
||
1066 | String string = integer.toString();
|
||
1067 | 142 | jmorell | feaBordes.setProp("color", string);
|
1068 | feaFondos.setProp("color", string);
|
||
1069 | 166 | jmorell | feaBordes.setProp("colorByLayer", "true"); |
1070 | feaFondos.setProp("colorByLayer", "true"); |
||
1071 | 82 | jmorell | } |
1072 | if (grp.hasCode(210)) |
||
1073 | xtruX = grp.getDataAsDouble(210);
|
||
1074 | if (grp.hasCode(220)) |
||
1075 | 162 | luisw | xtruY = grp.getDataAsDouble(220);
|
1076 | 82 | jmorell | if (grp.hasCode(230)) |
1077 | 162 | luisw | xtruZ = grp.getDataAsDouble(230);
|
1078 | 82 | jmorell | Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1); |
1079 | Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2); |
||
1080 | Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3); |
||
1081 | Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4); |
||
1082 | Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
|
||
1083 | Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
|
||
1084 | Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
|
||
1085 | Point2D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru);
|
||
1086 | Point2D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru);
|
||
1087 | pts[0].setLocation(point_out1);
|
||
1088 | pts[1].setLocation(point_out2);
|
||
1089 | pts[2].setLocation(point_out3);
|
||
1090 | pts[3].setLocation(point_out4);
|
||
1091 | |||
1092 | 106 | jmorell | Point2D aux = pts[2]; |
1093 | pts[2] = pts[3]; |
||
1094 | pts[3] = aux;
|
||
1095 | |||
1096 | 82 | jmorell | for (int i=0; i<pts.length; i++) { |
1097 | 142 | jmorell | lineString.add(pts[i]); |
1098 | 82 | jmorell | polygon.add(pts[i]); |
1099 | } |
||
1100 | |||
1101 | 106 | jmorell | // Para cerrarlos.
|
1102 | 142 | jmorell | lineString.add(pts[0]);
|
1103 | 106 | jmorell | polygon.add(pts[0]);
|
1104 | |||
1105 | 142 | jmorell | feaBordes.setGeometry(lineString); |
1106 | feaFondos.setGeometry(polygon); |
||
1107 | 82 | jmorell | //features.add(feature);
|
1108 | if (addingToBlock == false) { |
||
1109 | 102 | jmorell | //System.out.println("createSolid(): A?ade un solid a la lista de entidades");
|
1110 | 142 | jmorell | features.add(feaBordes); |
1111 | features.add(feaFondos); |
||
1112 | 82 | jmorell | } else {
|
1113 | 102 | jmorell | //System.out.println("createSolid(): A?adimos un circulo al bloque " + iterator);
|
1114 | 142 | jmorell | blk.add(feaBordes); |
1115 | blk.add(feaFondos); |
||
1116 | 82 | jmorell | } |
1117 | 44 | jmorell | } |
1118 | |||
1119 | 171 | jmorell | public void createSpline(DxfGroupVector grp) throws Exception { |
1120 | 185 | jmorell | double x = 0.0, y = 0.0, z = 0.0, elev = 0.0; |
1121 | 183 | jmorell | //double elev = 0.0;
|
1122 | DxfGroup g = null;
|
||
1123 | LineString lineString = new LineString();
|
||
1124 | Polygon polygon = new Polygon(); |
||
1125 | //Geometry geometria;
|
||
1126 | //Feature feature= new Feature();
|
||
1127 | Feature feaBordes= new Feature();
|
||
1128 | Feature feaFondos= new Feature();
|
||
1129 | int flags = 0; |
||
1130 | |||
1131 | //feature.setProp("dxfEntity", "LwPolyline");
|
||
1132 | feaBordes.setProp("dxfEntity", "Spline"); |
||
1133 | feaFondos.setProp("dxfEntity", "Spline"); |
||
1134 | if (grp.hasCode(8)) { |
||
1135 | //feature.setProp("layer", grp.getDataAsString(8));
|
||
1136 | feaBordes.setProp("layer", grp.getDataAsString(8)); |
||
1137 | feaFondos.setProp("layer", grp.getDataAsString(8)); |
||
1138 | } |
||
1139 | /*if (grp.hasCode(38)) {
|
||
1140 | elev = grp.getDataAsDouble(38);
|
||
1141 | Double doub = new Double(elev);
|
||
1142 | String string = doub.toString();
|
||
1143 | //feature.setProp("elevation", string);
|
||
1144 | feaBordes.setProp("elevation", string);
|
||
1145 | feaFondos.setProp("elevation", string);
|
||
1146 | } else {
|
||
1147 | Double doub = new Double(0.0);
|
||
1148 | //feature.setProp("elevation", doub.toString());
|
||
1149 | feaBordes.setProp("elevation", doub.toString());
|
||
1150 | feaFondos.setProp("elevation", doub.toString());
|
||
1151 | }*/
|
||
1152 | 185 | jmorell | if (grp.hasCode(39)) { |
1153 | 183 | jmorell | Double doub = new Double(grp.getDataAsDouble(39)); |
1154 | String string = doub.toString();
|
||
1155 | //feature.setProp("thickness", string);
|
||
1156 | feaBordes.setProp("thickness", string);
|
||
1157 | feaFondos.setProp("thickness", string);
|
||
1158 | } else {
|
||
1159 | Double doub = new Double(0.0); |
||
1160 | //feature.setProp("thickness", doub.toString());
|
||
1161 | feaBordes.setProp("thickness", doub.toString());
|
||
1162 | feaFondos.setProp("thickness", doub.toString());
|
||
1163 | 185 | jmorell | } |
1164 | 183 | jmorell | if (grp.hasCode(62)) { |
1165 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1166 | String string = integer.toString();
|
||
1167 | //feature.setProp("color", string);
|
||
1168 | feaBordes.setProp("color", string);
|
||
1169 | feaFondos.setProp("color", string);
|
||
1170 | feaBordes.setProp("colorByLayer", "false"); |
||
1171 | feaFondos.setProp("colorByLayer", "false"); |
||
1172 | } else {
|
||
1173 | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
||
1174 | int clr = layer.colorNumber;
|
||
1175 | Integer integer = new Integer(clr); |
||
1176 | String string = integer.toString();
|
||
1177 | //feature.setProp("color", string);
|
||
1178 | feaBordes.setProp("color", string);
|
||
1179 | feaFondos.setProp("color", string);
|
||
1180 | feaBordes.setProp("colorByLayer", "true"); |
||
1181 | feaFondos.setProp("colorByLayer", "true"); |
||
1182 | } |
||
1183 | if (grp.hasCode(70)) |
||
1184 | flags = grp.getDataAsInt(70);
|
||
1185 | if ((flags & 0x01) == 0x01) { |
||
1186 | //geometria = new Polygon();
|
||
1187 | feaBordes.setGeometry(lineString); |
||
1188 | feaFondos.setGeometry(polygon); |
||
1189 | isDoubleFeatured = true;
|
||
1190 | } else {
|
||
1191 | //geometria = new LineString();
|
||
1192 | feaBordes.setGeometry(lineString); |
||
1193 | isDoubleFeatured = false;
|
||
1194 | } |
||
1195 | |||
1196 | int j = 0; |
||
1197 | double firstX = 0.0; |
||
1198 | double firstY = 0.0; |
||
1199 | double firstZ = 0.0; |
||
1200 | for (int i=0; i<grp.size(); i++) { |
||
1201 | g = (DxfGroup) grp.get(i); |
||
1202 | if (g.getCode() == 10) { |
||
1203 | j++; |
||
1204 | x = ((Double) g.getData()).doubleValue();
|
||
1205 | } else if (g.getCode() == 20) { |
||
1206 | y = ((Double) g.getData()).doubleValue();
|
||
1207 | //if (y <= 1.0) throw new Exception("Y == "+y);
|
||
1208 | //lineString.add( proj.createPoint( x, y ) );
|
||
1209 | //polygon.add( proj.createPoint( x, y ) );
|
||
1210 | //geometria.add( proj.createPoint( x, y ) );
|
||
1211 | } else if (g.getCode() == 30) { |
||
1212 | z = ((Double) g.getData()).doubleValue();
|
||
1213 | // OJO --> proj.createPoint no acepta ptos con 3 coordenadas,
|
||
1214 | // ni gvSIG en esta fase de desarrollo.
|
||
1215 | lineString.add(proj.createPoint(x, y)); |
||
1216 | if (isDoubleFeatured) polygon.add( proj.createPoint( x, y ) );
|
||
1217 | if (j == 1) { |
||
1218 | firstX = x; |
||
1219 | firstY = y; |
||
1220 | firstZ = z; |
||
1221 | } |
||
1222 | 185 | jmorell | elev = z; |
1223 | 183 | jmorell | x = 0.0; y = 0.0; z = 0.0; |
1224 | } |
||
1225 | } |
||
1226 | 185 | jmorell | |
1227 | Double doub = new Double(elev); |
||
1228 | String string = doub.toString();
|
||
1229 | //feature.setProp("elevation", string);
|
||
1230 | feaBordes.setProp("elevation", string);
|
||
1231 | feaFondos.setProp("elevation", string);
|
||
1232 | |||
1233 | 183 | jmorell | if (isDoubleFeatured) {
|
1234 | //geometria.add(proj.createPoint(firstX, firstY));
|
||
1235 | lineString.add(proj.createPoint(firstX, firstY)); |
||
1236 | polygon.add(proj.createPoint(firstX, firstY)); |
||
1237 | } |
||
1238 | |||
1239 | lastFeaBordes = feaBordes; |
||
1240 | if (isDoubleFeatured) lastFeaFondos = feaFondos;
|
||
1241 | //features.add(feature);
|
||
1242 | if (addingToBlock == false) { |
||
1243 | features.add(feaBordes); |
||
1244 | if (isDoubleFeatured) features.add(feaFondos);
|
||
1245 | } else {
|
||
1246 | //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
||
1247 | blk.add(feaBordes); |
||
1248 | if (isDoubleFeatured) blk.add(feaFondos);
|
||
1249 | } |
||
1250 | isDoubleFeatured = false;
|
||
1251 | |||
1252 | 171 | jmorell | /*double x = 0.0, y = 0.0, elev=0.0;
|
1253 | DxfGroup g = null;
|
||
1254 | |||
1255 | DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1256 | DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
|
||
1257 | for (int i=0; i<grp.size(); i++) {
|
||
1258 | g = (DxfGroup) grp.get(i);
|
||
1259 | if (g.getCode() == 10)
|
||
1260 | x = ((Double) g.getData()).doubleValue();
|
||
1261 | else if (g.getCode() == 20) {
|
||
1262 | y = ((Double) g.getData()).doubleValue();
|
||
1263 | //if (y <= 1.0) throw new Exception("Y == "+y);
|
||
1264 | entity.add( proj.createPoint( x, y ) );
|
||
1265 | x = 0.0; y = 0.0;
|
||
1266 | }
|
||
1267 | }
|
||
1268 | if (grp.hasCode(62)) {
|
||
1269 | entity.dxfColor = grp.getDataAsInt(62);
|
||
1270 | } else {
|
||
1271 | //entity.dxfColor = 0;
|
||
1272 | }
|
||
1273 | if (grp.hasCode(70))
|
||
1274 | entity.flags = grp.getDataAsInt(70);
|
||
1275 | if ((entity.flags & 0x01) == 0x01) {
|
||
1276 | entity.closed = true;
|
||
1277 | }
|
||
1278 | if (addingToBlock == false) {
|
||
1279 | entities.add(entity);
|
||
1280 | } else {
|
||
1281 | //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
|
||
1282 | blk.add(entity);
|
||
1283 | }*/
|
||
1284 | } |
||
1285 | public void createAttdef(DxfGroupVector grp) throws Exception { |
||
1286 | } |
||
1287 | public void createAttrib(DxfGroupVector grp) throws Exception { |
||
1288 | Feature attFeature = new Feature();
|
||
1289 | lastFeaBordes = attFeature; |
||
1290 | lastFeaBordes.setGeometry(new Point()); |
||
1291 | } |
||
1292 | |||
1293 | 73 | jmorell | public void createBlock(DxfGroupVector grp) throws Exception { |
1294 | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
||
1295 | blk = new FeatureCollection(proj);
|
||
1296 | 44 | jmorell | |
1297 | 73 | jmorell | Point2D basePoint = new Point2D.Double(); |
1298 | String blockName = ""; |
||
1299 | 102 | jmorell | //System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
|
1300 | 73 | jmorell | |
1301 | addingToBlock = true;
|
||
1302 | 102 | jmorell | //System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
|
1303 | 73 | jmorell | blkList.add(iterator, blk); |
1304 | |||
1305 | 102 | jmorell | //System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
|
1306 | 73 | jmorell | |
1307 | 74 | jmorell | if (grp.hasCode(8)) |
1308 | blk.setProp("layer", grp.getDataAsString(8)); |
||
1309 | if (grp.hasCode(62)) { |
||
1310 | Integer integer = new Integer(grp.getDataAsInt(62)); |
||
1311 | String string = integer.toString();
|
||
1312 | blk.setProp("color", string);
|
||
1313 | 166 | jmorell | blk.setProp("colorByLayer", "false"); |
1314 | 74 | jmorell | } else {
|
1315 | 128 | jmorell | DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
|
1316 | int clr = layer.colorNumber;
|
||
1317 | Integer integer = new Integer(clr); |
||
1318 | String string = integer.toString();
|
||
1319 | blk.setProp("color", string);
|
||
1320 | 166 | jmorell | blk.setProp("colorByLayer", "true"); |
1321 | 74 | jmorell | } |
1322 | |||
1323 | 73 | jmorell | if (grp.hasCode(1)) { |
1324 | blockName = grp.getDataAsString(1);
|
||
1325 | //blk.setBlkName(blockName);
|
||
1326 | blk.setProp("blockName", blockName);
|
||
1327 | } |
||
1328 | if (grp.hasCode(2)) { |
||
1329 | blockName = grp.getDataAsString(2);
|
||
1330 | //blk.setBlkName(blockName);
|
||
1331 | blk.setProp("blockName", blockName);
|
||
1332 | } |
||
1333 | 177 | jmorell | // 041001: Anulado porque provoca que no se visualizen bloques de la
|
1334 | // leyenda en m54643.dxf.
|
||
1335 | /*if (grp.hasCode(3)) {
|
||
1336 | 73 | jmorell | blockName = grp.getDataAsString(3);
|
1337 | //blk.setBlkName(blockName);
|
||
1338 | blk.setProp("blockName", blockName);
|
||
1339 | 177 | jmorell | }*/
|
1340 | 73 | jmorell | if (grp.hasCode(10)) { |
1341 | //basePoint.setLocation(grp.getDataAsDouble(10), basePoint.getY());
|
||
1342 | //blk.setBPoint(basePoint);
|
||
1343 | Double basePointX = new Double(grp.getDataAsDouble(10)); |
||
1344 | blk.setProp("basePointX", basePointX.toString());
|
||
1345 | } |
||
1346 | if (grp.hasCode(20)) { |
||
1347 | //basePoint.setLocation(basePoint.getX(), grp.getDataAsDouble(20));
|
||
1348 | //blk.setBPoint(basePoint);
|
||
1349 | Double basePointY = new Double(grp.getDataAsDouble(20)); |
||
1350 | blk.setProp("basePointY", basePointY.toString());
|
||
1351 | } |
||
1352 | if (grp.hasCode(30)) { |
||
1353 | 124 | jmorell | //basePoint.setLocation(basePoint.getZ(), grp.getDataAsDouble(30));
|
1354 | //blk.setBPoint(basePoint);
|
||
1355 | Double basePointZ = new Double(grp.getDataAsDouble(30)); |
||
1356 | blk.setProp("basePointZ", basePointZ.toString());
|
||
1357 | 73 | jmorell | } |
1358 | if (grp.hasCode(70)) { |
||
1359 | //blk.flags = grp.getDataAsInt(70);
|
||
1360 | Integer blockFlags = new Integer(grp.getDataAsInt(70)); |
||
1361 | blk.setProp("blockFlags", blockFlags.toString());
|
||
1362 | } |
||
1363 | 44 | jmorell | } |
1364 | |||
1365 | public void endBlk(DxfGroupVector grp) throws Exception { |
||
1366 | 73 | jmorell | //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
|
1367 | setAddingToBlock(false);
|
||
1368 | iterator = iterator + 1;
|
||
1369 | } |
||
1370 | |||
1371 | 78 | luisw | public void testBlocks() { |
1372 | System.out.println("getBlkList() = " + getBlkList()); |
||
1373 | Vector blkList = getBlkList();
|
||
1374 | FeatureCollection block = null;
|
||
1375 | Feature feature = null;
|
||
1376 | InsPoint insert = null;
|
||
1377 | Point2D point1 = new Point2D.Double(); |
||
1378 | Point2D point2 = new Point2D.Double(); |
||
1379 | System.out.println("blkList = " + blkList); |
||
1380 | System.out.println("blkList.size() = " + blkList.size()); |
||
1381 | for (int i=0; i<blkList.size(); i++) { |
||
1382 | System.out.println("compruebaBloques(): Bloque " + i +" de " + blkList.size()); |
||
1383 | block = (FeatureCollection) blkList.get(i); |
||
1384 | 96 | luisw | int aux = block.size();
|
1385 | 78 | luisw | for (int j=0; j<aux; j++) { |
1386 | 96 | luisw | feature = (Feature)block.get(j); |
1387 | 78 | luisw | //if (feature.getGeometry() instanceof InsPoint && feature.getProp("isAnInsert") == "true") {
|
1388 | if (feature.getGeometry() instanceof InsPoint) { |
||
1389 | insert = (InsPoint)feature.getGeometry(); |
||
1390 | String nomBlock = insert.getBlockName();
|
||
1391 | System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", inserta el bloque = " + nomBlock); |
||
1392 | System.out.println("compruebaBloques(): insert.get(0) = " + insert.get(0)); |
||
1393 | System.out.println("compruebaBloques(): feature.getProp(rotAngle) = " + insert.getRotAngle()); |
||
1394 | System.out.println("compruebaBloques(): insert.getScaleFactor() = " + insert.getScaleFactor()); |
||
1395 | //if (feature.getProp("blockFound") == "false") {
|
||
1396 | if (insert.getBlockFound() == false) { |
||
1397 | System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock); |
||
1398 | 168 | jmorell | insert.encuentraBloque(nomBlock); |
1399 | //gestionaInsert(feature);
|
||
1400 | //block.add(feature);
|
||
1401 | 78 | luisw | } |
1402 | |||
1403 | } |
||
1404 | } |
||
1405 | } |
||
1406 | } |
||
1407 | |||
1408 | 73 | jmorell | public void gestionaInsert(Feature feature) { |
1409 | Feature feature2 = null;
|
||
1410 | Point point = null; |
||
1411 | LineString lineString = null;
|
||
1412 | Polygon polygon = null; |
||
1413 | 74 | jmorell | InsPoint insert = new InsPoint();
|
1414 | insert = (InsPoint)feature.getGeometry(); |
||
1415 | 77 | jmorell | double bPointX = 0.0; |
1416 | double bPointY = 0.0; |
||
1417 | 168 | jmorell | //if (insert.getBlockFound() == true) {
|
1418 | 77 | jmorell | bPointX = Double.parseDouble(insert.getBlock().getProp("basePointX")); |
1419 | bPointY = Double.parseDouble(insert.getBlock().getProp("basePointY")); |
||
1420 | 168 | jmorell | //}
|
1421 | 74 | jmorell | double sFactorX = insert.getScaleFactor().getX();
|
1422 | double sFactorY = insert.getScaleFactor().getY();
|
||
1423 | 104 | jmorell | double rAngleGra = insert.getRotAngle();
|
1424 | double rAngleRad = rAngleGra*Math.PI/180.0; |
||
1425 | 73 | jmorell | InsPoint insert2 = null;
|
1426 | 44 | jmorell | |
1427 | 96 | luisw | for (int i=0; i<insert.getBlock().size(); i++) { |
1428 | 102 | jmorell | //System.out.println("gestionaInserts: insert.getBlock().features.size() = " + insert.getBlock().size());
|
1429 | 119 | jmorell | feature2 = (Feature)insert.getBlock().get(i); |
1430 | 100 | jmorell | |
1431 | 122 | jmorell | // Para que los elementos dentro del bloque tengan la misma layer
|
1432 | 145 | jmorell | // y color que el insert al que corresponden.
|
1433 | 161 | jmorell | // Segun la especificacion del formato DXF de Autodesk, la layer
|
1434 | // de las entities dentro de in bloque es la del bloque. La
|
||
1435 | // layer especifica para estos elementos en la defincion del
|
||
1436 | // bloque se ignora.
|
||
1437 | 168 | jmorell | System.out.println("TTTTTT: layer = " + feature2.getProp("layer")); |
1438 | if ((feature2.getProp("colorByLayer").equals("false") || feature2.getProp("layer").equals("0")) && !feature.getProp("layer").equals("0")) { |
||
1439 | 166 | jmorell | feature2.setProp("color", feature.getProp("color")); |
1440 | } |
||
1441 | 168 | jmorell | feature2.setProp("layer", feature.getProp("layer")); |
1442 | 100 | jmorell | |
1443 | 73 | jmorell | Point2D point1 = new Point2D.Double(); |
1444 | Point2D point11 = new Point2D.Double(); |
||
1445 | 119 | jmorell | Point2D pointAux = null; |
1446 | 103 | jmorell | |
1447 | 73 | jmorell | if (feature2.getGeometry() instanceof InsPoint){ |
1448 | 148 | jmorell | |
1449 | System.out.println("Encuentra bloques dentro de bloques"); |
||
1450 | |||
1451 | 74 | jmorell | insert2 = (InsPoint)feature2.getGeometry(); |
1452 | 73 | jmorell | point1 = insert2.get(0);
|
1453 | 117 | jmorell | |
1454 | 119 | jmorell | pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY); |
1455 | double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
||
1456 | double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
||
1457 | 103 | jmorell | point11.setLocation(laX, laY); |
1458 | 73 | jmorell | InsPoint insert3 = new InsPoint();
|
1459 | |||
1460 | 74 | jmorell | insert3.add(point11); |
1461 | 73 | jmorell | |
1462 | 74 | jmorell | insert3.setBlkList(insert2.getBlkList()); |
1463 | insert3.setBlock(insert2.getBlock()); |
||
1464 | insert3.setBlockName(insert2.getBlockName()); |
||
1465 | insert3.setRotAngle(insert2.getRotAngle()); |
||
1466 | 119 | jmorell | Point2D newScale = new Point2D.Double(insert2.getScaleFactor().getX() * sFactorX, insert2.getScaleFactor().getY() * sFactorY); |
1467 | insert3.setScaleFactor(newScale); |
||
1468 | 73 | jmorell | |
1469 | 74 | jmorell | Feature feature3 = new Feature();
|
1470 | feature3.setProp("layer", feature2.getProp("layer")); |
||
1471 | feature3.setProp("color", feature2.getProp("color")); |
||
1472 | 124 | jmorell | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
1473 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
1474 | 74 | jmorell | feature3.setGeometry(insert3); |
1475 | 73 | jmorell | |
1476 | 74 | jmorell | gestionaInsert(feature3); |
1477 | 73 | jmorell | } else if (feature2.getGeometry() instanceof LineString) { |
1478 | 74 | jmorell | lineString = (LineString)feature2.getGeometry(); |
1479 | 73 | jmorell | LineString lineString2 = new LineString();
|
1480 | Point2D[] points = new Point2D[lineString.pointNr()]; |
||
1481 | Point2D[] pointss = new Point2D[lineString.pointNr()]; |
||
1482 | for (int j=0; j<lineString.pointNr(); j++) { |
||
1483 | points[j] = (Point2D)lineString.get(j);
|
||
1484 | 74 | jmorell | pointss[j] = new Point2D.Double(); |
1485 | 117 | jmorell | |
1486 | 119 | jmorell | pointAux = new Point2D.Double(points[j].getX() - bPointX, points[j].getY() - bPointY); |
1487 | double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
||
1488 | double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
||
1489 | 103 | jmorell | pointss[j].setLocation(laX, laY); |
1490 | 73 | jmorell | lineString2.add(pointss[j]); |
1491 | } |
||
1492 | 74 | jmorell | |
1493 | Feature feature3 = new Feature();
|
||
1494 | feature3.setProp("layer", feature2.getProp("layer")); |
||
1495 | feature3.setProp("color", feature2.getProp("color")); |
||
1496 | 124 | jmorell | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
1497 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
1498 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
1499 | 74 | jmorell | feature3.setGeometry(lineString2); |
1500 | |||
1501 | if (addingToBlock == false) { |
||
1502 | features.add(feature3); |
||
1503 | 73 | jmorell | } |
1504 | 74 | jmorell | } else if (feature2.getGeometry() instanceof Polygon) { |
1505 | polygon = (Polygon)feature2.getGeometry();
|
||
1506 | Polygon polygon2 = new Polygon(); |
||
1507 | Point2D[] points = new Point2D[polygon.pointNr()]; |
||
1508 | Point2D[] pointss = new Point2D[polygon.pointNr()]; |
||
1509 | for (int j=0; j<polygon.pointNr(); j++) { |
||
1510 | points[j] = (Point2D)polygon.get(j);
|
||
1511 | 103 | jmorell | pointss[j] = new Point2D.Double(); |
1512 | 117 | jmorell | |
1513 | 119 | jmorell | points[j].setLocation(points[j].getX() - bPointX, points[j].getY() - bPointY); |
1514 | double laX = insert.get(0).getX() + ((points[j].getX()*sFactorX)*Math.cos(rAngleRad) + (points[j].getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
||
1515 | double laY = insert.get(0).getY() + ((points[j].getX()*sFactorX)*Math.sin(rAngleRad) + (points[j].getY()*sFactorY)*Math.cos(rAngleRad)); |
||
1516 | 103 | jmorell | pointss[j].setLocation(laX, laY); |
1517 | 74 | jmorell | polygon2.add(pointss[j]); |
1518 | 73 | jmorell | } |
1519 | 74 | jmorell | |
1520 | Feature feature3 = new Feature();
|
||
1521 | feature3.setProp("layer", feature2.getProp("layer")); |
||
1522 | feature3.setProp("color", feature2.getProp("color")); |
||
1523 | 124 | jmorell | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
1524 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
1525 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
1526 | 74 | jmorell | feature3.setGeometry(polygon2); |
1527 | |||
1528 | if (addingToBlock == false) { |
||
1529 | features.add(feature3); |
||
1530 | } |
||
1531 | } else if (feature2.getGeometry() instanceof Point) { |
||
1532 | point = (Point)feature2.getGeometry();
|
||
1533 | point1 = point.get(0);
|
||
1534 | 117 | jmorell | |
1535 | 119 | jmorell | pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY); |
1536 | double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
||
1537 | double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
||
1538 | 103 | jmorell | point11.setLocation(laX, laY); |
1539 | 74 | jmorell | Point pointt = new Point(); |
1540 | pointt.add(point11); |
||
1541 | |||
1542 | Feature feature3 = new Feature();
|
||
1543 | feature3.setProp("layer", feature2.getProp("layer")); |
||
1544 | feature3.setProp("color", feature2.getProp("color")); |
||
1545 | 124 | jmorell | feature3.setProp("dxfEntity", feature2.getProp("dxfEntity")); |
1546 | feature3.setProp("elevation", feature2.getProp("elevation")); |
||
1547 | feature3.setProp("thickness", feature2.getProp("thickness")); |
||
1548 | 122 | jmorell | if (point.isText) {
|
1549 | feature3.setProp("text", feature2.getProp("text")); |
||
1550 | 177 | jmorell | feature3.setProp("textHeight", feature2.getProp("textHeight")); |
1551 | double auxR = Double.parseDouble(feature2.getProp("textRotation")); |
||
1552 | System.out.println("auxR = " + auxR); |
||
1553 | auxR = auxR + rAngleGra; |
||
1554 | feature3.setProp("textRotation", Double.toString(auxR)); |
||
1555 | System.out.println("feature3.getProp(textRotation) = " + feature3.getProp("textRotation")); |
||
1556 | 178 | jmorell | pointt.isText = true;
|
1557 | 122 | jmorell | } |
1558 | 74 | jmorell | feature3.setGeometry(pointt); |
1559 | |||
1560 | 177 | jmorell | //if (addingToBlock == false) {
|
1561 | 74 | jmorell | features.add(feature3); |
1562 | 177 | jmorell | //}
|
1563 | 73 | jmorell | } else {
|
1564 | 119 | jmorell | System.out.println("gestionaInserts: Encontrado elemento desconocido"); |
1565 | 73 | jmorell | } |
1566 | } |
||
1567 | 44 | jmorell | } |
1568 | |||
1569 | /* (non-Javadoc)
|
||
1570 | * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
|
||
1571 | */
|
||
1572 | public Extent getExtent() {
|
||
1573 | Feature feature = new Feature();
|
||
1574 | Extent extent = new Extent();
|
||
1575 | Iterator iter = features.iterator();
|
||
1576 | while (iter.hasNext()) {
|
||
1577 | feature = (Feature)iter.next(); |
||
1578 | extent.add(feature.getExtent()); |
||
1579 | } |
||
1580 | return extent;
|
||
1581 | } |
||
1582 | |||
1583 | 94 | luisw | public void setProjection(IProjection p) { |
1584 | 44 | jmorell | proj = p; |
1585 | } |
||
1586 | |||
1587 | /* (non-Javadoc)
|
||
1588 | * @see org.cresques.io.DxfFile.EntityFactory#reProject(org.cresques.geo.ReProjection)
|
||
1589 | */
|
||
1590 | 94 | luisw | public void reProject(ICoordTrans rp) { |
1591 | 44 | jmorell | Feature feature = new Feature();
|
1592 | Extent extent = new Extent();
|
||
1593 | Iterator iter = features.iterator();
|
||
1594 | while (iter.hasNext()) {
|
||
1595 | feature = (Feature)iter.next(); |
||
1596 | ((Projected) feature).reProject(rp); |
||
1597 | extent.add(feature.getExtent()); |
||
1598 | } |
||
1599 | setProjection(rp.getPDest()); |
||
1600 | } |
||
1601 | |||
1602 | /* (non-Javadoc)
|
||
1603 | * @see org.cresques.geo.Projected#getProjection()
|
||
1604 | */
|
||
1605 | 94 | luisw | public IProjection getProjection() {
|
1606 | 44 | jmorell | return proj;
|
1607 | } |
||
1608 | |||
1609 | 96 | luisw | public IObjList getObjects() { return features;} |
1610 | 44 | jmorell | |
1611 | 91 | luisw | public void draw(Graphics2D g, ViewPortData vp) { |
1612 | 44 | jmorell | Iterator iter = features.iterator();
|
1613 | Extent extent; |
||
1614 | while (iter.hasNext()) {
|
||
1615 | Feature feature = new Feature();
|
||
1616 | feature = (Feature)iter.next(); |
||
1617 | extent = feature.getExtent(); |
||
1618 | if (vp.getExtent().minX()> extent.maxX()) continue; |
||
1619 | if (vp.getExtent().minY()> extent.maxY()) continue; |
||
1620 | if (vp.getExtent().maxX()< extent.minX()) continue; |
||
1621 | if (vp.getExtent().maxY()< extent.minY()) continue; |
||
1622 | //if (!feature.layer.frozen)
|
||
1623 | feature.draw(g, vp); |
||
1624 | } |
||
1625 | } |
||
1626 | |||
1627 | public static Vector createArc(Point2D coord1, Point2D coord2, double bulge) { |
||
1628 | return new DxfCalArcs(coord1, coord2, bulge).getPoints(1); |
||
1629 | } |
||
1630 | 62 | jmorell | |
1631 | /* (non-Javadoc)
|
||
1632 | * @see org.cresques.io.DxfFile.EntityFactory#getBlkList()
|
||
1633 | */
|
||
1634 | public Vector getBlkList() { |
||
1635 | 76 | jmorell | return blkList;
|
1636 | 62 | jmorell | } |
1637 | 66 | jmorell | |
1638 | /* (non-Javadoc)
|
||
1639 | * @see org.cresques.io.DxfFile.EntityFactory#getDxfEntityList()
|
||
1640 | */
|
||
1641 | public DxfEntityList getDxfEntityList() {
|
||
1642 | // TODO Auto-generated method stub
|
||
1643 | return null; |
||
1644 | } |
||
1645 | 69 | jmorell | |
1646 | /* (non-Javadoc)
|
||
1647 | * @see org.cresques.io.DxfFile.EntityFactory#getBlk()
|
||
1648 | */
|
||
1649 | public DxfBlock getBlk() {
|
||
1650 | // TODO Auto-generated method stub
|
||
1651 | return null; |
||
1652 | } |
||
1653 | 44 | jmorell | |
1654 | } |