root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgAttrib.java @ 10632
History | View | Annotate | Download (8.5 KB)
1 | 2896 | jmorell | /* 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.objects; |
||
36 | |||
37 | import java.awt.geom.Point2D; |
||
38 | 7178 | azabala | import java.util.ArrayList; |
39 | 2896 | jmorell | |
40 | 10012 | fdiaz | import com.iver.cit.jdwglib.dwg.DwgHandleReference; |
41 | 2896 | jmorell | import com.iver.cit.jdwglib.dwg.DwgObject; |
42 | import com.iver.cit.jdwglib.dwg.DwgUtil; |
||
43 | 9825 | azabala | import com.iver.cit.jdwglib.dwg.IDwg3DTestable; |
44 | import com.iver.cit.jdwglib.dwg.IDwgExtrusionable; |
||
45 | import com.iver.cit.jdwglib.util.AcadExtrusionCalculator; |
||
46 | 2896 | jmorell | |
47 | /**
|
||
48 | * The DwgAttrib class represents a DWG Attrib
|
||
49 | *
|
||
50 | * @author jmorell
|
||
51 | */
|
||
52 | 9825 | azabala | public class DwgAttrib extends DwgObject |
53 | implements IDwgExtrusionable, IDwg3DTestable{
|
||
54 | 9718 | azabala | public DwgAttrib(int index) { |
55 | super(index);
|
||
56 | // TODO Auto-generated constructor stub
|
||
57 | } |
||
58 | 2896 | jmorell | private int dataFlag; |
59 | private double elevation; |
||
60 | private Point2D insertionPoint; |
||
61 | private Point2D alignmentPoint; |
||
62 | private double[] extrusion; |
||
63 | private double thickness; |
||
64 | private double obliqueAngle; |
||
65 | private double rotationAngle; |
||
66 | private double height; |
||
67 | private double widthFactor; |
||
68 | private String text; |
||
69 | private int generation; |
||
70 | private int halign; |
||
71 | private int valign; |
||
72 | private String tag; |
||
73 | private int fieldLength; |
||
74 | private int flags; |
||
75 | private String prompt; |
||
76 | 10012 | fdiaz | private DwgHandleReference styleHandle = null; |
77 | 2896 | jmorell | |
78 | 9927 | azabala | |
79 | 2896 | jmorell | /**
|
80 | * @return Returns the elevation.
|
||
81 | */
|
||
82 | public double getElevation() { |
||
83 | return elevation;
|
||
84 | } |
||
85 | /**
|
||
86 | * @param elevation The elevation to set.
|
||
87 | */
|
||
88 | public void setElevation(double elevation) { |
||
89 | this.elevation = elevation;
|
||
90 | } |
||
91 | /**
|
||
92 | * @return Returns the extrusion.
|
||
93 | */
|
||
94 | public double[] getExtrusion() { |
||
95 | return extrusion;
|
||
96 | } |
||
97 | /**
|
||
98 | * @return Returns the insertionPoint.
|
||
99 | */
|
||
100 | public Point2D getInsertionPoint() { |
||
101 | return insertionPoint;
|
||
102 | } |
||
103 | /**
|
||
104 | * @param insertionPoint The insertionPoint to set.
|
||
105 | */
|
||
106 | public void setInsertionPoint(Point2D insertionPoint) { |
||
107 | this.insertionPoint = insertionPoint;
|
||
108 | } |
||
109 | 10174 | fdiaz | |
110 | 2896 | jmorell | /**
|
111 | * @return Returns the alignmentPoint.
|
||
112 | */
|
||
113 | public Point2D getAlignmentPoint() { |
||
114 | return alignmentPoint;
|
||
115 | } |
||
116 | /**
|
||
117 | * @param alignmentPoint The alignmentPoint to set.
|
||
118 | */
|
||
119 | public void setAlignmentPoint(Point2D alignmentPoint) { |
||
120 | this.alignmentPoint = alignmentPoint;
|
||
121 | } |
||
122 | /**
|
||
123 | * @return Returns the dataFlag.
|
||
124 | */
|
||
125 | public int getDataFlag() { |
||
126 | return dataFlag;
|
||
127 | } |
||
128 | /**
|
||
129 | * @param dataFlag The dataFlag to set.
|
||
130 | */
|
||
131 | public void setDataFlag(int dataFlag) { |
||
132 | this.dataFlag = dataFlag;
|
||
133 | } |
||
134 | /**
|
||
135 | * @return Returns the fieldLength.
|
||
136 | */
|
||
137 | public int getFieldLength() { |
||
138 | return fieldLength;
|
||
139 | } |
||
140 | /**
|
||
141 | * @param fieldLength The fieldLength to set.
|
||
142 | */
|
||
143 | public void setFieldLength(int fieldLength) { |
||
144 | this.fieldLength = fieldLength;
|
||
145 | } |
||
146 | /**
|
||
147 | * @return Returns the flags.
|
||
148 | */
|
||
149 | public int getFlags() { |
||
150 | return flags;
|
||
151 | } |
||
152 | /**
|
||
153 | * @param flags The flags to set.
|
||
154 | */
|
||
155 | public void setFlags(int flags) { |
||
156 | this.flags = flags;
|
||
157 | } |
||
158 | /**
|
||
159 | * @return Returns the generation.
|
||
160 | */
|
||
161 | public int getGeneration() { |
||
162 | return generation;
|
||
163 | } |
||
164 | /**
|
||
165 | * @param generation The generation to set.
|
||
166 | */
|
||
167 | public void setGeneration(int generation) { |
||
168 | this.generation = generation;
|
||
169 | } |
||
170 | /**
|
||
171 | * @return Returns the halign.
|
||
172 | */
|
||
173 | public int getHalign() { |
||
174 | return halign;
|
||
175 | } |
||
176 | /**
|
||
177 | * @param halign The halign to set.
|
||
178 | */
|
||
179 | public void setHalign(int halign) { |
||
180 | this.halign = halign;
|
||
181 | } |
||
182 | /**
|
||
183 | * @return Returns the height.
|
||
184 | */
|
||
185 | public double getHeight() { |
||
186 | return height;
|
||
187 | } |
||
188 | /**
|
||
189 | * @param height The height to set.
|
||
190 | */
|
||
191 | public void setHeight(double height) { |
||
192 | this.height = height;
|
||
193 | } |
||
194 | /**
|
||
195 | * @return Returns the obliqueAngle.
|
||
196 | */
|
||
197 | public double getObliqueAngle() { |
||
198 | return obliqueAngle;
|
||
199 | } |
||
200 | /**
|
||
201 | * @param obliqueAngle The obliqueAngle to set.
|
||
202 | */
|
||
203 | public void setObliqueAngle(double obliqueAngle) { |
||
204 | this.obliqueAngle = obliqueAngle;
|
||
205 | } |
||
206 | /**
|
||
207 | * @return Returns the prompt.
|
||
208 | */
|
||
209 | public String getPrompt() { |
||
210 | return prompt;
|
||
211 | } |
||
212 | /**
|
||
213 | * @param prompt The prompt to set.
|
||
214 | */
|
||
215 | public void setPrompt(String prompt) { |
||
216 | this.prompt = prompt;
|
||
217 | } |
||
218 | /**
|
||
219 | * @return Returns the rotationAngle.
|
||
220 | */
|
||
221 | public double getRotationAngle() { |
||
222 | return rotationAngle;
|
||
223 | } |
||
224 | /**
|
||
225 | * @param rotationAngle The rotationAngle to set.
|
||
226 | */
|
||
227 | public void setRotationAngle(double rotationAngle) { |
||
228 | this.rotationAngle = rotationAngle;
|
||
229 | } |
||
230 | /**
|
||
231 | * @return Returns the styleHandle.
|
||
232 | */
|
||
233 | 10012 | fdiaz | public DwgHandleReference getStyleHandle() {
|
234 | 2896 | jmorell | return styleHandle;
|
235 | } |
||
236 | /**
|
||
237 | * @param styleHandle The styleHandle to set.
|
||
238 | */
|
||
239 | 10012 | fdiaz | public void setStyleHandle(DwgHandleReference styleHandle) { |
240 | 2896 | jmorell | this.styleHandle = styleHandle;
|
241 | } |
||
242 | /**
|
||
243 | * @return Returns the tag.
|
||
244 | */
|
||
245 | public String getTag() { |
||
246 | return tag;
|
||
247 | } |
||
248 | /**
|
||
249 | * @param tag The tag to set.
|
||
250 | */
|
||
251 | public void setTag(String tag) { |
||
252 | this.tag = tag;
|
||
253 | } |
||
254 | /**
|
||
255 | * @return Returns the text.
|
||
256 | */
|
||
257 | public String getText() { |
||
258 | return text;
|
||
259 | } |
||
260 | /**
|
||
261 | * @param text The text to set.
|
||
262 | */
|
||
263 | public void setText(String text) { |
||
264 | this.text = text;
|
||
265 | } |
||
266 | /**
|
||
267 | * @return Returns the thickness.
|
||
268 | */
|
||
269 | public double getThickness() { |
||
270 | return thickness;
|
||
271 | } |
||
272 | /**
|
||
273 | * @param thickness The thickness to set.
|
||
274 | */
|
||
275 | public void setThickness(double thickness) { |
||
276 | this.thickness = thickness;
|
||
277 | } |
||
278 | /**
|
||
279 | * @return Returns the valign.
|
||
280 | */
|
||
281 | public int getValign() { |
||
282 | return valign;
|
||
283 | } |
||
284 | /**
|
||
285 | * @param valign The valign to set.
|
||
286 | */
|
||
287 | public void setValign(int valign) { |
||
288 | this.valign = valign;
|
||
289 | } |
||
290 | /**
|
||
291 | * @return Returns the widthFactor.
|
||
292 | */
|
||
293 | public double getWidthFactor() { |
||
294 | return widthFactor;
|
||
295 | } |
||
296 | /**
|
||
297 | * @param widthFactor The widthFactor to set.
|
||
298 | */
|
||
299 | public void setWidthFactor(double widthFactor) { |
||
300 | this.widthFactor = widthFactor;
|
||
301 | } |
||
302 | /**
|
||
303 | * @param extrusion The extrusion to set.
|
||
304 | */
|
||
305 | public void setExtrusion(double[] extrusion) { |
||
306 | this.extrusion = extrusion;
|
||
307 | } |
||
308 | 9825 | azabala | /* (non-Javadoc)
|
309 | * @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion()
|
||
310 | */
|
||
311 | public void applyExtrussion() { |
||
312 | Point2D attribInsertionPoint = getInsertionPoint();
|
||
313 | 10599 | azabala | if(attribInsertionPoint == null){ |
314 | System.out.println("ATTRIB sin insertion point"); |
||
315 | return;
|
||
316 | } |
||
317 | 9825 | azabala | double attribElevation = getElevation();
|
318 | double[] attribInsertionPoint3D = new double[]{ |
||
319 | attribInsertionPoint.getX(), |
||
320 | attribInsertionPoint.getY(), |
||
321 | attribElevation}; |
||
322 | double[] attribExt = getExtrusion(); |
||
323 | attribInsertionPoint3D = AcadExtrusionCalculator. |
||
324 | 10319 | azabala | extrude2(attribInsertionPoint3D, attribExt); |
325 | 9825 | azabala | setInsertionPoint(new Point2D.Double(attribInsertionPoint3D[0], |
326 | attribInsertionPoint3D[1]));
|
||
327 | setElevation(attribInsertionPoint3D[2]);
|
||
328 | } |
||
329 | /* (non-Javadoc)
|
||
330 | * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
|
||
331 | */
|
||
332 | public boolean has3DData() { |
||
333 | return (getElevation() != 0.0); |
||
334 | } |
||
335 | 9830 | azabala | public double getZ() { |
336 | return getElevation();
|
||
337 | } |
||
338 | 10174 | fdiaz | /* (non-Javadoc)
|
339 | * @see java.lang.Object#clone()
|
||
340 | */
|
||
341 | public Object clone(){ |
||
342 | DwgAttrib obj = new DwgAttrib(index);
|
||
343 | this.fill(obj);
|
||
344 | return obj;
|
||
345 | } |
||
346 | |||
347 | protected void fill(DwgObject obj){ |
||
348 | super.fill(obj);
|
||
349 | DwgAttrib myObj = (DwgAttrib)obj; |
||
350 | |||
351 | myObj.setAlignmentPoint(alignmentPoint); |
||
352 | myObj.setDataFlag(dataFlag); |
||
353 | myObj.setElevation(elevation); |
||
354 | myObj.setExtrusion(extrusion); |
||
355 | myObj.setFieldLength(fieldLength); |
||
356 | myObj.setFlags(flags); |
||
357 | myObj.setGeneration(generation); |
||
358 | myObj.setHalign(halign); |
||
359 | myObj.setHeight(height); |
||
360 | myObj.setInsertionPoint(insertionPoint); |
||
361 | myObj.setObliqueAngle(obliqueAngle); |
||
362 | myObj.setPrompt(prompt); |
||
363 | myObj.setRotationAngle(rotationAngle); |
||
364 | myObj.setStyleHandle(styleHandle); |
||
365 | myObj.setTag(tag); |
||
366 | myObj.setText(text); |
||
367 | myObj.setThickness(thickness); |
||
368 | myObj.setValign(valign); |
||
369 | myObj.setWidthFactor(widthFactor); |
||
370 | } |
||
371 | |||
372 | 2896 | jmorell | } |