Revision 424 branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfFeatureMaker.java
DxfFeatureMaker.java | ||
---|---|---|
287 | 287 |
// Se trata de un SEQEND despues de un ATTRIB |
288 | 288 |
|
289 | 289 |
// 041130: Rellena las props con los atributos. |
290 |
completeAttributes(lastFeaBordes); |
|
291 |
completeAttributes(lastFeaFondos); |
|
290 |
//completeAttributes(lastFeaBordes); |
|
291 |
//completeAttributes(lastFeaFondos); |
|
292 |
copyAttributes(lastFeaBordes); |
|
292 | 293 |
|
293 | 294 |
if (addingToBlock == false) { |
294 | 295 |
features.add(lastFeaFondos); |
... | ... | |
1314 | 1315 |
Feature feature = new Feature(); |
1315 | 1316 |
Point secondGeom = new Point(); |
1316 | 1317 |
Feature secondFeat = new Feature(); |
1317 |
|
|
1318 | 1318 |
int attributesFollowFlag = 0; |
1319 | 1319 |
|
1320 | 1320 |
feature.setProp("dxfEntity", "Insert"); |
... | ... | |
1758 | 1758 |
textStyleName = grp.getDataAsString(7); |
1759 | 1759 |
textStyleName = DxfConvTexts.ConvertText(textStyleName); |
1760 | 1760 |
} |
1761 |
|
|
1762 |
setNewAttributes(); |
|
1763 |
|
|
1761 | 1764 |
/*if (grp.hasCode(40)) { |
1762 | 1765 |
Double heightD = new Double(grp.getDataAsDouble(40)); |
1763 | 1766 |
String heightS = heightD.toString(); |
... | ... | |
1819 | 1822 |
boolean defValDefined = false; |
1820 | 1823 |
int attributeFlags = 0; |
1821 | 1824 |
|
1822 |
//Feature insFeature = lastFeaBordes; |
|
1823 |
//Feature insFea = lastFeaBordes; |
|
1824 |
Feature ptFea = lastFeaFondos; |
|
1825 |
Feature insFea = lastFeaBordes; |
|
1826 |
//Feature ptFea = lastFeaFondos; |
|
1825 | 1827 |
|
1826 | 1828 |
//feature.setProp("dxfEntity", "Attrib"); <-- Es un INSERT con attributes. |
1827 | 1829 |
/*if (grp.hasCode(8)) |
... | ... | |
1854 | 1856 |
//System.out.println("createAttrib(1): attribute[0] = " + attribute[0]); |
1855 | 1857 |
//System.out.println("createAttrib(1): attribute[1] = " + attribute[1]); |
1856 | 1858 |
if (tagDefined) { |
1857 |
//insFea.setProp(attribute[0], attribute[1]);
|
|
1858 |
ptFea.setProp(attribute[0], attribute[1]); |
|
1859 |
insFea.setProp(attribute[0], attribute[1]); |
|
1860 |
//ptFea.setProp(attribute[0], attribute[1]);
|
|
1859 | 1861 |
/*for (int i=0;i<attributes.size();i++) { |
1860 | 1862 |
String[] att = (String[])attributes.get(i); |
1861 | 1863 |
String stAttTag = att[0]; |
... | ... | |
1872 | 1874 |
//System.out.println("createAttrib(2): attribute[0] = " + attribute[0]); |
1873 | 1875 |
//System.out.println("createAttrib(2): attribute[1] = " + attribute[1]); |
1874 | 1876 |
if (defValDefined) { |
1875 |
//insFea.setProp(attribute[0], attribute[1]);
|
|
1876 |
ptFea.setProp(attribute[0], attribute[1]); |
|
1877 |
insFea.setProp(attribute[0], attribute[1]); |
|
1878 |
//ptFea.setProp(attribute[0], attribute[1]);
|
|
1877 | 1879 |
/*for (int i=0;i<attributes.size();i++) { |
1878 | 1880 |
String[] att = (String[])attributes.get(i); |
1879 | 1881 |
String stAttTag = att[0]; |
... | ... | |
2120 | 2122 |
feature3.setProp("elevation", feature2.getProp("elevation")); |
2121 | 2123 |
|
2122 | 2124 |
//041130 |
2123 |
/*for (int j=0;j<attributes.size();j++) {
|
|
2125 |
for (int j=0;j<attributes.size();j++) { |
|
2124 | 2126 |
String[] att = new String[2]; |
2125 | 2127 |
att = (String[])attributes.get(j); |
2126 | 2128 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2127 |
}*/
|
|
2129 |
} |
|
2128 | 2130 |
|
2129 | 2131 |
feature3.setGeometry(insert3); |
2130 | 2132 |
|
... | ... | |
2153 | 2155 |
feature3.setProp("thickness", feature2.getProp("thickness")); |
2154 | 2156 |
|
2155 | 2157 |
//041130 |
2156 |
/*for (int j=0;j<attributes.size();j++) {
|
|
2158 |
for (int j=0;j<attributes.size();j++) { |
|
2157 | 2159 |
String[] att = new String[2]; |
2158 | 2160 |
att = (String[])attributes.get(j); |
2159 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
|
2160 |
}*/ |
|
2161 |
System.out.println("gestionaInsert(): att[0] = " + att[0]); |
|
2162 |
System.out.println("gestionaInsert(): feature2.getProp(att[0]) = " + feature2.getProp(att[0])); |
|
2163 |
System.out.println("gestionaInsert(): feature2.getProp(layer) = " + feature2.getProp("layer")); |
|
2164 |
System.out.println("gestionaInsert(): feature2.getProp(color) = " + feature2.getProp("color")); |
|
2165 |
System.out.println("gestionaInsert(): feature2.getProp(dxfEntity) = " + feature2.getProp("dxfEntity")); |
|
2166 |
System.out.println("gestionaInsert(): feature2.getProp(thickness) = " + feature2.getProp("thickness")); |
|
2167 |
String str = att[0]; |
|
2168 |
feature3.setProp(str,feature2.getProp(str)); |
|
2169 |
} |
|
2161 | 2170 |
|
2162 | 2171 |
feature3.setGeometry(lineString2); |
2163 | 2172 |
|
... | ... | |
2188 | 2197 |
feature3.setProp("thickness", feature2.getProp("thickness")); |
2189 | 2198 |
|
2190 | 2199 |
//041130 |
2191 |
/*for (int j=0;j<attributes.size();j++) {
|
|
2200 |
for (int j=0;j<attributes.size();j++) { |
|
2192 | 2201 |
String[] att = new String[2]; |
2193 | 2202 |
att = (String[])attributes.get(j); |
2194 | 2203 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2195 |
}*/
|
|
2204 |
} |
|
2196 | 2205 |
|
2197 | 2206 |
feature3.setGeometry(polygon2); |
2198 | 2207 |
|
... | ... | |
2228 | 2237 |
} |
2229 | 2238 |
|
2230 | 2239 |
//041130 |
2231 |
/*for (int j=0;j<attributes.size();j++) {
|
|
2240 |
for (int j=0;j<attributes.size();j++) { |
|
2232 | 2241 |
String[] att = new String[2]; |
2233 | 2242 |
att = (String[])attributes.get(j); |
2234 | 2243 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
2235 |
}*/
|
|
2244 |
} |
|
2236 | 2245 |
|
2237 | 2246 |
feature3.setGeometry(pointt); |
2238 | 2247 |
|
... | ... | |
2274 | 2283 |
|
2275 | 2284 |
/** |
2276 | 2285 |
* Hace los setProp para los atributos extra. |
2286 |
* @param feature |
|
2277 | 2287 |
*/ |
2278 | 2288 |
private void completeAttributes(Feature feature) { |
2279 | 2289 |
// 041130: Rellena las props con los atributos. |
... | ... | |
2284 | 2294 |
} |
2285 | 2295 |
} |
2286 | 2296 |
|
2297 |
/** |
|
2298 |
* Copia los atributos extra cargados en InsPoint y ya perfectamente definidos a los |
|
2299 |
* elementos del bloque al que referencia el punto de insercion. |
|
2300 |
* @param insert |
|
2301 |
*/ |
|
2302 |
private void copyAttributes(Feature feaInsert) { |
|
2303 |
Feature feature = null; |
|
2304 |
/*Point point = null; |
|
2305 |
LineString lineString = null; |
|
2306 |
Polygon polygon = null;*/ |
|
2307 |
InsPoint insert = new InsPoint(); |
|
2308 |
insert = (InsPoint)feaInsert.getGeometry(); |
|
2309 |
/*double bPointX = 0.0; |
|
2310 |
double bPointY = 0.0; |
|
2311 |
//if (insert.getBlockFound() == true) { |
|
2312 |
bPointX = Double.parseDouble(insert.getBlock().getProp("basePointX")); |
|
2313 |
bPointY = Double.parseDouble(insert.getBlock().getProp("basePointY")); |
|
2314 |
//} |
|
2315 |
double sFactorX = insert.getScaleFactor().getX(); |
|
2316 |
double sFactorY = insert.getScaleFactor().getY();*/ |
|
2317 |
/*double rAngleGra = insert.getRotAngle(); |
|
2318 |
double rAngleRad = rAngleGra*Math.PI/180.0; |
|
2319 |
InsPoint insert2 = null;*/ |
|
2320 |
|
|
2321 |
for (int i=0; i<insert.getBlock().size(); i++) { |
|
2322 |
//System.out.println("gestionaInserts: insert.getBlock().features.size() = " + insert.getBlock().size()); |
|
2323 |
feature = (Feature)insert.getBlock().get(i); |
|
2324 |
|
|
2325 |
for (int j=0;j<attributes.size();j++) { |
|
2326 |
String[] att = new String[2]; |
|
2327 |
att = (String[])attributes.get(j); |
|
2328 |
feature.setProp(att[0],feaInsert.getProp(att[0])); |
|
2329 |
} |
|
2330 |
|
|
2331 |
// Para que los elementos dentro del bloque tengan la misma layer |
|
2332 |
// y color que el insert al que corresponden. |
|
2333 |
// Segun la especificacion del formato DXF de Autodesk, la layer |
|
2334 |
// de las entities dentro de un bloque es la del bloque. La |
|
2335 |
// layer especifica para estos elementos en la defincion del |
|
2336 |
// bloque se ignora. |
|
2337 |
//System.out.println("gestionaInsert(): layer = " + feature2.getProp("layer")); |
|
2338 |
/*if ((feature2.getProp("colorByLayer").equals("false") || feature2.getProp("layer").equals("0")) && !feature.getProp("layer").equals("0")) { |
|
2339 |
feature2.setProp("color", feature.getProp("color")); |
|
2340 |
} |
|
2341 |
feature2.setProp("layer", feature.getProp("layer"));*/ |
|
2342 |
|
|
2343 |
//Point2D point1 = new Point2D.Double(); |
|
2344 |
//Point2D point11 = new Point2D.Double(); |
|
2345 |
//Point2D pointAux = null; |
|
2346 |
|
|
2347 |
//if (feature.getGeometry() instanceof InsPoint){ |
|
2348 |
|
|
2349 |
//System.out.println("gestionaInsert(): Encuentra bloques dentro de bloques"); |
|
2350 |
|
|
2351 |
//insert2 = (InsPoint)feature.getGeometry(); |
|
2352 |
/*point1 = insert2.get(0); |
|
2353 |
|
|
2354 |
pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY); |
|
2355 |
double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
|
2356 |
double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
|
2357 |
point11.setLocation(laX, laY); |
|
2358 |
InsPoint insert3 = new InsPoint(); |
|
2359 |
|
|
2360 |
insert3.add(point11); |
|
2361 |
|
|
2362 |
insert3.setBlkList(insert2.getBlkList()); |
|
2363 |
insert3.setBlock(insert2.getBlock()); |
|
2364 |
insert3.setBlockName(insert2.getBlockName()); |
|
2365 |
insert3.setRotAngle(insert2.getRotAngle()); |
|
2366 |
Point2D newScale = new Point2D.Double(insert2.getScaleFactor().getX() * sFactorX, insert2.getScaleFactor().getY() * sFactorY); |
|
2367 |
insert3.setScaleFactor(newScale);*/ |
|
2368 |
|
|
2369 |
//Feature feature3 = new Feature(); |
|
2370 |
|
|
2371 |
/*feature.setProp("layer", feaInsert.getProp("layer")); |
|
2372 |
feature.setProp("color", feaInsert.getProp("color")); |
|
2373 |
feature.setProp("dxfEntity", feaInsert.getProp("dxfEntity")); |
|
2374 |
feature.setProp("elevation", feaInsert.getProp("elevation"));*/ |
|
2375 |
|
|
2376 |
/*for (int j=0;j<attributes.size();j++) { |
|
2377 |
String[] att = new String[2]; |
|
2378 |
att = (String[])attributes.get(j); |
|
2379 |
feature.setProp(att[0],feaInsert.getProp(att[0])); |
|
2380 |
}*/ |
|
2381 |
|
|
2382 |
//041130 |
|
2383 |
/*for (int j=0;j<attributes.size();j++) { |
|
2384 |
String[] att = new String[2]; |
|
2385 |
att = (String[])attributes.get(j); |
|
2386 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
|
2387 |
}*/ |
|
2388 |
|
|
2389 |
//feature3.setGeometry(insert2); |
|
2390 |
|
|
2391 |
//gestionaInsert(feature3); |
|
2392 |
//} else if (feature.getGeometry() instanceof LineString) { |
|
2393 |
//lineString = (LineString)feature.getGeometry(); |
|
2394 |
/*LineString lineString2 = new LineString(); |
|
2395 |
Point2D[] points = new Point2D[lineString.pointNr()]; |
|
2396 |
Point2D[] pointss = new Point2D[lineString.pointNr()]; |
|
2397 |
for (int j=0; j<lineString.pointNr(); j++) { |
|
2398 |
points[j] = (Point2D)lineString.get(j); |
|
2399 |
pointss[j] = new Point2D.Double(); |
|
2400 |
|
|
2401 |
pointAux = new Point2D.Double(points[j].getX() - bPointX, points[j].getY() - bPointY); |
|
2402 |
double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
|
2403 |
double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
|
2404 |
pointss[j].setLocation(laX, laY); |
|
2405 |
lineString2.add(pointss[j]); |
|
2406 |
}*/ |
|
2407 |
|
|
2408 |
//Feature feature3 = new Feature(); |
|
2409 |
/*feature.setProp("layer", feaInsert.getProp("layer")); |
|
2410 |
feature.setProp("color", feaInsert.getProp("color")); |
|
2411 |
feature.setProp("dxfEntity", feaInsert.getProp("dxfEntity")); |
|
2412 |
feature.setProp("elevation", feaInsert.getProp("elevation")); |
|
2413 |
feature.setProp("thickness", feaInsert.getProp("thickness")); |
|
2414 |
|
|
2415 |
for (int j=0;j<attributes.size();j++) { |
|
2416 |
String[] att = new String[2]; |
|
2417 |
att = (String[])attributes.get(j); |
|
2418 |
System.out.println("copyAttributes(); att[0] = " + att[0]); |
|
2419 |
System.out.println("copyAttributes(); att[1] = " + att[1]); |
|
2420 |
feature.setProp(att[0],feaInsert.getProp(att[0])); |
|
2421 |
}*/ |
|
2422 |
|
|
2423 |
//041130 |
|
2424 |
/*for (int j=0;j<attributes.size();j++) { |
|
2425 |
String[] att = new String[2]; |
|
2426 |
att = (String[])attributes.get(j); |
|
2427 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
|
2428 |
}*/ |
|
2429 |
|
|
2430 |
//feature3.setGeometry(lineString); |
|
2431 |
|
|
2432 |
/*if (addingToBlock == false) { |
|
2433 |
features.add(feature3); |
|
2434 |
}*/ |
|
2435 |
//} else if (feature.getGeometry() instanceof Polygon) { |
|
2436 |
//polygon = (Polygon)feature.getGeometry(); |
|
2437 |
/*Polygon polygon2 = new Polygon(); |
|
2438 |
Point2D[] points = new Point2D[polygon.pointNr()]; |
|
2439 |
Point2D[] pointss = new Point2D[polygon.pointNr()]; |
|
2440 |
for (int j=0; j<polygon.pointNr(); j++) { |
|
2441 |
points[j] = (Point2D)polygon.get(j); |
|
2442 |
pointss[j] = new Point2D.Double(); |
|
2443 |
|
|
2444 |
points[j].setLocation(points[j].getX() - bPointX, points[j].getY() - bPointY); |
|
2445 |
double laX = insert.get(0).getX() + ((points[j].getX()*sFactorX)*Math.cos(rAngleRad) + (points[j].getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
|
2446 |
double laY = insert.get(0).getY() + ((points[j].getX()*sFactorX)*Math.sin(rAngleRad) + (points[j].getY()*sFactorY)*Math.cos(rAngleRad)); |
|
2447 |
pointss[j].setLocation(laX, laY); |
|
2448 |
polygon2.add(pointss[j]); |
|
2449 |
}*/ |
|
2450 |
|
|
2451 |
//Feature feature3 = new Feature(); |
|
2452 |
/*feature.setProp("layer", feaInsert.getProp("layer")); |
|
2453 |
feature.setProp("color", feaInsert.getProp("color")); |
|
2454 |
feature.setProp("dxfEntity", feaInsert.getProp("dxfEntity")); |
|
2455 |
feature.setProp("elevation", feaInsert.getProp("elevation")); |
|
2456 |
feature.setProp("thickness", feaInsert.getProp("thickness")); |
|
2457 |
|
|
2458 |
for (int j=0;j<attributes.size();j++) { |
|
2459 |
String[] att = new String[2]; |
|
2460 |
att = (String[])attributes.get(j); |
|
2461 |
feature.setProp(att[0],feaInsert.getProp(att[0])); |
|
2462 |
}*/ |
|
2463 |
|
|
2464 |
//041130 |
|
2465 |
/*for (int j=0;j<attributes.size();j++) { |
|
2466 |
String[] att = new String[2]; |
|
2467 |
att = (String[])attributes.get(j); |
|
2468 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
|
2469 |
}*/ |
|
2470 |
|
|
2471 |
//feature3.setGeometry(polygon); |
|
2472 |
|
|
2473 |
/*if (addingToBlock == false) { |
|
2474 |
features.add(feature3); |
|
2475 |
}*/ |
|
2476 |
//} else if (feature.getGeometry() instanceof Point) { |
|
2477 |
//point = (Point)feature.getGeometry(); |
|
2478 |
/*point1 = point.get(0); |
|
2479 |
|
|
2480 |
pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY); |
|
2481 |
double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad)); |
|
2482 |
double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad)); |
|
2483 |
point11.setLocation(laX, laY); |
|
2484 |
Point pointt = new Point(); |
|
2485 |
pointt.add(point11);*/ |
|
2486 |
|
|
2487 |
//Feature feature3 = new Feature(); |
|
2488 |
/*feature.setProp("layer", feaInsert.getProp("layer")); |
|
2489 |
feature.setProp("color", feaInsert.getProp("color")); |
|
2490 |
feature.setProp("dxfEntity", feaInsert.getProp("dxfEntity")); |
|
2491 |
feature.setProp("elevation", feaInsert.getProp("elevation")); |
|
2492 |
feature.setProp("thickness", feaInsert.getProp("thickness")); |
|
2493 |
if (point.isText) { |
|
2494 |
feature3.setProp("text", feature.getProp("text")); |
|
2495 |
feature3.setProp("textHeight", feature.getProp("textHeight")); |
|
2496 |
double auxR = Double.parseDouble(feature.getProp("textRotation")); |
|
2497 |
//System.out.println("auxR = " + auxR); |
|
2498 |
auxR = auxR + rAngleGra; |
|
2499 |
feature3.setProp("textRotation", Double.toString(auxR)); |
|
2500 |
//System.out.println("gestionaInsert(): feature3.getProp(textRotation) = " + feature3.getProp("textRotation")); |
|
2501 |
//point.isText = true; |
|
2502 |
} |
|
2503 |
|
|
2504 |
for (int j=0;j<attributes.size();j++) { |
|
2505 |
String[] att = new String[2]; |
|
2506 |
att = (String[])attributes.get(j); |
|
2507 |
feature3.setProp(att[0],feature.getProp(att[0])); |
|
2508 |
}*/ |
|
2509 |
|
|
2510 |
//041130 |
|
2511 |
/*for (int j=0;j<attributes.size();j++) { |
|
2512 |
String[] att = new String[2]; |
|
2513 |
att = (String[])attributes.get(j); |
|
2514 |
feature3.setProp(att[0],feature2.getProp(att[0])); |
|
2515 |
}*/ |
|
2516 |
|
|
2517 |
/*feature3.setGeometry(point); |
|
2518 |
|
|
2519 |
if (addingToBlock == false) { |
|
2520 |
features.add(feature3); |
|
2521 |
}*/ |
|
2522 |
/*} else { |
|
2523 |
System.out.println("gestionaInsert(): Encontrado elemento desconocido"); |
|
2524 |
}*/ |
|
2525 |
} |
|
2526 |
} |
|
2527 |
|
|
2528 |
/** |
|
2529 |
* Se ejecuta cuando se declaran nuevos atributos, es decir, tras cada ATTDEF. |
|
2530 |
* A?ade estos atributos a las features existentes. |
|
2531 |
*/ |
|
2532 |
private void setNewAttributes() { |
|
2533 |
for (int i=0;i<features.size();i++) { |
|
2534 |
Feature fea = new Feature(); |
|
2535 |
fea = (Feature)features.get(i); |
|
2536 |
completeAttributes(fea); |
|
2537 |
} |
|
2538 |
for (int i=0;i<blkList.size();i++) { |
|
2539 |
FeatureCollection bloque = new FeatureCollection(proj); |
|
2540 |
bloque = (FeatureCollection)blkList.get(i); |
|
2541 |
for (int j=0;j<bloque.size();j++) { |
|
2542 |
Feature fea = new Feature(); |
|
2543 |
fea = (Feature)bloque.get(j); |
|
2544 |
completeAttributes(fea); |
|
2545 |
} |
|
2546 |
} |
|
2547 |
} |
|
2548 |
|
|
2287 | 2549 |
public Vector getAttributes() { |
2288 | 2550 |
return attributes; |
2289 | 2551 |
} |
Also available in: Unified diff