Statistics
| Revision:

root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgPoint.java @ 10356

History | View | Annotate | Download (4.12 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.DwgObject;
41
import com.iver.cit.jdwglib.dwg.IDwg2FMap;
42
import com.iver.cit.jdwglib.dwg.IDwg3DTestable;
43
import com.iver.cit.jdwglib.dwg.IDwgExtrusionable;
44
import com.iver.cit.jdwglib.util.AcadExtrusionCalculator;
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 FShape toFMapGeometry(boolean is3DFile) {
133
                FPoint2D point = null;
134
                double[] p = getPoint();
135
                if (is3DFile) {
136
                        point = new FPoint3D(p[0], p[1], p[2]);
137
                
138
                } else {
139
                        point = new FPoint2D(p[0], p[1]);
140
                }
141
                return point;
142
        }
143
        
144
        public String toFMapString(boolean is3DFile) {
145
                if(is3DFile)
146
                        return "FPoint3D";
147
                else
148
                        return "FPoint2D";
149
        }
150
        
151
        public String toString(){
152
                return "Point";
153
        }
154
        
155
        /* (non-Javadoc)
156
         * @see java.lang.Object#clone()
157
         */
158
        public Object clone(){
159
                DwgPoint obj = new DwgPoint(index);
160
                this.fill(obj);
161
                return obj;
162
        }
163
        
164
        protected void fill(DwgObject obj){
165
                super.fill(obj);
166
                DwgPoint myObj = (DwgPoint)obj;
167

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

    
174
}