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