Statistics
| Revision:

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

History | View | Annotate | Download (7.09 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.IGeometry;
40
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
41
import com.iver.cit.jdwglib.dwg.DwgHandleReference;
42
import com.iver.cit.jdwglib.dwg.DwgObject;
43
import com.iver.cit.jdwglib.dwg.IDwg2FMap;
44
import com.iver.cit.jdwglib.dwg.IDwg3DTestable;
45
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable;
46
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator;
47

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

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

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

    
299
}