Revision 10585

View differences:

trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/readers/DwgFileV12Reader.java
693 693
		void read(ByteBuffer bb, byte flags, short opts, DwgObject dwgObj);
694 694
	}
695 695
	
696
	/**
697
	 * In DWG 12 version, some kind of objects (Polylines and Vertex) cannot be
698
	 * instanciated until the EntityReader has readed some stuff (flags and so)
699
	 * from the file.
700
	 * 
701
	 * DifferedEntityReader has the responsability to create DwgObject instances,
702
	 * and it has the precondition that DwgObject parameter of its method read must
703
	 * be null.
704
	 * */
705
	abstract class DifferedEntityReader implements EntityReader{
706
		abstract DwgObject getDwgObject();
707
		
708
		public void read(ByteBuffer bb, byte flags, short opts, DwgObject dwgObj){
709
			if(dwgObj != null)
710
				throw new RuntimeException("DifferedEntityReader es el encargado de construir los objetos, debe recibirlos a null");
711
		}
712
		
713
	}
714
	
696 715
	class LineReader implements EntityReader{
697 716
		public void read(ByteBuffer bb, byte flags, short opts, DwgObject dwgObj) {
698 717
			if(! (dwgObj instanceof DwgLine))
......
1222 1241
		}
1223 1242
	}
1224 1243
	
1225
	class PlineReader implements EntityReader{
1244
	class PlineReader extends DifferedEntityReader{
1226 1245
		public void read(ByteBuffer bb, byte flags, short opts, DwgObject dwgObj) {
1246
			super.read(bb, flags, opts, dwgObj);
1247
			
1248
			//TODO El byte 70 es el que determina el tipo de Polyline
1227 1249
			if( (opts & 0x1) > 0){
1228 1250
				byte b70 = bb.get();
1229 1251
			}
......
1252 1274
				byte b75 = bb.get();
1253 1275
			}
1254 1276
		}
1277

  
1278
		DwgObject getDwgObject() {
1279
			// TODO Auto-generated method stub
1280
			return null;
1281
		}
1255 1282
	}
1256 1283
	
1257
	class VertexReader implements EntityReader{
1284
	class VertexReader extends DifferedEntityReader{
1258 1285
		public void read(ByteBuffer bb, byte flags, short opts, DwgObject dwgObj) {
1259 1286
			double[] pt10 = getPoint(false);
1260 1287
			bb.order(ByteOrder.LITTLE_ENDIAN);
......
1271 1298
				byte b70 = bb.get();
1272 1299
			}
1273 1300
		}
1301

  
1302
		DwgObject getDwgObject() {
1303
			// TODO Auto-generated method stub
1304
			return null;
1305
		}
1274 1306
	}
1275 1307
	
1276 1308
	class Face3DReader implements EntityReader{
......
1428 1460
				DwgObject entity = null;
1429 1461
				if(reader instanceof PlineReader){
1430 1462
					System.out.println("plinereader");
1463
					
1464
					
1465
					
1466
					
1467
					
1431 1468
				}else if(reader instanceof VertexReader){
1432 1469
					System.out.println("vertexreader");
1470
					
1471
					
1472
					
1473
					
1474
					
1475
					
1476
					
1477
					
1478
					
1433 1479
				}else{
1434 1480
					entity = DwgObjectFactory.
1435 1481
								getInstance().
1436 1482
								create(kind, index);
1437 1483
				}
1438
				
1439 1484
				entity.setColor(color);
1440 1485
				entity.setType(type);//TODO Este type es el mismo que para DWG 13-14-2000?
1441 1486
				entity.setSizeInBits(lenght);//TODO Este size es el mismo que para DWG 13-14-2000?
......
1487 1532
				}
1488 1533
				
1489 1534
				reader.read(bb, flag, opts, entity);
1535
				
1536
				
1537
				
1490 1538
				ant = bb.position();
1491 1539
				if(ant < crcpos){
1492 1540
					bb.position(bb.position() + (crcpos - ant));

Also available in: Unified diff