Revision 9930 trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgLayer.java

View differences:

DwgLayer.java
34 34
 */
35 35
package com.iver.cit.jdwglib.dwg.objects;
36 36

  
37
import java.util.ArrayList;
38
import java.util.Vector;
39

  
40 37
import com.iver.cit.jdwglib.dwg.DwgObject;
41
import com.iver.cit.jdwglib.dwg.DwgUtil;
42 38

  
43 39
/**
44 40
 * The DwgLayer class represents a DWG Layer
......
62 58
	private int linetypeHandle;
63 59
	
64 60
	/**
65
	 * Read a Layer in the DWG format Version 15
66
	 * 
67
	 * @param data Array of unsigned bytes obtained from the DWG binary file
68
	 * @param offset The current bit offset where the value begins
69
	 * @throws Exception If an unexpected bit value is found in the DWG file. Occurs
70
	 * 		   when we are looking for LwPolylines.
71
	 */
72
	public void readDwgLayerV15(int[] data, int offset) throws Exception {
73
		int bitPos = offset;
74
		ArrayList v = DwgUtil.getBitLong(data, bitPos);
75
		bitPos = ((Integer)v.get(0)).intValue();
76
		int numReactors = ((Integer)v.get(1)).intValue();
77
		setNumReactors(numReactors);
78
		v = DwgUtil.getTextString(data, bitPos);
79
		bitPos = ((Integer)v.get(0)).intValue();
80
		String name = (String)v.get(1);
81
		this.name = name;
82
		v = DwgUtil.testBit(data, bitPos);
83
		bitPos = ((Integer)v.get(0)).intValue();
84
		boolean flag = ((Boolean)v.get(1)).booleanValue();
85
		flag64 = flag;
86
		v = DwgUtil.getBitShort(data, bitPos);
87
		bitPos = ((Integer)v.get(0)).intValue();
88
		int xrefplus1 = ((Integer)v.get(1)).intValue();
89
		xRefPlus = xrefplus1;
90
		v = DwgUtil.testBit(data, bitPos);
91
		bitPos = ((Integer)v.get(0)).intValue();
92
		boolean xdep = ((Boolean)v.get(1)).booleanValue();
93
		this.xdep = xdep; 
94
		v = DwgUtil.getBitShort(data, bitPos);
95
		bitPos = ((Integer)v.get(0)).intValue();
96
		int flags = ((Integer)v.get(1)).intValue();
97
		this.flags = flags;
98
		v = DwgUtil.getBitShort(data, bitPos);
99
		bitPos = ((Integer)v.get(0)).intValue();
100
		int color = ((Integer)v.get(1)).intValue();
101
		this.color = color;
102
		v = DwgUtil.getHandle(data, bitPos);
103
		bitPos = ((Integer)v.get(0)).intValue();
104
		int[] handle = new int[v.size()-1];
105
	    for (int j=1;j<v.size();j++) {
106
		    handle[j-1] = ((Integer)v.get(j)).intValue();
107
	    }
108
	    ArrayList handleVect = new ArrayList();
109
	    for (int i=0;i<handle.length;i++) {
110
	    	handleVect.add(new Integer(handle[i]));
111
	    }
112
	    layerControlHandle = DwgUtil.handleBinToHandleInt(handleVect);
113
		for (int i=0;i<numReactors;i++) {
114
			v = DwgUtil.getHandle(data, bitPos);
115
			bitPos = ((Integer)v.get(0)).intValue();
116
			handle = new int[v.size()-1];
117
		    for (int j=1;j<v.size();j++) {
118
			    handle[j-1] = ((Integer)v.get(j)).intValue();
119
		    }
120
		}
121
		v = DwgUtil.getHandle(data, bitPos);
122
		bitPos = ((Integer)v.get(0)).intValue();
123
		handle = new int[v.size()-1];
124
	    for (int j=1;j<v.size();j++) {
125
		    handle[j-1] = ((Integer)v.get(j)).intValue();
126
	    }
127
		v = DwgUtil.getHandle(data, bitPos);
128
		bitPos = ((Integer)v.get(0)).intValue();
129
		handle = new int[v.size()-1];
130
	    for (int j=1;j<v.size();j++) {
131
		    handle[j-1] = ((Integer)v.get(j)).intValue();
132
	    }
133
	    handleVect = new ArrayList();
134
	    for (int i=0;i<handle.length;i++) {
135
	    	handleVect.add(new Integer(handle[i]));
136
	    }
137
	    nullHandle = DwgUtil.handleBinToHandleInt(handleVect);
138
		v = DwgUtil.getHandle(data, bitPos);
139
		bitPos = ((Integer)v.get(0)).intValue();
140
		handle = new int[v.size()-1];
141
	    for (int j=1;j<v.size();j++) {
142
		    handle[j-1] = ((Integer)v.get(j)).intValue();
143
	    }
144
	    handleVect = new ArrayList();
145
	    for (int i=0;i<handle.length;i++) {
146
	    	handleVect.add(new Integer(handle[i]));
147
	    }
148
	    plotstyleHandle = DwgUtil.handleBinToHandleInt(handleVect);
149
		v = DwgUtil.getHandle(data, bitPos);
150
		bitPos = ((Integer)v.get(0)).intValue();
151
		handle = new int[v.size()-1];
152
	    for (int j=1;j<v.size();j++) {
153
		    handle[j-1] = ((Integer)v.get(j)).intValue();
154
	    }
155
	    handleVect = new ArrayList();
156
	    for (int i=0;i<handle.length;i++) {
157
	    	handleVect.add(new Integer(handle[i]));
158
	    }
159
	    linetypeHandle = DwgUtil.handleBinToHandleInt(handleVect);
160
	}
161
	/**
162 61
	 * @return Returns the color.
163 62
	 */
164 63
	public int getColor() {
......
182 81
	public void setName(String name) {
183 82
		this.name = name;
184 83
	}
84
	/**
85
	 * @return Returns the flag64.
86
	 */
87
	public boolean isFlag64() {
88
		return flag64;
89
	}
90
	/**
91
	 * @param flag64 The flag64 to set.
92
	 */
93
	public void setFlag64(boolean flag64) {
94
		this.flag64 = flag64;
95
	}
96
	/**
97
	 * @return Returns the xRefPlus.
98
	 */
99
	public int getXRefPlus() {
100
		return xRefPlus;
101
	}
102
	/**
103
	 * @param refPlus The xRefPlus to set.
104
	 */
105
	public void setXRefPlus(int refPlus) {
106
		xRefPlus = refPlus;
107
	}
108
	/**
109
	 * @return Returns the xdep.
110
	 */
111
	public boolean isXdep() {
112
		return xdep;
113
	}
114
	/**
115
	 * @param xdep The xdep to set.
116
	 */
117
	public void setXdep(boolean xdep) {
118
		this.xdep = xdep;
119
	}
120
	/**
121
	 * @return Returns the flags.
122
	 */
123
	public int getFlags() {
124
		return flags;
125
	}
126
	/**
127
	 * @param flags The flags to set.
128
	 */
129
	public void setFlags(int flags) {
130
		this.flags = flags;
131
	}
132
	/**
133
	 * @return Returns the layerControlHandle.
134
	 */
135
	public int getLayerControlHandle() {
136
		return layerControlHandle;
137
	}
138
	/**
139
	 * @param layerControlHandle The layerControlHandle to set.
140
	 */
141
	public void setLayerControlHandle(int layerControlHandle) {
142
		this.layerControlHandle = layerControlHandle;
143
	}
144
	/**
145
	 * @return Returns the nullHandle.
146
	 */
147
	public int getNullHandle() {
148
		return nullHandle;
149
	}
150
	/**
151
	 * @param nullHandle The nullHandle to set.
152
	 */
153
	public void setNullHandle(int nullHandle) {
154
		this.nullHandle = nullHandle;
155
	}
156
	/**
157
	 * @return Returns the linetypeHandle.
158
	 */
159
	public int getLinetypeHandle() {
160
		return linetypeHandle;
161
	}
162
	/**
163
	 * @param linetypeHandle The linetypeHandle to set.
164
	 */
165
	public void setLinetypeHandle(int linetypeHandle) {
166
		this.linetypeHandle = linetypeHandle;
167
	}
168
	/**
169
	 * @return Returns the plotstyleHandle.
170
	 */
171
	public int getPlotstyleHandle() {
172
		return plotstyleHandle;
173
	}
174
	/**
175
	 * @param plotstyleHandle The plotstyleHandle to set.
176
	 */
177
	public void setPlotstyleHandle(int plotstyleHandle) {
178
		this.plotstyleHandle = plotstyleHandle;
179
	}
185 180
}

Also available in: Unified diff