Revision 1924 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dwg/DwgMemoryDriver.java
DwgMemoryDriver.java | ||
---|---|---|
129 | 129 |
dwg = new DwgFile(); |
130 | 130 |
long time = System.currentTimeMillis(); |
131 | 131 |
dwg.read(m_Fich.getAbsolutePath()); |
132 |
dwg.initializeLayerTable(); |
|
132 | 133 |
dwg.calculateDwgPolylines(); |
133 |
//dwg.initializeLayerTable(); |
|
134 | 134 |
dwg.manageInserts(); |
135 | 135 |
long timeElapsed = System.currentTimeMillis()-time; |
136 | 136 |
System.out.println("Tiempo empleado en leer el fichero dwg = " + timeElapsed); |
... | ... | |
174 | 174 |
} |
175 | 175 |
}*/ |
176 | 176 |
|
177 |
Vector layerTable = createLayerTable(dwgObjects); |
|
177 |
//Vector layerTable = createLayerTable(dwgObjects);
|
|
178 | 178 |
|
179 | 179 |
for (int i=0;i<dwgObjects.size();i++) { |
180 | 180 |
|
... | ... | |
196 | 196 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
197 | 197 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc")); |
198 | 198 |
//int[] layerHandle = (int[])entity.getLayer(); |
199 |
String layerName = getLayerName(entity, layerTable);
|
|
199 |
String layerName = dwg.getLayerName(entity);
|
|
200 | 200 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
201 | 201 |
int color = entity.getColor(); |
202 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
202 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
203 | 203 |
//if (color==0) color ByBlock |
204 | 204 |
if (color==256) color = colorByLayer; |
205 | 205 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
230 | 230 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
231 | 231 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle")); |
232 | 232 |
//int[] layerHandle = (int[])entity.getLayer(); |
233 |
String layerName = getLayerName(entity, layerTable);
|
|
233 |
String layerName = dwg.getLayerName(entity);
|
|
234 | 234 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
235 | 235 |
int color = entity.getColor(); |
236 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
236 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
237 | 237 |
//if (color==0) color ByBlock |
238 | 238 |
if (color==256) color = colorByLayer; |
239 | 239 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
265 | 265 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
266 | 266 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line")); |
267 | 267 |
//int[] layerHandle = (int[])entity.getLayer(); |
268 |
String layerName = getLayerName(entity, layerTable);
|
|
268 |
String layerName = dwg.getLayerName(entity);
|
|
269 | 269 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
270 | 270 |
int color = entity.getColor(); |
271 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
271 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
272 | 272 |
//if (color==0) color ByBlock |
273 | 273 |
if (color==256) color = colorByLayer; |
274 | 274 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
295 | 295 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
296 | 296 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Point")); |
297 | 297 |
//int[] layerHandle = (int[])entity.getLayer(); |
298 |
String layerName = getLayerName(entity, layerTable);
|
|
298 |
String layerName = dwg.getLayerName(entity);
|
|
299 | 299 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
300 | 300 |
int color = entity.getColor(); |
301 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
301 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
302 | 302 |
//if (color==0) color ByBlock |
303 | 303 |
if (color==256) color = colorByLayer; |
304 | 304 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
321 | 321 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
322 | 322 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D")); |
323 | 323 |
//int[] layerHandle = (int[])entity.getLayer(); |
324 |
String layerName = getLayerName(entity, layerTable);
|
|
324 |
String layerName = dwg.getLayerName(entity);
|
|
325 | 325 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
326 | 326 |
int color = entity.getColor(); |
327 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
327 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
328 | 328 |
//if (color==0) color ByBlock |
329 | 329 |
if (color==256) color = colorByLayer; |
330 | 330 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
357 | 357 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
358 | 358 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Text")); |
359 | 359 |
//int[] layerHandle = (int[])entity.getLayer(); |
360 |
String layerName = getLayerName(entity, layerTable);
|
|
360 |
String layerName = dwg.getLayerName(entity);
|
|
361 | 361 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
362 | 362 |
int color = entity.getColor(); |
363 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
363 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
364 | 364 |
//if (color==0) color ByBlock |
365 | 365 |
if (color==256) color = colorByLayer; |
366 | 366 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
414 | 414 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
415 | 415 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block")); |
416 | 416 |
//int[] layerHandle = (int[])entity.getLayer(); |
417 |
String layerName = getLayerName(entity, layerTable);
|
|
417 |
String layerName = dwg.getLayerName(entity);
|
|
418 | 418 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
419 | 419 |
int color = entity.getColor(); |
420 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
420 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
421 | 421 |
//if (color==0) color ByBlock |
422 | 422 |
if (color==256) color = colorByLayer; |
423 | 423 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
441 | 441 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
442 | 442 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("EndBlk")); |
443 | 443 |
//int[] layerHandle = (int[])entity.getLayer(); |
444 |
String layerName = getLayerName(entity, layerTable);
|
|
444 |
String layerName = dwg.getLayerName(entity);
|
|
445 | 445 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
446 | 446 |
int color = entity.getColor(); |
447 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
447 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
448 | 448 |
//if (color==0) color ByBlock |
449 | 449 |
if (color==256) color = colorByLayer; |
450 | 450 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
468 | 468 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
469 | 469 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Control Object")); |
470 | 470 |
//int[] layerHandle = (int[])entity.getLayer(); |
471 |
String layerName = getLayerName(entity, layerTable);
|
|
471 |
String layerName = dwg.getLayerName(entity);
|
|
472 | 472 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
473 | 473 |
int color = entity.getColor(); |
474 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
474 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
475 | 475 |
//if (color==0) color ByBlock |
476 | 476 |
if (color==256) color = colorByLayer; |
477 | 477 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
495 | 495 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
496 | 496 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Header")); |
497 | 497 |
//int[] layerHandle = (int[])entity.getLayer(); |
498 |
String layerName = getLayerName(entity, layerTable);
|
|
498 |
String layerName = dwg.getLayerName(entity);
|
|
499 | 499 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
500 | 500 |
int color = entity.getColor(); |
501 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
501 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
502 | 502 |
//if (color==0) color ByBlock |
503 | 503 |
if (color==256) color = colorByLayer; |
504 | 504 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
536 | 536 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
537 | 537 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Insert")); |
538 | 538 |
//int[] layerHandle = (int[])entity.getLayer(); |
539 |
String layerName = getLayerName(entity, layerTable);
|
|
539 |
String layerName = dwg.getLayerName(entity);
|
|
540 | 540 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
541 | 541 |
int color = entity.getColor(); |
542 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
542 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
543 | 543 |
//if (color==0) color ByBlock |
544 | 544 |
if (color==256) color = colorByLayer; |
545 | 545 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
567 | 567 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
568 | 568 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("MText")); |
569 | 569 |
//int[] layerHandle = (int[])entity.getLayer(); |
570 |
String layerName = getLayerName(entity, layerTable);
|
|
570 |
String layerName = dwg.getLayerName(entity);
|
|
571 | 571 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
572 | 572 |
int color = entity.getColor(); |
573 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
573 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
574 | 574 |
//if (color==0) color ByBlock |
575 | 575 |
if (color==256) color = colorByLayer; |
576 | 576 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
609 | 609 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
610 | 610 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Solid")); |
611 | 611 |
//int[] layerHandle = (int[])entity.getLayer(); |
612 |
String layerName = getLayerName(entity, layerTable);
|
|
612 |
String layerName = dwg.getLayerName(entity);
|
|
613 | 613 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
614 | 614 |
int color = entity.getColor(); |
615 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
615 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
616 | 616 |
//if (color==0) color ByBlock |
617 | 617 |
if (color==256) color = colorByLayer; |
618 | 618 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
656 | 656 |
auxRow[ID_FIELD_ID] = ValueFactory.createValue(i); |
657 | 657 |
auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("LwPolyline")); |
658 | 658 |
//int[] layerHandle = (int[])entity.getLayer(); |
659 |
String layerName = getLayerName(entity, layerTable);
|
|
659 |
String layerName = dwg.getLayerName(entity);
|
|
660 | 660 |
auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName); |
661 | 661 |
int color = entity.getColor(); |
662 |
int colorByLayer = getColorByLayer(entity, layerTable);
|
|
662 |
int colorByLayer = dwg.getColorByLayer(entity);
|
|
663 | 663 |
//if (color==0) color ByBlock |
664 | 664 |
if (color==256) color = colorByLayer; |
665 | 665 |
auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color); |
... | ... | |
1194 | 1194 |
* @param dwgObjects |
1195 | 1195 |
* @return |
1196 | 1196 |
*/ |
1197 |
private Vector createLayerTable(Vector dwgObjects) { |
|
1197 |
/*private Vector createLayerTable(Vector dwgObjects) {
|
|
1198 | 1198 |
Vector layerTable = new Vector(); |
1199 | 1199 |
for (int i=0;i<dwgObjects.size();i++) { |
1200 | 1200 |
DwgObject obj = (DwgObject)dwgObjects.get(i); |
... | ... | |
1210 | 1210 |
} |
1211 | 1211 |
} |
1212 | 1212 |
return layerTable; |
1213 |
} |
|
1213 |
}*/
|
|
1214 | 1214 |
|
1215 |
//private String setLayerName(int[] layerHandle, Vector layerTable) { |
|
1216 |
private String getLayerName(DwgObject entity, Vector layerTable) { |
|
1215 |
/*private String getLayerName(DwgObject entity, Vector layerTable) { |
|
1217 | 1216 |
String layerName = ""; |
1218 |
/*int[] layerHandle = (int[])entity.getLayer(); |
|
1219 |
byte[] layerBytes = new byte[]{0,0,0,0}; |
|
1220 |
if (layerHandle.length>2) layerBytes[3] = (byte)layerHandle[2]; |
|
1221 |
if (layerHandle.length>3) layerBytes[2] = (byte)layerHandle[3]; |
|
1222 |
if (layerHandle.length>4) layerBytes[1] = (byte)layerHandle[4]; |
|
1223 |
if (layerHandle.length>5) layerBytes[0] = (byte)layerHandle[5]; |
|
1224 |
int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0});*/ |
|
1225 | 1217 |
int layer = entity.getLayerHandle(); |
1226 | 1218 |
for (int j=0;j<layerTable.size();j++) { |
1227 | 1219 |
Vector layerTableRecord = (Vector)layerTable.get(j); |
1228 |
/*Vector layerHandleVect = (Vector)layerTableRecord.get(0); |
|
1229 |
byte[] layerHandleBytes = new byte[]{0,0,0,0}; |
|
1230 |
if (layerHandleVect.size()>2) layerHandleBytes[3] = (byte)((Integer)layerHandleVect.get(2)).intValue(); |
|
1231 |
if (layerHandleVect.size()>3) layerHandleBytes[2] = (byte)((Integer)layerHandleVect.get(3)).intValue(); |
|
1232 |
if (layerHandleVect.size()>4) layerHandleBytes[1] = (byte)((Integer)layerHandleVect.get(4)).intValue(); |
|
1233 |
if (layerHandleVect.size()>5) layerHandleBytes[0] = (byte)((Integer)layerHandleVect.get(5)).intValue(); |
|
1234 |
int lHandle = ByteUtils.bytesToInt(layerHandleBytes, new int[]{0});*/ |
|
1235 | 1220 |
int lHandle = ((Integer)layerTableRecord.get(0)).intValue(); |
1236 | 1221 |
if (lHandle==layer) { |
1237 | 1222 |
layerName = (String)layerTableRecord.get(1); |
1238 |
//System.out.println("layerName = " + layerName); |
|
1239 | 1223 |
} |
1240 | 1224 |
} |
1241 | 1225 |
return layerName; |
... | ... | |
1243 | 1227 |
|
1244 | 1228 |
private int getColorByLayer(DwgObject entity, Vector layerTable) { |
1245 | 1229 |
int colorByLayer = 0; |
1246 |
/*int[] layerHandle = (int[])entity.getLayer(); |
|
1247 |
byte[] layerBytes = new byte[]{0,0,0,0}; |
|
1248 |
if (layerHandle.length>2) layerBytes[3] = (byte)layerHandle[2]; |
|
1249 |
if (layerHandle.length>3) layerBytes[2] = (byte)layerHandle[3]; |
|
1250 |
if (layerHandle.length>4) layerBytes[1] = (byte)layerHandle[4]; |
|
1251 |
if (layerHandle.length>5) layerBytes[0] = (byte)layerHandle[5]; |
|
1252 |
int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0});*/ |
|
1253 | 1230 |
int layer = entity.getLayerHandle(); |
1254 | 1231 |
for (int j=0;j<layerTable.size();j++) { |
1255 | 1232 |
Vector layerTableRecord = (Vector)layerTable.get(j); |
1256 |
/*Vector layerHandleVect = (Vector)layerTableRecord.get(0); |
|
1257 |
byte[] layerHandleBytes = new byte[]{0,0,0,0}; |
|
1258 |
if (layerHandleVect.size()>2) layerHandleBytes[3] = (byte)((Integer)layerHandleVect.get(2)).intValue(); |
|
1259 |
if (layerHandleVect.size()>3) layerHandleBytes[2] = (byte)((Integer)layerHandleVect.get(3)).intValue(); |
|
1260 |
if (layerHandleVect.size()>4) layerHandleBytes[1] = (byte)((Integer)layerHandleVect.get(4)).intValue(); |
|
1261 |
if (layerHandleVect.size()>5) layerHandleBytes[0] = (byte)((Integer)layerHandleVect.get(5)).intValue(); |
|
1262 |
int lHandle = ByteUtils.bytesToInt(layerHandleBytes, new int[]{0});*/ |
|
1263 | 1233 |
int lHandle = ((Integer)layerTableRecord.get(0)).intValue(); |
1264 | 1234 |
if (lHandle==layer) { |
1265 | 1235 |
colorByLayer = ((Integer)layerTableRecord.get(2)).intValue(); |
1266 |
//System.out.println("colorByLayer = " + colorByLayerObj.intValue()); |
|
1267 | 1236 |
} |
1268 | 1237 |
} |
1269 | 1238 |
return colorByLayer; |
1270 |
} |
|
1239 |
}*/
|
|
1271 | 1240 |
|
1272 | 1241 |
/* (non-Javadoc) |
1273 | 1242 |
* @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File) |
Also available in: Unified diff