Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / objects / DwgPoint.java @ 28969

History | View | Annotate | Download (4.08 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 org.gvsig.dwg.lib.objects;
36

    
37
import org.gvsig.dwg.lib.DwgObject;
38
import org.gvsig.dwg.lib.IDwg2FMap;
39
import org.gvsig.dwg.lib.IDwg3DTestable;
40
import org.gvsig.dwg.lib.util.AcadExtrusionCalculator;
41
import org.gvsig.fmap.geom.Geometry;
42
import org.gvsig.fmap.geom.GeometryFactory;
43
import org.gvsig.fmap.geom.GeometryManager;
44

    
45

    
46
/**
47
 * The DwgPoint class represents a DWG Point
48
 *
49
 * @author jmorell
50
 */
51
public class DwgPoint extends DwgObject
52
                implements/* IDwgExtrusionable,*/ IDwg3DTestable, IDwg2FMap{
53
        public DwgPoint(int index) {
54
                super(index);
55
                // TODO Auto-generated constructor stub
56
        }
57
        private double[] point;
58
        private double thickness;
59
        private double[] extrusion;
60
        private double xAxisAngle;
61

    
62
        /**
63
         * @return Returns the point.
64
         */
65
        public double[] getPoint() {
66
                return point;
67
        }
68
        /**
69
         * @param point The point to set.
70
         */
71
        public void setPoint(double[] point) {
72
                this.point = point;
73
        }
74
        /**
75
         * @return Returns the extrusion.
76
         */
77
        public double[] getExtrusion() {
78
                return extrusion;
79
        }
80
        /**
81
         * @param extrusion The extrusion to set.
82
         */
83
        public void setExtrusion(double[] extrusion) {
84
                this.extrusion = extrusion;
85
        }
86
        /**
87
         * @return Returns the thickness.
88
         */
89
        public double getThickness() {
90
                return thickness;
91
        }
92
        /**
93
         * @param thickness The thickness to set.
94
         */
95
        public void setThickness(double thickness) {
96
                this.thickness = thickness;
97
        }
98
        /**
99
         * @return Returns the xAxisAngle.
100
         */
101
        public double getXAxisAngle() {
102
                return xAxisAngle;
103
        }
104
        /**
105
         * @param axisAngle The xAxisAngle to set.
106
         */
107
        public void setXAxisAngle(double axisAngle) {
108
                xAxisAngle = axisAngle;
109
        }
110

    
111
        /* (non-Javadoc)
112
         * @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion()
113
         */
114
        public void applyExtrussion() {
115
                 double[] point = getPoint();
116
         double[] pointExt = getExtrusion();
117
         point = AcadExtrusionCalculator.extrude2(point, pointExt);
118
         setPoint(point);
119
        }
120
        /* (non-Javadoc)
121
         * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
122
         */
123
        public boolean has3DData() {
124
                return getPoint()[2] != 0.0;
125
        }
126
        /* (non-Javadoc)
127
         * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#getZ()
128
         */
129
        public double getZ() {
130
                return getPoint()[2];
131
        }
132
        public Geometry toFMapGeometry(boolean is3DFile) {
133
                GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
134
                double[] p = getPoint();
135
                if (is3DFile) {
136
                        return gFactory.createPoint3D(p[0], p[1], p[2]);
137
                } else {
138
                        return gFactory.createPoint2D(p[0], p[1]);
139
                }
140
        }
141

    
142
        public String toFMapString(boolean is3DFile) {
143
                if(is3DFile)
144
                        return "FPoint3D";
145
                else
146
                        return "FPoint2D";
147
        }
148

    
149
        public String toString(){
150
                return "Point";
151
        }
152

    
153
        /* (non-Javadoc)
154
         * @see java.lang.Object#clone()
155
         */
156
        public Object clone(){
157
                DwgPoint obj = new DwgPoint(index);
158
                this.fill(obj);
159
                return obj;
160
        }
161

    
162
        protected void fill(DwgObject obj){
163
                super.fill(obj);
164
                DwgPoint myObj = (DwgPoint)obj;
165

    
166
                myObj.setExtrusion(extrusion);
167
                myObj.setPoint(point);
168
                myObj.setThickness(thickness);
169
                myObj.setXAxisAngle(xAxisAngle);
170
        }
171

    
172
}