root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / DwgObject.java @ 10311
History | View | Annotate | Download (9.61 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 com.iver.cit.jdwglib.dwg; |
36 |
|
37 |
import java.util.ArrayList; |
38 |
import java.util.List; |
39 |
|
40 |
/**
|
41 |
* The DwgObject class represents a DWG object
|
42 |
*
|
43 |
* @author jmorell
|
44 |
*/
|
45 |
public class DwgObject implements Cloneable{ |
46 |
protected int type; |
47 |
|
48 |
protected DwgHandleReference handle;
|
49 |
|
50 |
protected String version; |
51 |
|
52 |
protected int mode; |
53 |
|
54 |
/**
|
55 |
* code of the layer handle
|
56 |
*/
|
57 |
//protected int layerHandleCode;
|
58 |
|
59 |
/**
|
60 |
* layer handle as an integer
|
61 |
*/
|
62 |
protected DwgHandleReference layerHandle;
|
63 |
|
64 |
protected int color; |
65 |
|
66 |
protected int numReactors; |
67 |
|
68 |
protected boolean noLinks; |
69 |
|
70 |
protected int linetypeFlags; |
71 |
|
72 |
protected int plotstyleFlags; |
73 |
|
74 |
protected int sizeInBits; |
75 |
|
76 |
protected List extendedData; |
77 |
|
78 |
protected int graphicData; |
79 |
|
80 |
protected DwgHandleReference plotStyleHandle = null; |
81 |
|
82 |
protected DwgHandleReference subEntityHandle = null; |
83 |
|
84 |
protected DwgHandleReference xDicObjHandle = null; |
85 |
|
86 |
protected boolean graphicsFlag; |
87 |
|
88 |
/**
|
89 |
* Index of the dwg object in the object's map section
|
90 |
*
|
91 |
*/
|
92 |
protected int index = 0; |
93 |
|
94 |
/*
|
95 |
* Previous and Next Handle (this stuff has allowed us to solve the problem
|
96 |
* of layer handles
|
97 |
*/
|
98 |
private DwgHandleReference nextHandle = null; |
99 |
|
100 |
private DwgHandleReference previousHandle = null; |
101 |
|
102 |
//private ArrayList reactorsHandlesCodes = new ArrayList();
|
103 |
|
104 |
private ArrayList reactorsHandles = new ArrayList(); |
105 |
|
106 |
public DwgObject(int index) { |
107 |
this.index = index;
|
108 |
} |
109 |
|
110 |
public void setNextHandle(DwgHandleReference hr) { |
111 |
this.nextHandle = hr;
|
112 |
|
113 |
} |
114 |
|
115 |
public void setPreviousHandle(DwgHandleReference hr) { |
116 |
this.previousHandle = hr;
|
117 |
} |
118 |
|
119 |
/*
|
120 |
public void setReactorsHandles(ArrayList reactorsHandles) {
|
121 |
this.reactorsHandlesCodes=reactorsHandles;
|
122 |
}
|
123 |
*/
|
124 |
|
125 |
public void addReactorHandle(DwgHandleReference hr) { |
126 |
if (this.reactorsHandles == null){ |
127 |
this.reactorsHandles = new ArrayList(); |
128 |
} |
129 |
this.reactorsHandles.add(hr);
|
130 |
} |
131 |
|
132 |
|
133 |
public DwgHandleReference getNextHandle() {
|
134 |
return this.nextHandle; |
135 |
|
136 |
} |
137 |
|
138 |
public DwgHandleReference getPreviousHandle() {
|
139 |
return this.previousHandle; |
140 |
} |
141 |
|
142 |
public ArrayList getReactorsHandles() { |
143 |
return this.reactorsHandles; |
144 |
} |
145 |
|
146 |
//TODO Todo esto no vale si handle puede tomar valor -1
|
147 |
public boolean hasLayerHandle() { |
148 |
return this.layerHandle != null; |
149 |
} |
150 |
public boolean hasNextHandle() { |
151 |
return this.nextHandle != null; |
152 |
} |
153 |
|
154 |
public boolean hasPreviousHandle() { |
155 |
return this.previousHandle != null; |
156 |
} |
157 |
|
158 |
public boolean hasSubEntityHandle(){ |
159 |
return this.subEntityHandle != null; |
160 |
} |
161 |
|
162 |
public boolean hasXDicObjHandle(){ |
163 |
return this.xDicObjHandle != null; |
164 |
} |
165 |
|
166 |
public boolean hasReactorsHandles(){ |
167 |
return this.reactorsHandles.size() != 0; |
168 |
} |
169 |
|
170 |
public int reactorsHandlesQuantity(){ |
171 |
return this.reactorsHandles.size(); |
172 |
} |
173 |
|
174 |
public int getIndex() { |
175 |
return index;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* @return Returns the sizeInBits.
|
180 |
*/
|
181 |
public int getSizeInBits() { |
182 |
return sizeInBits;
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* @param sizeInBits
|
187 |
* The sizeInBits to set.
|
188 |
*/
|
189 |
public void setSizeInBits(int sizeInBits) { |
190 |
this.sizeInBits = sizeInBits;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* @return Returns the extendedData.
|
195 |
*/
|
196 |
public List getExtendedData() { |
197 |
return extendedData;
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* @param extData
|
202 |
* The extendedData to set.
|
203 |
*/
|
204 |
public void setExtendedData(List extData) { |
205 |
this.extendedData = extData;
|
206 |
} |
207 |
|
208 |
/**
|
209 |
* @return Returns the graphicData.
|
210 |
*/
|
211 |
public int getGraphicData() { |
212 |
return graphicData;
|
213 |
} |
214 |
|
215 |
/**
|
216 |
* @param graphicData
|
217 |
* The graphicData to set.
|
218 |
*/
|
219 |
public void setGraphicData(int graphicData) { |
220 |
this.graphicData = graphicData;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* @return Returns the version.
|
225 |
*/
|
226 |
public String getVersion() { |
227 |
return version;
|
228 |
} |
229 |
|
230 |
/**
|
231 |
* @param linetypeFlags
|
232 |
* The linetypeFlags to set.
|
233 |
*/
|
234 |
public void setLinetypeFlags(int linetypeFlags) { |
235 |
this.linetypeFlags = linetypeFlags;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* @param plotstyleFlags
|
240 |
* The plotstyleFlags to set.
|
241 |
*/
|
242 |
public void setPlotstyleFlags(int plotstyleFlags) { |
243 |
this.plotstyleFlags = plotstyleFlags;
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* @return Returns the subEntityHandle.
|
248 |
*/
|
249 |
public DwgHandleReference getSubEntityHandle() {
|
250 |
return subEntityHandle;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* @param subEntityHandle
|
255 |
* The subEntityHandle to set.
|
256 |
*/
|
257 |
public void setSubEntityHandle(DwgHandleReference subEntityHandle) { |
258 |
this.subEntityHandle = subEntityHandle;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
* @return Returns the xDicObjHandle.
|
263 |
*/
|
264 |
public DwgHandleReference getXDicObjHandle() {
|
265 |
return xDicObjHandle;
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* @param dicObjHandle
|
270 |
* The xDicObjHandle to set.
|
271 |
*/
|
272 |
public void setXDicObjHandle(DwgHandleReference dicObjHandle) { |
273 |
xDicObjHandle = dicObjHandle; |
274 |
} |
275 |
|
276 |
/**
|
277 |
* @return Returns the color.
|
278 |
*/
|
279 |
public int getColor() { |
280 |
return color;
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* @param color
|
285 |
* The color to set.
|
286 |
*/
|
287 |
public void setColor(int color) { |
288 |
this.color = color;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* @return Returns the handle.
|
293 |
*/
|
294 |
public DwgHandleReference getHandle() {
|
295 |
return handle;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* @param handle
|
300 |
* The handle to set.
|
301 |
*/
|
302 |
public void setHandle(DwgHandleReference handle) { |
303 |
this.handle = handle;
|
304 |
} |
305 |
|
306 |
/**
|
307 |
* @return Returns the layerHandle.
|
308 |
*/
|
309 |
public DwgHandleReference getLayerHandle() {
|
310 |
return layerHandle;
|
311 |
} |
312 |
|
313 |
/**
|
314 |
* @param layerHandle
|
315 |
* The layerHandle to set.
|
316 |
*/
|
317 |
public void setLayerHandle(DwgHandleReference layerHandle) { |
318 |
this.layerHandle = layerHandle;
|
319 |
} |
320 |
|
321 |
/**
|
322 |
* @return Returns the mode.
|
323 |
*/
|
324 |
public int getMode() { |
325 |
return mode;
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* @param mode
|
330 |
* The mode to set.
|
331 |
*/
|
332 |
public void setMode(int mode) { |
333 |
this.mode = mode;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* @return Returns the noLinks.
|
338 |
*/
|
339 |
public boolean isNoLinks() { |
340 |
return noLinks;
|
341 |
} |
342 |
|
343 |
/**
|
344 |
* @param noLinks
|
345 |
* The noLinks to set.
|
346 |
*/
|
347 |
public void setNoLinks(boolean noLinks) { |
348 |
this.noLinks = noLinks;
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* @return Returns the numReactors.
|
353 |
*/
|
354 |
public int getNumReactors() { |
355 |
return numReactors;
|
356 |
} |
357 |
|
358 |
/**
|
359 |
* @param numReactors
|
360 |
* The numReactors to set.
|
361 |
*/
|
362 |
public void setNumReactors(int numReactors) { |
363 |
this.numReactors = numReactors;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* @return Returns the type.
|
368 |
*/
|
369 |
public int getType() { |
370 |
return type;
|
371 |
} |
372 |
|
373 |
/**
|
374 |
* @param type
|
375 |
* The type to set.
|
376 |
*/
|
377 |
public void setType(int type) { |
378 |
this.type = type;
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* @return Returns the linetypeFlags.
|
383 |
*/
|
384 |
public int getLinetypeFlags() { |
385 |
return linetypeFlags;
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* @return Returns the plotstyleFlags.
|
390 |
*/
|
391 |
public int getPlotstyleFlags() { |
392 |
return plotstyleFlags;
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* @param version
|
397 |
* The version to set.
|
398 |
*/
|
399 |
public void setVersion(String version) { |
400 |
this.version = version;
|
401 |
} |
402 |
|
403 |
/**
|
404 |
* @return Returns the graphicsFlag.
|
405 |
*/
|
406 |
public boolean isGraphicsFlag() { |
407 |
return graphicsFlag;
|
408 |
} |
409 |
|
410 |
/**
|
411 |
* @param graphicsFlag
|
412 |
* The graphicsFlag to set.
|
413 |
*/
|
414 |
public void setGraphicsFlag(boolean graphicsFlag) { |
415 |
this.graphicsFlag = graphicsFlag;
|
416 |
} |
417 |
|
418 |
/*
|
419 |
* This property exists in 13-14 versions, but not in 2000 version
|
420 |
*/
|
421 |
private boolean lyrByLineType = false; |
422 |
|
423 |
public void setLyrByLineType(boolean lyrByLineType) { |
424 |
this.lyrByLineType = lyrByLineType;
|
425 |
} |
426 |
|
427 |
public boolean isLyrByLineType() { |
428 |
return lyrByLineType;
|
429 |
} |
430 |
|
431 |
public void setPlotStyleHandle(DwgHandleReference hr) { |
432 |
this.plotStyleHandle = hr;
|
433 |
|
434 |
} |
435 |
|
436 |
public boolean hasPlotStyleHandle() { |
437 |
return this.plotStyleHandle != null; |
438 |
} |
439 |
|
440 |
/*
|
441 |
* Esto solo se usa para la version 13-14
|
442 |
*/
|
443 |
private DwgHandleReference lineTypeHandle = null; |
444 |
|
445 |
/**
|
446 |
* Sets the handle of the line type of this drawing entity.
|
447 |
*
|
448 |
* TODO Ver si conviene guardar tambien el handleCode de este handle
|
449 |
*
|
450 |
* @param handle2
|
451 |
*/
|
452 |
public void setLineTypeHandle(DwgHandleReference hr) { |
453 |
this.lineTypeHandle = hr;
|
454 |
|
455 |
} |
456 |
|
457 |
public DwgHandleReference getLineTypeHandle() {
|
458 |
return this.lineTypeHandle; |
459 |
} |
460 |
|
461 |
public boolean hasLineTypeHandle() { |
462 |
return this.lineTypeHandle != null; |
463 |
} |
464 |
|
465 |
|
466 |
public Object clone(){ |
467 |
DwgObject obj = new DwgObject(this.index); |
468 |
this.fill(obj);
|
469 |
return obj;
|
470 |
} |
471 |
|
472 |
protected void fill(DwgObject obj){ |
473 |
|
474 |
obj.setColor(color); |
475 |
obj.setExtendedData(extendedData); |
476 |
obj.setGraphicData(graphicData); |
477 |
obj.setGraphicsFlag(graphicsFlag); |
478 |
obj.setHandle(handle); |
479 |
obj.setLayerHandle(layerHandle); |
480 |
obj.setLinetypeFlags(linetypeFlags); |
481 |
obj.setLineTypeHandle(lineTypeHandle); |
482 |
obj.setLyrByLineType(lyrByLineType); |
483 |
obj.setMode(mode); |
484 |
obj.setNextHandle(nextHandle); |
485 |
obj.setNoLinks(noLinks); |
486 |
obj.setNumReactors(numReactors); |
487 |
obj.setPlotstyleFlags(plotstyleFlags); |
488 |
obj.setPlotStyleHandle(plotStyleHandle); |
489 |
obj.setPreviousHandle(previousHandle); |
490 |
obj.setSizeInBits(sizeInBits); |
491 |
obj.setSubEntityHandle(subEntityHandle); |
492 |
obj.setType(type); |
493 |
obj.setVersion(version); |
494 |
obj.setXDicObjHandle(xDicObjHandle); |
495 |
|
496 |
} |
497 |
} |