svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / objects / DwgBlockHeader.java @ 28969
History | View | Annotate | Download (9.87 KB)
1 |
/* jdwglib. Java Library for reading Dwg files.
|
---|---|
2 |
*
|
3 |
* Author: Jose Morell Rama (jose.morell@gmail.com).
|
4 |
* Port from the Pythoncad Dwg library by Art Haas.
|
5 |
*
|
6 |
* Copyright (C) 2005 Jose Morell, IVER TI S.A. and Generalitat Valenciana
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Jose Morell (jose.morell@gmail.com)
|
25 |
*
|
26 |
* or
|
27 |
*
|
28 |
* IVER TI S.A.
|
29 |
* C/Salamanca, 50
|
30 |
* 46005 Valencia
|
31 |
* Spain
|
32 |
* +34 963163400
|
33 |
* dac@iver.es
|
34 |
*/
|
35 |
package org.gvsig.dwg.lib.objects; |
36 |
|
37 |
import java.util.ArrayList; |
38 |
|
39 |
import org.gvsig.dwg.lib.DwgHandleReference; |
40 |
import org.gvsig.dwg.lib.DwgObject; |
41 |
import org.gvsig.dwg.lib.IDwg3DTestable; |
42 |
|
43 |
|
44 |
/**
|
45 |
* The DwgBlockHeader class represents a DWG Block header
|
46 |
*
|
47 |
* @author jmorell, azabala
|
48 |
*/
|
49 |
public class DwgBlockHeader extends DwgObject implements IDwg3DTestable { |
50 |
private String name; |
51 |
private boolean flag64; |
52 |
private int xRefPlus; |
53 |
private boolean xdep; |
54 |
private boolean anonymous; |
55 |
private boolean hasAttrs; |
56 |
|
57 |
//TODO REVISAR COMO TRATAR UN BLOQUE CUANDO ES UNA REFERENCIA
|
58 |
//EXTERNA (DwgFile.blockManagement() )
|
59 |
private boolean blkIsXRef; |
60 |
private boolean xRefOverLaid; |
61 |
private boolean loaded; |
62 |
private double[] basePoint; |
63 |
private String xRefPName; |
64 |
private String blockDescription; |
65 |
private int previewData; |
66 |
|
67 |
private DwgHandleReference blockControlHandle;
|
68 |
private DwgHandleReference nullHandle;
|
69 |
private DwgHandleReference blockEntityHandle;
|
70 |
private DwgHandleReference firstEntityHandle;
|
71 |
private DwgHandleReference lastEntityHandle;
|
72 |
private DwgHandleReference endBlkEntityHandle;
|
73 |
|
74 |
|
75 |
private DwgHandleReference[] insertHandles; |
76 |
|
77 |
private DwgHandleReference layoutHandle;
|
78 |
private ArrayList objects; |
79 |
private ArrayList ownedObjectsHandles; //For R2004+ |
80 |
|
81 |
/**
|
82 |
* Create new DwgBlockHeader object
|
83 |
*/
|
84 |
public DwgBlockHeader(int index) { |
85 |
super(index);
|
86 |
objects = new ArrayList(); |
87 |
ownedObjectsHandles = new ArrayList(); |
88 |
} |
89 |
|
90 |
/**
|
91 |
* @return Returns the basePoint.
|
92 |
*/
|
93 |
public double[] getBasePoint() { |
94 |
return basePoint;
|
95 |
} |
96 |
/**
|
97 |
* @param basePoint The basePoint to set.
|
98 |
*/
|
99 |
public void setBasePoint(double[] basePoint) { |
100 |
this.basePoint = basePoint;
|
101 |
} |
102 |
/**
|
103 |
* @return Returns the firstEntityHandle.
|
104 |
*/
|
105 |
public DwgHandleReference getFirstEntityHandle() {
|
106 |
return firstEntityHandle;
|
107 |
} |
108 |
/**
|
109 |
* @param firstEntityHandle The firstEntityHandle to set.
|
110 |
*/
|
111 |
public void setFirstEntityHandle(DwgHandleReference firstEntityHandle) { |
112 |
this.firstEntityHandle = firstEntityHandle;
|
113 |
} |
114 |
/**
|
115 |
* @return Returns the lastEntityHandle.
|
116 |
*/
|
117 |
public DwgHandleReference getLastEntityHandle() {
|
118 |
return lastEntityHandle;
|
119 |
} |
120 |
/**
|
121 |
* @param lastEntityHandle The lastEntityHandle to set.
|
122 |
*/
|
123 |
public void setLastEntityHandle(DwgHandleReference lastEntityHandle) { |
124 |
this.lastEntityHandle = lastEntityHandle;
|
125 |
} |
126 |
/**
|
127 |
* @return Returns the name.
|
128 |
*/
|
129 |
public String getName() { |
130 |
return name;
|
131 |
} |
132 |
/**
|
133 |
* @param name The name to set.
|
134 |
*/
|
135 |
public void setName(String name) { |
136 |
this.name = name;
|
137 |
} |
138 |
/**
|
139 |
* @return Returns the blockEntityHandle.
|
140 |
*/
|
141 |
public DwgHandleReference getBlockEntityHandle() {
|
142 |
return blockEntityHandle;
|
143 |
} |
144 |
/**
|
145 |
* @param blockEntityHandle The blockEntityHandle to set.
|
146 |
*/
|
147 |
public void setBlockEntityHandle(DwgHandleReference blockEntityHandle) { |
148 |
this.blockEntityHandle = blockEntityHandle;
|
149 |
} |
150 |
/**
|
151 |
* @return Returns the anonymous.
|
152 |
*/
|
153 |
public boolean isAnonymous() { |
154 |
return anonymous;
|
155 |
} |
156 |
/**
|
157 |
* @param anonymous The anonymous to set.
|
158 |
*/
|
159 |
public void setAnonymous(boolean anonymous) { |
160 |
this.anonymous = anonymous;
|
161 |
} |
162 |
/**
|
163 |
* @return Returns the blkIsXRef.
|
164 |
*/
|
165 |
public boolean isBlkIsXRef() { |
166 |
return blkIsXRef;
|
167 |
} |
168 |
/**
|
169 |
* @param blkIsXRef The blkIsXRef to set.
|
170 |
*/
|
171 |
public void setBlkIsXRef(boolean blkIsXRef) { |
172 |
this.blkIsXRef = blkIsXRef;
|
173 |
} |
174 |
/**
|
175 |
* @return Returns the blockControlHandle.
|
176 |
*/
|
177 |
public DwgHandleReference getBlockControlHandle() {
|
178 |
return blockControlHandle;
|
179 |
} |
180 |
/**
|
181 |
* @param blockControlHandle The blockControlHandle to set.
|
182 |
*/
|
183 |
public void setBlockControlHandle(DwgHandleReference blockControlHandle) { |
184 |
this.blockControlHandle = blockControlHandle;
|
185 |
} |
186 |
/**
|
187 |
* @return Returns the blockDescription.
|
188 |
*/
|
189 |
public String getBlockDescription() { |
190 |
return blockDescription;
|
191 |
} |
192 |
/**
|
193 |
* @param blockDescription The blockDescription to set.
|
194 |
*/
|
195 |
public void setBlockDescription(String blockDescription) { |
196 |
this.blockDescription = blockDescription;
|
197 |
} |
198 |
/**
|
199 |
* @return Returns the endBlkEntityHandle.
|
200 |
*/
|
201 |
public DwgHandleReference getEndBlkEntityHandle() {
|
202 |
return endBlkEntityHandle;
|
203 |
} |
204 |
/**
|
205 |
* @param endBlkEntityHandle The endBlkEntityHandle to set.
|
206 |
*/
|
207 |
public void setEndBlkEntityHandle(DwgHandleReference endBlkEntityHandle) { |
208 |
this.endBlkEntityHandle = endBlkEntityHandle;
|
209 |
} |
210 |
/**
|
211 |
* @return Returns the flag64.
|
212 |
*/
|
213 |
public boolean isFlag64() { |
214 |
return flag64;
|
215 |
} |
216 |
/**
|
217 |
* @param flag64 The flag64 to set.
|
218 |
*/
|
219 |
public void setFlag64(boolean flag64) { |
220 |
this.flag64 = flag64;
|
221 |
} |
222 |
/**
|
223 |
* @return Returns the hasAttrs.
|
224 |
*/
|
225 |
public boolean isHasAttrs() { |
226 |
return hasAttrs;
|
227 |
} |
228 |
/**
|
229 |
* @param hasAttrs The hasAttrs to set.
|
230 |
*/
|
231 |
public void setHasAttrs(boolean hasAttrs) { |
232 |
this.hasAttrs = hasAttrs;
|
233 |
} |
234 |
/**
|
235 |
* @return Returns the insertHandles.
|
236 |
*/
|
237 |
public DwgHandleReference[] getInsertHandles() { |
238 |
return insertHandles;
|
239 |
} |
240 |
/**
|
241 |
* @param insertHandles The insertHandles to set.
|
242 |
*/
|
243 |
public void setInsertHandles(DwgHandleReference[] insertHandles) { |
244 |
this.insertHandles = insertHandles;
|
245 |
} |
246 |
/**
|
247 |
* @return Returns the layoutHandle.
|
248 |
*/
|
249 |
public DwgHandleReference getLayoutHandle() {
|
250 |
return layoutHandle;
|
251 |
} |
252 |
/**
|
253 |
* @param handle The layoutHandle to set.
|
254 |
*/
|
255 |
public void setLayoutHandle(DwgHandleReference handle) { |
256 |
this.layoutHandle = handle;
|
257 |
} |
258 |
/**
|
259 |
* @return Returns the loaded.
|
260 |
*/
|
261 |
public boolean isLoaded() { |
262 |
return loaded;
|
263 |
} |
264 |
/**
|
265 |
* @param loaded The loaded to set.
|
266 |
*/
|
267 |
public void setLoaded(boolean loaded) { |
268 |
this.loaded = loaded;
|
269 |
} |
270 |
/**
|
271 |
* @return Returns the nullHandle.
|
272 |
*/
|
273 |
public DwgHandleReference getNullHandle() {
|
274 |
return nullHandle;
|
275 |
} |
276 |
/**
|
277 |
* @param nullHandle The nullHandle to set.
|
278 |
*/
|
279 |
public void setNullHandle(DwgHandleReference nullHandle) { |
280 |
this.nullHandle = nullHandle;
|
281 |
} |
282 |
/**
|
283 |
* @return Returns the previewData.
|
284 |
*/
|
285 |
public int getPreviewData() { |
286 |
return previewData;
|
287 |
} |
288 |
/**
|
289 |
* @param previewData The previewData to set.
|
290 |
*/
|
291 |
public void setPreviewData(int previewData) { |
292 |
this.previewData = previewData;
|
293 |
} |
294 |
/**
|
295 |
* @return Returns the xdep.
|
296 |
*/
|
297 |
public boolean isXdep() { |
298 |
return xdep;
|
299 |
} |
300 |
/**
|
301 |
* @param xdep The xdep to set.
|
302 |
*/
|
303 |
public void setXdep(boolean xdep) { |
304 |
this.xdep = xdep;
|
305 |
} |
306 |
/**
|
307 |
* @return Returns the xRefOverLaid.
|
308 |
*/
|
309 |
public boolean isXRefOverLaid() { |
310 |
return xRefOverLaid;
|
311 |
} |
312 |
/**
|
313 |
* @param refOverLaid The xRefOverLaid to set.
|
314 |
*/
|
315 |
public void setXRefOverLaid(boolean refOverLaid) { |
316 |
xRefOverLaid = refOverLaid; |
317 |
} |
318 |
/**
|
319 |
* @return Returns the xRefPlus.
|
320 |
*/
|
321 |
public int getXRefPlus() { |
322 |
return xRefPlus;
|
323 |
} |
324 |
/**
|
325 |
* @param refPlus The xRefPlus to set.
|
326 |
*/
|
327 |
public void setXRefPlus(int refPlus) { |
328 |
xRefPlus = refPlus; |
329 |
} |
330 |
/**
|
331 |
* @return Returns the xRefPName.
|
332 |
*/
|
333 |
public String getXRefPName() { |
334 |
return xRefPName;
|
335 |
} |
336 |
/**
|
337 |
* @param refPName The xRefPName to set.
|
338 |
*/
|
339 |
public void setXRefPName(String refPName) { |
340 |
xRefPName = refPName; |
341 |
} |
342 |
/**
|
343 |
* @return Returns the objects.
|
344 |
*/
|
345 |
public ArrayList getObjects() { |
346 |
return objects;
|
347 |
} |
348 |
/**
|
349 |
* @param objects The objects to set.
|
350 |
*/
|
351 |
public void setObjects(ArrayList objects) { |
352 |
this.objects = objects;
|
353 |
} |
354 |
/**
|
355 |
* Add a DWG object to the blockObjects vector
|
356 |
*
|
357 |
* @param object DWG object
|
358 |
*/
|
359 |
public void addObject(DwgObject object) { |
360 |
this.objects.add(object);
|
361 |
} |
362 |
|
363 |
/**
|
364 |
* @return Returns the owned objects handles.
|
365 |
*/
|
366 |
public ArrayList getOwnedObjectsHandles() { |
367 |
return ownedObjectsHandles;
|
368 |
} |
369 |
/**
|
370 |
* @param objects The owned objects handles to set.
|
371 |
*/
|
372 |
public void setOwnedObjectsHandles(ArrayList handles) { |
373 |
this.ownedObjectsHandles = handles;
|
374 |
} |
375 |
/**
|
376 |
* Add a handle to the ownedBbjectsHandle vector
|
377 |
*
|
378 |
* @param handle handle
|
379 |
*/
|
380 |
public void addOwnedObjectHandle(DwgHandleReference handle) { |
381 |
this.ownedObjectsHandles.add(handle);
|
382 |
} |
383 |
|
384 |
|
385 |
/* (non-Javadoc)
|
386 |
* @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
|
387 |
*/
|
388 |
public boolean has3DData() { |
389 |
return (getBasePoint()[2] != 0.0); |
390 |
} |
391 |
public double getZ() { |
392 |
return getBasePoint()[2]; |
393 |
} |
394 |
public Object clone(){ |
395 |
DwgBlockHeader obj = new DwgBlockHeader(index);
|
396 |
this.fill(obj);
|
397 |
return obj;
|
398 |
} |
399 |
|
400 |
protected void fill(DwgObject obj){ |
401 |
super.fill(obj);
|
402 |
DwgBlockHeader myObj = (DwgBlockHeader)obj; |
403 |
|
404 |
myObj.setAnonymous(anonymous); |
405 |
myObj.setBasePoint(basePoint); |
406 |
myObj.setBlkIsXRef(blkIsXRef); |
407 |
myObj.setBlockControlHandle(blockControlHandle); |
408 |
myObj.setBlockDescription(blockDescription); |
409 |
myObj.setBlockEntityHandle(blockEntityHandle); |
410 |
myObj.setEndBlkEntityHandle(endBlkEntityHandle); |
411 |
myObj.setFirstEntityHandle(firstEntityHandle); |
412 |
myObj.setFlag64(flag64); |
413 |
myObj.setHasAttrs(hasAttrs); |
414 |
myObj.setInsertHandles(insertHandles); |
415 |
myObj.setLastEntityHandle(lastEntityHandle); |
416 |
myObj.setLayoutHandle(layoutHandle); |
417 |
myObj.setLoaded(loaded); |
418 |
myObj.setName(name); |
419 |
myObj.setNullHandle(nullHandle); |
420 |
myObj.setObjects(objects); |
421 |
myObj.setPreviewData(previewData); |
422 |
myObj.setXdep(xdep); |
423 |
myObj.setXRefOverLaid(xRefOverLaid); |
424 |
myObj.setXRefPlus(xRefPlus); |
425 |
myObj.setXRefPName(xRefPName); |
426 |
} |
427 |
|
428 |
} |