root / trunk / org.gvsig.dwg / org.gvsig.dwg.lib / src / main / java / org / gvsig / dwg / lib / readers / v2004 / DwgLayerReader2004.java @ 5
History | View | Annotate | Download (3.53 KB)
1 |
/*
|
---|---|
2 |
* Created on 25-ene-2007 by azabala
|
3 |
*
|
4 |
*/
|
5 |
package org.gvsig.dwg.lib.readers.v2004; |
6 |
|
7 |
import java.util.ArrayList; |
8 |
|
9 |
import org.gvsig.dwg.lib.CorruptedDwgEntityException; |
10 |
import org.gvsig.dwg.lib.DwgHandleReference; |
11 |
import org.gvsig.dwg.lib.DwgObject; |
12 |
import org.gvsig.dwg.lib.DwgUtil; |
13 |
import org.gvsig.dwg.lib.objects.DwgLayer; |
14 |
|
15 |
|
16 |
/**
|
17 |
* @author alzabord
|
18 |
*
|
19 |
* TODO To change the template for this generated type comment go to
|
20 |
* Window - Preferences - Java - Code Style - Code Templates
|
21 |
*/
|
22 |
public class DwgLayerReader2004 extends AbstractDwg2004Reader{ |
23 |
|
24 |
/* (non-Javadoc)
|
25 |
* @see com.iver.cit.jdwglib.dwg.readers.IDwgObjectReader#readSpecificObj(int[], int, com.iver.cit.jdwglib.dwg.DwgObject)
|
26 |
*/
|
27 |
public void readSpecificObj(int[] data, int offset, DwgObject dwgObj) throws RuntimeException, CorruptedDwgEntityException { |
28 |
if(! (dwgObj instanceof DwgLayer)) |
29 |
throw new RuntimeException("LayerReader 2004 solo puede leer DwgLayer"); |
30 |
|
31 |
DwgLayer lyr = (DwgLayer) dwgObj; |
32 |
int bitPos = offset;
|
33 |
ArrayList v;
|
34 |
|
35 |
v = DwgUtil.getBitLong(data, bitPos); |
36 |
bitPos = ((Integer)v.get(0)).intValue(); |
37 |
int numReactors = ((Integer)v.get(1)).intValue(); |
38 |
lyr.setNumReactors(numReactors); |
39 |
|
40 |
v = DwgUtil.testBit(data, bitPos); |
41 |
bitPos = ((Integer)v.get(0)).intValue(); |
42 |
boolean XdicFlag = ((Boolean) v.get(1)).booleanValue(); |
43 |
|
44 |
v = DwgUtil.getTextString(data, bitPos); |
45 |
bitPos = ((Integer)v.get(0)).intValue(); |
46 |
String name = (String)v.get(1); |
47 |
lyr.setName(name); |
48 |
|
49 |
v = DwgUtil.testBit(data, bitPos); |
50 |
bitPos = ((Integer)v.get(0)).intValue(); |
51 |
boolean flag = ((Boolean)v.get(1)).booleanValue(); |
52 |
lyr.setFlag64(flag); |
53 |
|
54 |
v = DwgUtil.getBitShort(data, bitPos); |
55 |
bitPos = ((Integer)v.get(0)).intValue(); |
56 |
int xrefplus1 = ((Integer)v.get(1)).intValue(); |
57 |
lyr.setXRefPlus(xrefplus1); |
58 |
|
59 |
v = DwgUtil.testBit(data, bitPos); |
60 |
bitPos = ((Integer)v.get(0)).intValue(); |
61 |
boolean xdep = ((Boolean)v.get(1)).booleanValue(); |
62 |
lyr.setXdep(xdep); |
63 |
|
64 |
v = DwgUtil.getBitShort(data, bitPos); |
65 |
bitPos = ((Integer)v.get(0)).intValue(); |
66 |
int flags = ((Integer)v.get(1)).intValue(); |
67 |
lyr.setFlags(flags); |
68 |
|
69 |
// v = DwgUtil.getBitShort(data, bitPos);
|
70 |
// bitPos = ((Integer)v.get(0)).intValue();
|
71 |
// int color = ((Integer)v.get(1)).intValue();
|
72 |
// lyr.setColor(color);
|
73 |
|
74 |
//FIXME: De momento solo guardo el indice del color por compatibilidad.
|
75 |
// hay que ver qu? debemos hacer con el color
|
76 |
v = DwgUtil.getCmColor(data, bitPos, lyr.getVersion()); |
77 |
bitPos = ((Integer)v.get(0)).intValue(); |
78 |
int color = ((Integer)v.get(1)).intValue(); |
79 |
lyr.setColor(color); |
80 |
|
81 |
|
82 |
DwgHandleReference hr = new DwgHandleReference();
|
83 |
bitPos = hr.read(data, bitPos); |
84 |
lyr.setLayerControlHandle(hr); |
85 |
|
86 |
lyr.inserta(); |
87 |
/*
|
88 |
* Reactors handles
|
89 |
* DwgObject
|
90 |
*/
|
91 |
DwgHandleReference reactorHandle; |
92 |
for (int i = 0; i < lyr.getNumReactors(); i++) { |
93 |
reactorHandle = new DwgHandleReference();
|
94 |
bitPos = reactorHandle.read(data, bitPos); |
95 |
lyr.addReactorHandle(reactorHandle); |
96 |
} |
97 |
|
98 |
/*
|
99 |
* XDICOBJHANDLE
|
100 |
*/
|
101 |
if(!XdicFlag){
|
102 |
DwgHandleReference xDicObjHandle = new DwgHandleReference();
|
103 |
bitPos = xDicObjHandle.read(data, bitPos); |
104 |
lyr.setXDicObjHandle(xDicObjHandle); |
105 |
} |
106 |
|
107 |
DwgHandleReference nullHandle = new DwgHandleReference();
|
108 |
bitPos = nullHandle.read(data, bitPos); |
109 |
lyr.setNullHandle(nullHandle); |
110 |
|
111 |
DwgHandleReference plotStyleHandle = new DwgHandleReference();
|
112 |
bitPos = plotStyleHandle.read(data, bitPos); |
113 |
lyr.setPlotStyleHandle(plotStyleHandle); |
114 |
|
115 |
|
116 |
DwgHandleReference lineTypeHandle = new DwgHandleReference();
|
117 |
bitPos = lineTypeHandle.read(data, bitPos); |
118 |
lyr.setLineTypeHandle(lineTypeHandle); |
119 |
|
120 |
|
121 |
} |
122 |
|
123 |
} |