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