svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / primitive / ArcTest.java @ 38785
History | View | Annotate | Download (2.88 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 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.geom.primitive; |
29 |
|
30 |
import junit.framework.Assert; |
31 |
|
32 |
import org.gvsig.fmap.geom.GeometryLocator; |
33 |
import org.gvsig.fmap.geom.GeometryManager; |
34 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
35 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
36 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
37 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
38 |
import org.slf4j.Logger; |
39 |
import org.slf4j.LoggerFactory; |
40 |
|
41 |
/**
|
42 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
43 |
*/
|
44 |
public class ArcTest extends AbstractLibraryAutoInitTestCase { |
45 |
private GeometryManager manager;
|
46 |
|
47 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
48 |
|
49 |
protected void doSetUp() throws Exception { |
50 |
manager = GeometryLocator.getGeometryManager(); |
51 |
} |
52 |
|
53 |
public void testCreateArc2D() throws InstantiationException, IllegalAccessException, CreateGeometryException{ |
54 |
Arc arc = (Arc)manager.create(TYPES.ARC, SUBTYPES.GEOM2D); |
55 |
GeneralPathX generalPathX = new GeneralPathX();
|
56 |
Exception e = null; |
57 |
try{
|
58 |
arc.setGeneralPath(generalPathX); |
59 |
}catch (UnsupportedOperationException e1){ |
60 |
e = e1; |
61 |
} |
62 |
Assert.assertTrue(e instanceof UnsupportedOperationException); |
63 |
|
64 |
|
65 |
Point initPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
66 |
initPoint.setCoordinateAt(0, 1); |
67 |
initPoint.setCoordinateAt(1, 1); |
68 |
|
69 |
Point middle = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
70 |
middle.setCoordinateAt(0, 0); |
71 |
middle.setCoordinateAt(1, 0); |
72 |
|
73 |
|
74 |
Point endPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
75 |
endPoint.setCoordinateAt(0, 0); |
76 |
endPoint.setCoordinateAt(1, 1); |
77 |
|
78 |
arc.setPoints(initPoint, middle, endPoint); |
79 |
|
80 |
assertEquals(0.5, arc.getCenterPoint().getX(), 0); |
81 |
assertEquals(0.5, arc.getCenterPoint().getY(), 0); |
82 |
assertEquals(1.0, arc.getInitPoint().getX(), 0); |
83 |
assertEquals(1.0, arc.getInitPoint().getY(), 0); |
84 |
assertEquals(0, arc.getEndPoint().getX(), 0); |
85 |
assertEquals(1, arc.getEndPoint().getY(), 0); |
86 |
} |
87 |
} |
88 |
|
89 |
|
90 |
|