Revision 1881 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dwg/DwgMemoryDriver.java

View differences:

DwgMemoryDriver.java
180 180
				double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue());
181 181
				Point2D[] arc = createArc(center, radius, startAngle, endAngle);
182 182
				FPolyline2D arcc = createPolyline3D(arc);
183
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
183
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
184 184
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc"));
185
				int[] layerHandle = (int[])entity.getLayer();
185
				//int[] layerHandle = (int[])entity.getLayer();
186 186
				String layerName = getLayerName(entity, layerTable);
187 187
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
188 188
				int color = entity.getColor();
189
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
189
				int colorByLayer = getColorByLayer(entity, layerTable);
190 190
				//if (color==0) color ByBlock
191 191
				if (color==256) color = colorByLayer;
192 192
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
210 210
				data = entity.getDwgObjectSpecificDataItem("RADIUS");
211 211
				double radius = ((Double)data.getValue()).doubleValue();
212 212
				FPolyline2D circle = createCircle(center, radius);
213
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
213
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
214 214
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle"));
215
				int[] layerHandle = (int[])entity.getLayer();
215
				//int[] layerHandle = (int[])entity.getLayer();
216 216
				String layerName = getLayerName(entity, layerTable);
217 217
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
218 218
				int color = entity.getColor();
219
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
219
				int colorByLayer = getColorByLayer(entity, layerTable);
220 220
				//if (color==0) color ByBlock
221 221
				if (color==256) color = colorByLayer;
222 222
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
241 241
				coord = (double[])data.getValue();
242 242
				Point2D p2 = new Point2D.Double(coord[0], coord[1]);
243 243
				FPolyline2D line = createLine(p1, p2);
244
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
244
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
245 245
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line"));
246
				int[] layerHandle = (int[])entity.getLayer();
246
				//int[] layerHandle = (int[])entity.getLayer();
247 247
				String layerName = getLayerName(entity, layerTable);
248 248
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
249 249
				int color = entity.getColor();
250
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
250
				int colorByLayer = getColorByLayer(entity, layerTable);
251 251
				//if (color==0) color ByBlock
252 252
				if (color==256) color = colorByLayer;
253 253
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
269 269
				double[] coord = (double[])data.getValue();
270 270
				Point2D p = new Point2D.Double(coord[0], coord[1]);
271 271
				FPoint2D point = createPoint(p);
272
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
272
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
273 273
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Point"));
274
				int[] layerHandle = (int[])entity.getLayer();
274
				//int[] layerHandle = (int[])entity.getLayer();
275 275
				String layerName = getLayerName(entity, layerTable);
276 276
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
277 277
				int color = entity.getColor();
278
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
278
				int colorByLayer = getColorByLayer(entity, layerTable);
279 279
				//if (color==0) color ByBlock
280 280
				if (color==256) color = colorByLayer;
281 281
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
363 363
					bulges.add(new Double(0));
364 364
				}
365 365
				FPolyline2D pline = createPolyline2D(newPts, bulges);
366
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
366
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
367 367
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D"));
368
				int[] layerHandle = (int[])entity.getLayer();
368
				//int[] layerHandle = (int[])entity.getLayer();
369 369
				String layerName = getLayerName(entity, layerTable);
370 370
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
371 371
				int color = entity.getColor();
372
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
372
				int colorByLayer = getColorByLayer(entity, layerTable);
373 373
				//if (color==0) color ByBlock
374 374
				if (color==256) color = colorByLayer;
375 375
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
423 423
					newPts[pts.length] = pts[0];
424 424
				}
425 425
				FPolyline2D pline3d = createPolyline3D(newPts);
426
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
426
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
427 427
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline3D"));
428
				int[] layerHandle = (int[])entity.getLayer();
428
				//int[] layerHandle = (int[])entity.getLayer();
429 429
				String layerName = getLayerName(entity, layerTable);
430 430
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
431 431
				int color = entity.getColor();
432
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
432
				int colorByLayer = getColorByLayer(entity, layerTable);
433 433
				//if (color==0) color ByBlock
434 434
				if (color==256) color = colorByLayer;
435 435
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
450 450
				DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
451 451
				Point2D p = (Point2D)data.getValue();
452 452
				FPoint2D point = createPoint(p);
453
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
453
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
454 454
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Text"));
455
				int[] layerHandle = (int[])entity.getLayer();
455
				//int[] layerHandle = (int[])entity.getLayer();
456 456
				String layerName = getLayerName(entity, layerTable);
457 457
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
458 458
				int color = entity.getColor();
459
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
459
				int colorByLayer = getColorByLayer(entity, layerTable);
460 460
				//if (color==0) color ByBlock
461 461
				if (color==256) color = colorByLayer;
462 462
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
500 500
				addingToBlock = true;
501 501
				//pto = (Point2D.Double)point.get(0);
502 502
				//FShape nuevoShp;
503
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
503
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
504 504
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block"));
505
				int[] layerHandle = (int[])entity.getLayer();
505
				//int[] layerHandle = (int[])entity.getLayer();
506 506
				String layerName = getLayerName(entity, layerTable);
507 507
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
508 508
				int color = entity.getColor();
509
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
509
				int colorByLayer = getColorByLayer(entity, layerTable);
510 510
				//if (color==0) color ByBlock
511 511
				if (color==256) color = colorByLayer;
512 512
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
527 527
				addingToBlock = false;
528 528
				//pto = (Point2D.Double)point.get(0);
529 529
				//FShape nuevoShp;
530
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
530
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
531 531
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("EndBlk"));
532
				int[] layerHandle = (int[])entity.getLayer();
532
				//int[] layerHandle = (int[])entity.getLayer();
533 533
				String layerName = getLayerName(entity, layerTable);
534 534
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
535 535
				int color = entity.getColor();
536
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
536
				int colorByLayer = getColorByLayer(entity, layerTable);
537 537
				//if (color==0) color ByBlock
538 538
				if (color==256) color = colorByLayer;
539 539
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
554 554
				//addingToBlock = false;
555 555
				//pto = (Point2D.Double)point.get(0);
556 556
				//FShape nuevoShp;
557
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
557
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
558 558
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Control Object"));
559
				int[] layerHandle = (int[])entity.getLayer();
559
				//int[] layerHandle = (int[])entity.getLayer();
560 560
				String layerName = getLayerName(entity, layerTable);
561 561
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
562 562
				int color = entity.getColor();
563
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
563
				int colorByLayer = getColorByLayer(entity, layerTable);
564 564
				//if (color==0) color ByBlock
565 565
				if (color==256) color = colorByLayer;
566 566
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
581 581
				addingToBlock = true;
582 582
				//pto = (Point2D.Double)point.get(0);
583 583
				//FShape nuevoShp;
584
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
584
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
585 585
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Header"));
586
				int[] layerHandle = (int[])entity.getLayer();
586
				//int[] layerHandle = (int[])entity.getLayer();
587 587
				String layerName = getLayerName(entity, layerTable);
588 588
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
589 589
				int color = entity.getColor();
590
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
590
				int colorByLayer = getColorByLayer(entity, layerTable);
591 591
				//if (color==0) color ByBlock
592 592
				if (color==256) color = colorByLayer;
593 593
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
615 615
				data = entity.getDwgObjectSpecificDataItem("BLOCK_HEADER_HANDLE");
616 616
				int[] blockHandle = (int[])data.getValue();
617 617
				
618
				manageInsert(dwgObjects, point, scale, rot, blockHandle, auxRow);
618
				manageInsert(dwgObjects, layerTable, point, scale, rot, blockHandle, auxRow);
619 619
				
620
				auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
620
				auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
621 621
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Insert"));
622
				int[] layerHandle = (int[])entity.getLayer();
622
				//int[] layerHandle = (int[])entity.getLayer();
623 623
				String layerName = getLayerName(entity, layerTable);
624 624
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
625 625
				int color = entity.getColor();
626
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
626
				int colorByLayer = getColorByLayer(entity, layerTable);
627 627
				//if (color==0) color ByBlock
628 628
				if (color==256) color = colorByLayer;
629 629
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
646 646
				double[] coord = (double[])data.getValue();
647 647
				Point2D p = new Point2D.Double(coord[0], coord[1]);
648 648
				FPoint2D point = createPoint(p);
649
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
649
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
650 650
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("MText"));
651
				int[] layerHandle = (int[])entity.getLayer();
651
				//int[] layerHandle = (int[])entity.getLayer();
652 652
				String layerName = getLayerName(entity, layerTable);
653 653
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
654 654
				int color = entity.getColor();
655
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
655
				int colorByLayer = getColorByLayer(entity, layerTable);
656 656
				//if (color==0) color ByBlock
657 657
				if (color==256) color = colorByLayer;
658 658
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
683 683
				coord = (double[])data.getValue();
684 684
				Point2D p4 = new Point2D.Double(coord[0], coord[1]);
685 685
				FPolygon2D solid = createSolid(new Point2D[]{p1, p2, p4, p3});
686
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
686
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
687 687
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Solid"));
688
				int[] layerHandle = (int[])entity.getLayer();
688
				//int[] layerHandle = (int[])entity.getLayer();
689 689
				String layerName = getLayerName(entity, layerTable);
690 690
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
691 691
				int color = entity.getColor();
692
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
692
				int colorByLayer = getColorByLayer(entity, layerTable);
693 693
				//if (color==0) color ByBlock
694 694
				if (color==256) color = colorByLayer;
695 695
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
722 722
					 pts[j] = new Point2D.Double(pt[0], pt[1]);
723 723
				}
724 724
				FPolyline2D spline = createLwPolyline(pts);
725
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
725
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
726 726
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Spline"));
727
				int[] layerHandle = (int[])entity.getLayer();
727
				//int[] layerHandle = (int[])entity.getLayer();
728 728
				String layerName = getLayerName(entity, layerTable);
729 729
                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
730 730
				int color = entity.getColor();
731
				int colorByLayer = setColorByLayer(layerHandle, layerTable);
731
				int colorByLayer = getColorByLayer(entity, layerTable);
732 732
				//if (color==0) color ByBlock
733 733
				if (color==256) color = colorByLayer;
734 734
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
763 763
						 pts[j] = new Point2D.Double(pt[0], pt[1]);
764 764
					}
765 765
					FPolyline2D lwpline = createLwPolyline(pts);
766
	                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
766
	                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
767 767
	                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("LwPolyline"));
768
					int[] layerHandle = (int[])entity.getLayer();
768
					//int[] layerHandle = (int[])entity.getLayer();
769 769
					String layerName = getLayerName(entity, layerTable);
770 770
	                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
771 771
					int color = entity.getColor();
772
					int colorByLayer = setColorByLayer(layerHandle, layerTable);
772
					int colorByLayer = getColorByLayer(entity, layerTable);
773 773
					//if (color==0) color ByBlock
774 774
					if (color==256) color = colorByLayer;
775 775
	                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
......
1023 1023
		}
1024 1024
	}
1025 1025
	
1026
	private void manageInsert(Vector dwgObjects, Point2D insPoint, double[] scale, double rot, int[] blockHandle, Value[] auxRow) {
1026
	private void manageInsert(Vector dwgObjects, Vector layerTable, Point2D insPoint, double[] scale, double rot, int[] blockHandle, Value[] auxRow) {
1027 1027
		byte[] blockHandleBytes = new byte[]{0,0,0,0};
1028 1028
		if (blockHandle.length>2) blockHandleBytes[3] = (byte)blockHandle[2];
1029 1029
		if (blockHandle.length>3) blockHandleBytes[2] = (byte)blockHandle[3];
......
1075 1075
					if (lastEntityHandle.length>5) lastEntityBytes[0] = (byte)lastEntityHandle[5];
1076 1076
					int lastHandle = ByteUtils.bytesToInt(lastEntityBytes, new int[]{0});
1077 1077
					//System.out.println("lastHandle = " + lastHandle);
1078
					// Buscando la capa y el color del bloque ...
1079
					String bname = (String)obj.getDwgObjectSpecificDataItem("NAME").getValue();
1080
					//int[] blockHandleLayer = null;
1081
					//int blockColor = 0;
1082
					DwgObject block = null;
1083
					for (int k=0;k<dwgObjects.size();k++) {
1084
						DwgObject ent = (DwgObject)dwgObjects.get(k);
1085
						if (ent.getType()==0x4) {
1086
							String name = (String)obj.getDwgObjectSpecificDataItem("NAME").getValue();
1087
							if (bname.equals(name)) {
1088
								//blockHandleLayer = ent.getLayer();
1089
								//blockColor = ent.getColor();
1090
								block = ent;
1091
							}
1092
						}
1093
					}
1078 1094
					
1079 1095
					for (int k=0;k<dwgObjects.size();k++) {
1080 1096
						DwgObject ent = (DwgObject)dwgObjects.get(k);
......
1098 1114
								if (blockEntityHandle.size()>4) blockEntityHandleBytes[1] = ((Integer)blockEntityHandle.get(4)).byteValue();
1099 1115
								if (blockEntityHandle.size()>5) blockEntityHandleBytes[0] = ((Integer)blockEntityHandle.get(5)).byteValue();
1100 1116
								int bEntityHandle = ByteUtils.bytesToInt(blockEntityHandleBytes, new int[]{0});
1101
								manageBlockEntity(blockEntity, bPoint, insPoint, scale, rot, auxRow);
1117
								manageBlockEntity(blockEntity, layerTable, bPoint, insPoint, scale, rot, block, auxRow);
1102 1118
								l++;
1103 1119
								if (bEntityHandle==lastHandle && ((Integer)entHandle.get(1)).intValue()==lastEntityHandle[1]) {
1104 1120
									break;
......
1111 1127
		}
1112 1128
	}
1113 1129
	
1114
	private void manageBlockEntity(DwgObject entity, double[] bPoint, Point2D insPoint, double[] scale, double rot, Value[] auxRow) {
1130
	private void manageBlockEntity(DwgObject entity, Vector layerTable, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, Value[] auxRow) {
1115 1131
		if (entity.getType()==0x11) {
1116 1132
			System.out.println("Encuentra un arco dentro de un bloque ...");
1117 1133
			DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
......
1132 1148
				arc[i] = new Point2D.Double(laX, laY);
1133 1149
			}
1134 1150
			FPolyline2D arcc = createPolyline3D(arc);
1135
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1136
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
1137
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
1138
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0);
1151
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1152
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc"));
1153
			String layerName = getLayerName(block, layerTable);
1154
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
1155
			int color = entity.getColor();
1156
			int colorByLayer = getColorByLayer(entity, layerTable);
1157
			int colorByBlock = getColorByLayer(block, layerTable);
1158
			if (color==0) color = colorByBlock;
1159
			if (color==256) color = colorByLayer;
1160
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1139 1161
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
1140 1162
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1141 1163
        	// Attributes
......
1164 1186
			radius = radius * scale[0];
1165 1187
			
1166 1188
			FPolyline2D circle = createCircle(center, radius);
1167
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1168
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
1169
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
1170
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0);
1189
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1190
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle"));
1191
			String layerName = getLayerName(block, layerTable);
1192
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
1193
			int color = entity.getColor();
1194
			int colorByLayer = getColorByLayer(entity, layerTable);
1195
			int colorByBlock = getColorByLayer(block, layerTable);
1196
			if (color==0) color = colorByBlock;
1197
			if (color==256) color = colorByLayer;
1198
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1171 1199
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
1172 1200
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1173 1201
        	// Attributes
......
1199 1227
			p2 = new Point2D.Double(laX, laY);
1200 1228
			
1201 1229
			FPolyline2D line = createLine(p1, p2);
1202
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1203
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
1204
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
1205
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0);
1230
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1231
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line"));
1232
			String layerName = getLayerName(block, layerTable);
1233
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
1234
			int color = entity.getColor();
1235
			int colorByLayer = getColorByLayer(entity, layerTable);
1236
			int colorByBlock = getColorByLayer(block, layerTable);
1237
			if (color==0) color = colorByBlock;
1238
			if (color==256) color = colorByLayer;
1239
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1206 1240
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
1207 1241
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1208 1242
        	// Attributes
......
1234 1268
			
1235 1269
			newScale = new double[]{scale[0]*newScale[0], scale[1]*newScale[1], scale[2]*newScale[2]};
1236 1270
			
1237
			manageInsert(dwgObjects, newInsPoint, newScale, newRot, newBlockHandle, auxRow);
1271
			manageInsert(dwgObjects, layerTable, newInsPoint, newScale, newRot, newBlockHandle, auxRow);
1238 1272
			
1239 1273
			/*auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1240 1274
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
......
1333 1367
			}
1334 1368
			
1335 1369
			FPolyline2D pline = createPolyline2D(newPts, bulges);
1336
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1337
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
1338
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
1339
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(0);
1370
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1371
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D"));
1372
			String layerName = getLayerName(block, layerTable);
1373
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
1374
			int color = entity.getColor();
1375
			int colorByLayer = getColorByLayer(entity, layerTable);
1376
			int colorByBlock = getColorByLayer(block, layerTable);
1377
			if (color==0) color = colorByBlock;
1378
			if (color==256) color = colorByLayer;
1379
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1340 1380
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
1341 1381
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1342 1382
        	// Attributes
......
1419 1459
		return layerName;
1420 1460
	}
1421 1461
	
1422
	private int setColorByLayer(int[] layerHandle, Vector layerTable) {
1462
	private int getColorByLayer(DwgObject entity, Vector layerTable) {
1463
		int[] layerHandle = (int[])entity.getLayer();
1423 1464
		int colorByLayer = 0;
1424 1465
		byte[] layerBytes = new byte[]{0,0,0,0};
1425 1466
		if (layerHandle.length>2) layerBytes[3] = (byte)layerHandle[2];
......
1446 1487
		return colorByLayer;
1447 1488
	}
1448 1489
	
1490
	private int handleBinToHandleInt(Vector layerHandle) {
1491
		byte[] layerBytes = new byte[]{0,0,0,0};
1492
		if (layerHandle.size()>2) layerBytes[3] = (byte)((Integer)layerHandle.get(2)).intValue();
1493
		if (layerHandle.size()>3) layerBytes[2] = (byte)((Integer)layerHandle.get(3)).intValue();
1494
		if (layerHandle.size()>4) layerBytes[1] = (byte)((Integer)layerHandle.get(4)).intValue();;
1495
		if (layerHandle.size()>5) layerBytes[0] = (byte)((Integer)layerHandle.get(5)).intValue();
1496
		int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0});
1497
		return layer;
1498
	}
1499
	
1449 1500
	/* (non-Javadoc)
1450 1501
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
1451 1502
	 */

Also available in: Unified diff