Statistics
| Revision:

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

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