Statistics
| Revision:

root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgMText.java @ 10319

History | View | Annotate | Download (7 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 com.iver.cit.gvsig.fmap.core.FPoint2D;
38
import com.iver.cit.gvsig.fmap.core.FPoint3D;
39
import com.iver.cit.gvsig.fmap.core.FShape;
40
import com.iver.cit.jdwglib.dwg.DwgHandleReference;
41
import com.iver.cit.jdwglib.dwg.DwgObject;
42
import com.iver.cit.jdwglib.dwg.IDwg2FMap;
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 DwgMText class represents a DWG MText
49
 * 
50
 * @author jmorell, azabala
51
 */
52
public class DwgMText extends DwgObject 
53
        implements IDwgExtrusionable, IDwg3DTestable, IDwg2FMap {
54
        public DwgMText(int index) {
55
                super(index);
56
                // TODO Auto-generated constructor stub
57
        }
58
        private double[] insertionPoint;
59
        private double[] extrusion;
60
        private double[] xAxisDirection;
61
        private double width;
62
        private double height;
63
        private int attachment;
64
        private int drawingDir;
65
        private double extHeight;
66
        private double extWidth;
67
        private String text;
68
        private int lineSpacingStyle;
69
        private double lineSpacingFactor;
70
        private DwgHandleReference styleHandle = null;
71
        
72
        
73
        /**
74
         * @return Returns the height.
75
         */
76
        public double getHeight() {
77
                return height;
78
        }
79
        /**
80
         * @param height The height to set.
81
         */
82
        public void setHeight(double height) {
83
                this.height = height;
84
        }
85
        /**
86
         * @return Returns the insertionPoint.
87
         */
88
        public double[] getInsertionPoint() {
89
                return insertionPoint;
90
        }
91
        /**
92
         * @param insertionPoint The insertionPoint to set.
93
         */
94
        public void setInsertionPoint(double[] insertionPoint) {
95
                this.insertionPoint = insertionPoint;
96
        }
97
        /**
98
         * @return Returns the text.
99
         */
100
        public String getText() {
101
                return text;
102
        }
103
        /**
104
         * @param text The text to set.
105
         */
106
        public void setText(String text) {
107
                this.text = text;
108
        }
109
        /**
110
         * @return Returns the width.
111
         */
112
        public double getWidth() {
113
                return width;
114
        }
115
        /**
116
         * @param width The width to set.
117
         */
118
        public void setWidth(double width) {
119
                this.width = width;
120
        }
121
    /**
122
     * @return Returns the extrusion.
123
     */
124
    public double[] getExtrusion() {
125
        return extrusion;
126
    }
127

    
128
    /**
129
         * @return Returns the attachment.
130
         */
131
        public int getAttachment() {
132
                return attachment;
133
        }
134
        /**
135
         * @param attachment The attachment to set.
136
         */
137
        public void setAttachment(int attachment) {
138
                this.attachment = attachment;
139
        }
140
        /**
141
         * @return Returns the drawingDir.
142
         */
143
        public int getDrawingDir() {
144
                return drawingDir;
145
        }
146
        /**
147
         * @param drawingDir The drawingDir to set.
148
         */
149
        public void setDrawingDir(int drawingDir) {
150
                this.drawingDir = drawingDir;
151
        }
152
        /**
153
         * @return Returns the extHeight.
154
         */
155
        public double getExtHeight() {
156
                return extHeight;
157
        }
158
        /**
159
         * @param extHeight The extHeight to set.
160
         */
161
        public void setExtHeight(double extHeight) {
162
                this.extHeight = extHeight;
163
        }
164
        /**
165
         * @return Returns the extWidth.
166
         */
167
        public double getExtWidth() {
168
                return extWidth;
169
        }
170
        /**
171
         * @param extWidth The extWidth to set.
172
         */
173
        public void setExtWidth(double extWidth) {
174
                this.extWidth = extWidth;
175
        }
176
        /**
177
         * @return Returns the lineSpacingFactor.
178
         */
179
        public double getLineSpacingFactor() {
180
                return lineSpacingFactor;
181
        }
182
        /**
183
         * @param lineSpacingFactor The lineSpacingFactor to set.
184
         */
185
        public void setLineSpacingFactor(double lineSpacingFactor) {
186
                this.lineSpacingFactor = lineSpacingFactor;
187
        }
188
        /**
189
         * @return Returns the lineSpacingStyle.
190
         */
191
        public int getLineSpacingStyle() {
192
                return lineSpacingStyle;
193
        }
194
        /**
195
         * @param lineSpacingStyle The lineSpacingStyle to set.
196
         */
197
        public void setLineSpacingStyle(int lineSpacingStyle) {
198
                this.lineSpacingStyle = lineSpacingStyle;
199
        }
200
        /**
201
         * @return Returns the styleHandle.
202
         */
203
        public DwgHandleReference getStyleHandle() {
204
                return styleHandle;
205
        }
206
        /**
207
         * @param styleHandle The styleHandle to set.
208
         */
209
        public void setStyleHandle(DwgHandleReference styleHandle) {
210
                this.styleHandle = styleHandle;
211
        }
212
        /**
213
         * @return Returns the xAxisDirection.
214
         */
215
        public double[] getXAxisDirection() {
216
                return xAxisDirection;
217
        }
218
        /**
219
         * @param axisDirection The xAxisDirection to set.
220
         */
221
        public void setXAxisDirection(double[] axisDirection) {
222
                xAxisDirection = axisDirection;
223
        }
224
        /**
225
         * @param extrusion The extrusion to set.
226
         */
227
        public void setExtrusion(double[] extrusion) {
228
                this.extrusion = extrusion;
229
        }
230
        /* (non-Javadoc)
231
         * @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion()
232
         */
233
        public void applyExtrussion() {
234
                 double[] mtextPoint = getInsertionPoint();
235
         double[] mtextExt = getExtrusion();
236
         mtextPoint = AcadExtrusionCalculator.extrude2(mtextPoint, mtextExt);
237
         setInsertionPoint(mtextPoint);
238
        }
239
        /* (non-Javadoc)
240
         * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
241
         */
242
        public boolean has3DData() {
243
                return (getInsertionPoint()[2] != 0.0);
244
        }
245
        public double getZ() {
246
                return getInsertionPoint()[2];
247
        }
248
        
249
        public FShape toFMapGeometry(boolean is3DFile) {
250
                FPoint2D fPoint = null;
251
                double[] p = getInsertionPoint();
252
                if (is3DFile) {
253
                        fPoint = new FPoint3D(p[0], p[1], p[2]);
254
                } else {
255
                        fPoint = new FPoint2D(p[0], p[1]);
256
                }
257
                return fPoint;
258
        }
259
        public String toFMapString(boolean is3DFile) {
260
                if(is3DFile)
261
                        return "FPoint3D";
262
                else
263
                        return "FPoint2D";
264
        }
265
        
266
        public String toString(){
267
                return "MText";
268
        }
269
        
270
        /* (non-Javadoc)
271
         * @see java.lang.Object#clone()
272
         */
273
        public Object clone(){
274
                DwgMText obj = new DwgMText(index);
275
                this.fill(obj);
276
                return obj;
277
        }
278
        
279
        protected void fill(DwgObject obj){
280
                super.fill(obj);
281
                DwgMText myObj = (DwgMText)obj;
282

    
283
                myObj.setAttachment(attachment);
284
                myObj.setDrawingDir(drawingDir);
285
                myObj.setExtHeight(extHeight);
286
                myObj.setExtrusion(extrusion);
287
                myObj.setExtWidth(extWidth);
288
                myObj.setHeight(extHeight);
289
                myObj.setInsertionPoint(insertionPoint);
290
                myObj.setLineSpacingFactor(lineSpacingFactor);
291
                myObj.setLineSpacingStyle(lineSpacingStyle);
292
                myObj.setStyleHandle(styleHandle);
293
                myObj.setText(text);
294
                myObj.setWidth(width);
295
                myObj.setXAxisDirection(xAxisDirection);
296
        }
297

    
298
}