Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / impl / DefaultGeometryManagerTest.java @ 31544

History | View | Annotate | Download (7.02 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {}  {{Task}}
26
*/
27
package org.gvsig.fmap.geom.impl;
28

    
29
import java.awt.Rectangle;
30
import java.awt.Shape;
31
import java.awt.geom.AffineTransform;
32
import java.awt.geom.PathIterator;
33
import java.awt.geom.Point2D;
34
import java.awt.geom.Rectangle2D;
35

    
36
import junit.framework.TestCase;
37

    
38
import org.cresques.cts.ICoordTrans;
39
import org.gvsig.fmap.geom.Geometry;
40
import org.gvsig.fmap.geom.handler.Handler;
41
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
42
import org.gvsig.fmap.geom.operation.GeometryOperationException;
43
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
44
import org.gvsig.fmap.geom.primitive.Envelope;
45
import org.gvsig.fmap.geom.primitive.GeneralPathX;
46
import org.gvsig.fmap.geom.type.GeometryType;
47

    
48
/**
49
 * Unit tests for the class {@link DefaultGeometryManager}.
50
 * 
51
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
52
 */
53
public class DefaultGeometryManagerTest extends TestCase {
54

    
55
        private DefaultGeometryManager manager;
56

    
57
        protected void setUp() throws Exception {
58
                super.setUp();
59
        }
60

    
61
        /**
62
         * Test method for
63
         * {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#registerGeometryType(int, int)}
64
         * and
65
         * {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#getGeometryType(int, int)
66
         * .
67
         */
68
        public void testRegisterGetGeometryType() throws Exception {
69
                manager = new DefaultGeometryManager(1, 1);
70
                manager.registerGeometryType(TestGeometry.class,
71
                                Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
72
                manager.registerGeometryType(TestGeometry.class,
73
                                Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D);
74
                manager.registerGeometryType(TestGeometry.class,
75
                                Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D);
76
                manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC,
77
                                Geometry.SUBTYPES.GEOM3DM);
78

    
79
                assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY,
80
                                Geometry.SUBTYPES.GEOM2D));
81

    
82
                assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY,
83
                                Geometry.SUBTYPES.GEOM3D));
84

    
85
                assertNotNull(manager.getGeometryType(Geometry.TYPES.MULTISOLID,
86
                                Geometry.SUBTYPES.GEOM2D));
87

    
88
                assertNotNull(manager.getGeometryType(Geometry.TYPES.ARC,
89
                                Geometry.SUBTYPES.GEOM3DM));
90
        }
91

    
92
        /**
93
         * Test method for
94
         * {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#create(int, int)}.
95
         */
96
        public void testCreateIntInt() throws Exception {
97
                manager = new DefaultGeometryManager();
98
                manager.registerGeometryType(TestGeometry.class,
99
                                Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
100
                manager.registerGeometryType(TestGeometry.class,
101
                                Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D);
102
                manager.registerGeometryType(TestGeometry.class,
103
                                Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D);
104
                manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC,
105
                                Geometry.SUBTYPES.GEOM3DM);
106

    
107
                assertGeometry(manager.create(Geometry.TYPES.GEOMETRY,
108
                                Geometry.SUBTYPES.GEOM2D));
109

    
110
                assertGeometry(manager.create(Geometry.TYPES.GEOMETRY,
111
                                Geometry.SUBTYPES.GEOM3D));
112

    
113
                assertGeometry(manager.create(Geometry.TYPES.MULTISOLID,
114
                                Geometry.SUBTYPES.GEOM2D));
115

    
116
                assertGeometry(manager.create(Geometry.TYPES.ARC,
117
                                Geometry.SUBTYPES.GEOM3DM));
118
        }
119

    
120
        private void assertGeometry(Geometry geom) {
121
                assertNotNull(geom);
122
                assertEquals(TestGeometry.class, geom.getClass());
123
        }
124

    
125
        public static class TestGeometry implements Geometry {
126

    
127
                private final GeometryType geometryType;
128

    
129
                public TestGeometry(GeometryType geometryType) {
130
                        this.geometryType = geometryType;
131
                }
132

    
133
                public Geometry cloneGeometry() {
134
                        // TODO Auto-generated method stub
135
                        return null;
136
                }
137

    
138
                public boolean fastIntersects(double x, double y, double w, double h) {
139
                        // TODO Auto-generated method stub
140
                        return false;
141
                }
142

    
143
                public Rectangle2D getBounds2D() {
144
                        // TODO Auto-generated method stub
145
                        return null;
146
                }
147

    
148
                public int getDimension() {
149
                        // TODO Auto-generated method stub
150
                        return 0;
151
                }
152

    
153
                public Envelope getEnvelope() {
154
                        // TODO Auto-generated method stub
155
                        return null;
156
                }
157

    
158
                public GeneralPathX getGeneralPath() {
159
                        // TODO Auto-generated method stub
160
                        return null;
161
                }
162

    
163
                public GeometryType getGeometryType() {
164
                        return geometryType;
165
                }
166

    
167
                public Handler[] getHandlers(int type) {
168
                        // TODO Auto-generated method stub
169
                        return null;
170
                }
171

    
172
                public Shape getInternalShape() {
173
                        // TODO Auto-generated method stub
174
                        return null;
175
                }
176

    
177
                public PathIterator getPathIterator(AffineTransform at) {
178
                        // TODO Auto-generated method stub
179
                        return null;
180
                }
181

    
182
                public PathIterator getPathIterator(AffineTransform at, double flatness) {
183
                        // TODO Auto-generated method stub
184
                        return null;
185
                }
186

    
187
                public int getType() {
188
                        return 0;
189
                }
190

    
191
                public boolean intersects(Rectangle2D r) {
192
                        // TODO Auto-generated method stub
193
                        return false;
194
                }
195

    
196
                public Object invokeOperation(int index, GeometryOperationContext ctx)
197
                                throws GeometryOperationNotSupportedException,
198
                                GeometryOperationException {
199
                        // TODO Auto-generated method stub
200
                        return null;
201
                }
202

    
203
                public Object invokeOperation(String opName,
204
                                GeometryOperationContext ctx)
205
                                throws GeometryOperationNotSupportedException,
206
                                GeometryOperationException {
207
                        // TODO Auto-generated method stub
208
                        return null;
209
                }
210

    
211
                public boolean isSimple() {
212
                        // TODO Auto-generated method stub
213
                        return false;
214
                }
215

    
216
                public void reProject(ICoordTrans ct) {
217
                        // TODO Auto-generated method stub
218

    
219
                }
220

    
221
                public void transform(AffineTransform at) {
222
                        // TODO Auto-generated method stub
223

    
224
                }
225

    
226
                public boolean contains(Point2D p) {
227
                        // TODO Auto-generated method stub
228
                        return false;
229
                }
230

    
231
                public boolean contains(Rectangle2D r) {
232
                        // TODO Auto-generated method stub
233
                        return false;
234
                }
235

    
236
                public boolean contains(double x, double y) {
237
                        // TODO Auto-generated method stub
238
                        return false;
239
                }
240

    
241
                public boolean contains(double x, double y, double w, double h) {
242
                        // TODO Auto-generated method stub
243
                        return false;
244
                }
245

    
246
                public Rectangle getBounds() {
247
                        // TODO Auto-generated method stub
248
                        return null;
249
                }
250

    
251
                public boolean intersects(double x, double y, double w, double h) {
252
                        // TODO Auto-generated method stub
253
                        return false;
254
                }
255

    
256
                public int compareTo(Object arg0) {
257
                        // TODO Auto-generated method stub
258
                        return 0;
259
                }
260

    
261
        }
262
}