Statistics
| Revision:

root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgEllipse.java @ 9718

History | View | Annotate | Download (6.44 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.util.ArrayList;
38
import java.util.Vector;
39

    
40
import com.iver.cit.jdwglib.dwg.DwgObject;
41
import com.iver.cit.jdwglib.dwg.DwgUtil;
42

    
43
/**
44
 * The DwgEllipse class represents a DWG Ellipse
45
 * 
46
 * @author jmorell
47
 */
48
public class DwgEllipse extends DwgObject {
49
        public DwgEllipse(int index) {
50
                super(index);
51
                // TODO Auto-generated constructor stub
52
        }
53
        private double[] center;
54
        private double[] majorAxisVector;
55
        private double[] extrusion;
56
        private double axisRatio;
57
        private double initAngle;
58
        private double endAngle;
59
        
60
        /**
61
         * Read a Ellipse in the DWG format Version 15
62
         * 
63
         * @param data Array of unsigned bytes obtained from the DWG binary file
64
         * @param offset The current bit offset where the value begins
65
         * @throws Exception If an unexpected bit value is found in the DWG file. Occurs
66
         *                    when we are looking for LwPolylines.
67
         */
68
        public void readDwgEllipseV15(int[] data, int offset) throws Exception {
69
                int bitPos = offset;
70
                bitPos = readObjectHeaderV15(data, bitPos);
71
                ArrayList v = DwgUtil.getBitDouble(data, bitPos);
72
                bitPos = ((Integer)v.get(0)).intValue();
73
                double x = ((Double)v.get(1)).doubleValue();
74
                v = DwgUtil.getBitDouble(data, bitPos);
75
                bitPos = ((Integer)v.get(0)).intValue();
76
                double y = ((Double)v.get(1)).doubleValue();
77
                v = DwgUtil.getBitDouble(data, bitPos);
78
                bitPos = ((Integer)v.get(0)).intValue();
79
                double z = ((Double)v.get(1)).doubleValue();
80
                double[] coord = new double[]{x, y, z};
81
                center = coord;
82
                v = DwgUtil.getBitDouble(data, bitPos);
83
                bitPos = ((Integer)v.get(0)).intValue();
84
                x = ((Double)v.get(1)).doubleValue();
85
                v = DwgUtil.getBitDouble(data, bitPos);
86
                bitPos = ((Integer)v.get(0)).intValue();
87
                y = ((Double)v.get(1)).doubleValue();
88
                v = DwgUtil.getBitDouble(data, bitPos);
89
                bitPos = ((Integer)v.get(0)).intValue();
90
                z = ((Double)v.get(1)).doubleValue();
91
                coord = new double[]{x, y, z};
92
                majorAxisVector = coord;
93
                v = DwgUtil.getBitDouble(data, bitPos);
94
                bitPos = ((Integer)v.get(0)).intValue();
95
                x = ((Double)v.get(1)).doubleValue();
96
                v = DwgUtil.getBitDouble(data, bitPos);
97
                bitPos = ((Integer)v.get(0)).intValue();
98
                y = ((Double)v.get(1)).doubleValue();
99
                v = DwgUtil.getBitDouble(data, bitPos);
100
                bitPos = ((Integer)v.get(0)).intValue();
101
                z = ((Double)v.get(1)).doubleValue();
102
                coord = new double[]{x, y, z};
103
                extrusion = coord;
104
                v = DwgUtil.getBitDouble(data, bitPos);
105
                bitPos = ((Integer)v.get(0)).intValue();
106
                double val = ((Double)v.get(1)).doubleValue();
107
                axisRatio = val;
108
                v = DwgUtil.getBitDouble(data, bitPos);
109
                bitPos = ((Integer)v.get(0)).intValue();
110
                val = ((Double)v.get(1)).doubleValue();
111
            initAngle = val;
112
                v = DwgUtil.getBitDouble(data, bitPos);
113
                bitPos = ((Integer)v.get(0)).intValue();
114
                val = ((Double)v.get(1)).doubleValue();
115
            endAngle = val;
116
                bitPos = readObjectTailV15(data, bitPos);
117
        }
118
    /**
119
     * @return Returns the axisRatio.
120
     */
121
    public double getAxisRatio() {
122
        return axisRatio;
123
    }
124
    /**
125
     * @param axisRatio The axisRatio to set.
126
     */
127
    public void setAxisRatio(double axisRatio) {
128
        this.axisRatio = axisRatio;
129
    }
130
    /**
131
     * @return Returns the center.
132
     */
133
    public double[] getCenter() {
134
        return center;
135
    }
136
    /**
137
     * @param center The center to set.
138
     */
139
    public void setCenter(double[] center) {
140
        this.center = center;
141
    }
142
    /**
143
     * @return Returns the endAngle.
144
     */
145
    public double getEndAngle() {
146
        return endAngle;
147
    }
148
    /**
149
     * @param endAngle The endAngle to set.
150
     */
151
    public void setEndAngle(double endAngle) {
152
        this.endAngle = endAngle;
153
    }
154
    /**
155
     * @return Returns the initAngle.
156
     */
157
    public double getInitAngle() {
158
        return initAngle;
159
    }
160
    /**
161
     * @param initAngle The initAngle to set.
162
     */
163
    public void setInitAngle(double initAngle) {
164
        this.initAngle = initAngle;
165
    }
166
    /**
167
     * @return Returns the majorAxisVector.
168
     */
169
    public double[] getMajorAxisVector() {
170
        return majorAxisVector;
171
    }
172
    /**
173
     * @param majorAxisVector The majorAxisVector to set.
174
     */
175
    public void setMajorAxisVector(double[] majorAxisVector) {
176
        this.majorAxisVector = majorAxisVector;
177
    }
178
    /**
179
     * @return Returns the extrusion.
180
     */
181
    public double[] getExtrusion() {
182
        return extrusion;
183
    }
184
        /* (non-Javadoc)
185
         * @see java.lang.Object#clone()
186
         */
187
        public Object clone() {
188
                DwgEllipse dwgEllipse = new DwgEllipse(index);
189
                dwgEllipse.setType(type);
190
                dwgEllipse.setHandle(handle);
191
                dwgEllipse.setVersion(version);
192
                dwgEllipse.setMode(mode);
193
                dwgEllipse.setLayerHandle(layerHandle);
194
                dwgEllipse.setColor(color);
195
                dwgEllipse.setNumReactors(numReactors);
196
                dwgEllipse.setNoLinks(noLinks);
197
                dwgEllipse.setLinetypeFlags(linetypeFlags);
198
                dwgEllipse.setPlotstyleFlags(plotstyleFlags);
199
                dwgEllipse.setSizeInBits(sizeInBits);
200
                dwgEllipse.setExtendedData(extendedData);
201
                dwgEllipse.setGraphicData(graphicData);
202
                //dwgEllipse.setInsideBlock(insideBlock);
203
                dwgEllipse.setCenter(center);
204
                dwgEllipse.setMajorAxisVector(majorAxisVector);
205
                dwgEllipse.setExtrusion(extrusion);
206
                dwgEllipse.setAxisRatio(axisRatio);
207
                dwgEllipse.setInitAngle(initAngle);
208
                dwgEllipse.setEndAngle(endAngle);
209
                return dwgEllipse;
210
        }
211
        /**
212
         * @param extrusion The extrusion to set.
213
         */
214
        public void setExtrusion(double[] extrusion) {
215
                this.extrusion = extrusion;
216
        }
217
}