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