Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgAttrib.java @ 10539

History | View | Annotate | Download (8.39 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.objects;
36

    
37
import java.awt.geom.Point2D;
38
import java.util.ArrayList;
39

    
40
import com.iver.cit.jdwglib.dwg.DwgHandleReference;
41
import com.iver.cit.jdwglib.dwg.DwgObject;
42
import com.iver.cit.jdwglib.dwg.DwgUtil;
43
import com.iver.cit.jdwglib.dwg.IDwg3DTestable;
44
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable;
45
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator;
46

    
47
/**
48
 * The DwgAttrib class represents a DWG Attrib
49
 * 
50
 * @author jmorell
51
 */
52
public class DwgAttrib extends DwgObject 
53
implements IDwgExtrusionable, IDwg3DTestable{
54
        public DwgAttrib(int index) {
55
                super(index);
56
                // TODO Auto-generated constructor stub
57
        }
58
        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
        private DwgHandleReference styleHandle = null;
77
        
78
        
79
    /**
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

    
110
        /**
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
        public DwgHandleReference getStyleHandle() {
234
                return styleHandle;
235
        }
236
        /**
237
         * @param styleHandle The styleHandle to set.
238
         */
239
        public void setStyleHandle(DwgHandleReference styleHandle) {
240
                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
        /* (non-Javadoc)
309
         * @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion()
310
         */
311
        public void applyExtrussion() {
312
                  Point2D attribInsertionPoint = getInsertionPoint();
313
          double attribElevation = getElevation();
314
          double[] attribInsertionPoint3D = new double[]{
315
                          attribInsertionPoint.getX(), 
316
                                attribInsertionPoint.getY(), 
317
                                attribElevation};
318
          double[] attribExt = getExtrusion();
319
          attribInsertionPoint3D = AcadExtrusionCalculator.
320
                          extrude2(attribInsertionPoint3D, attribExt);
321
          setInsertionPoint(new Point2D.Double(attribInsertionPoint3D[0], 
322
                                                                                  attribInsertionPoint3D[1]));
323
         setElevation(attribInsertionPoint3D[2]);
324
        }
325
        /* (non-Javadoc)
326
         * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
327
         */
328
        public boolean has3DData() {
329
                return (getElevation() != 0.0);
330
        }
331
        public double getZ() {
332
                return getElevation();
333
        }
334
        /* (non-Javadoc)
335
         * @see java.lang.Object#clone()
336
         */
337
public Object clone(){
338
                DwgAttrib obj = new DwgAttrib(index);
339
                this.fill(obj);
340
                return obj;
341
        }
342
        
343
        protected void fill(DwgObject obj){
344
                super.fill(obj);
345
                DwgAttrib myObj = (DwgAttrib)obj;
346

    
347
                myObj.setAlignmentPoint(alignmentPoint);
348
                myObj.setDataFlag(dataFlag);
349
                myObj.setElevation(elevation);
350
                myObj.setExtrusion(extrusion);
351
                myObj.setFieldLength(fieldLength);
352
                myObj.setFlags(flags);
353
                myObj.setGeneration(generation);
354
                myObj.setHalign(halign);
355
                myObj.setHeight(height);
356
                myObj.setInsertionPoint(insertionPoint);
357
                myObj.setObliqueAngle(obliqueAngle);
358
                myObj.setPrompt(prompt);
359
                myObj.setRotationAngle(rotationAngle);
360
                myObj.setStyleHandle(styleHandle);
361
                myObj.setTag(tag);
362
                myObj.setText(text);
363
                myObj.setThickness(thickness);
364
                myObj.setValign(valign);
365
                myObj.setWidthFactor(widthFactor);
366
        }
367

    
368
}