svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / primitive / EllipticArcTest.java @ 26866
History | View | Annotate | Download (3.06 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 |
import junit.framework.TestCase; |
32 |
|
33 |
import org.gvsig.fmap.geom.GeometryLibrary; |
34 |
import org.gvsig.fmap.geom.GeometryLocator; |
35 |
import org.gvsig.fmap.geom.GeometryManager; |
36 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
37 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
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 EllipticArcTest extends TestCase { |
45 |
private GeometryManager manager;
|
46 |
|
47 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
48 |
|
49 |
static {
|
50 |
//logger.addAppender(new ConsoleAppender(new SimpleLayout()));
|
51 |
} |
52 |
|
53 |
public void setUp() throws Exception { |
54 |
super.setUp();
|
55 |
|
56 |
GeometryLibrary lib = new GeometryLibrary();
|
57 |
lib.initialize(); |
58 |
lib.postInitialize(); |
59 |
|
60 |
manager = GeometryLocator.getGeometryManager(); |
61 |
} |
62 |
|
63 |
public void testEllipticArc2D() throws InstantiationException, IllegalAccessException{ |
64 |
EllipticArc ellipticArc = (EllipticArc)manager.create(TYPES.ELLIPTICARC, SUBTYPES.GEOM2D); |
65 |
GeneralPathX generalPathX = new GeneralPathX();
|
66 |
Exception e = null; |
67 |
try{
|
68 |
ellipticArc.setGeneralPath(generalPathX); |
69 |
}catch (UnsupportedOperationException e1){ |
70 |
e = e1; |
71 |
} |
72 |
Assert.assertTrue(e instanceof UnsupportedOperationException); |
73 |
|
74 |
Point axis1Start = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
75 |
axis1Start.setCoordinateAt(0, 0); |
76 |
axis1Start.setCoordinateAt(1, 0); |
77 |
|
78 |
Point axix1End = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
79 |
axix1End.setCoordinateAt(0, 1); |
80 |
axix1End.setCoordinateAt(1, 1); |
81 |
|
82 |
double axis2Dist = 1; |
83 |
double angSt = 1; |
84 |
double angExt = 1; |
85 |
|
86 |
ellipticArc.setPoints(axis1Start, axix1End, axis2Dist, angSt, angExt); |
87 |
|
88 |
assertEquals(0, ellipticArc.getAxis1Start().getX(), 0); |
89 |
assertEquals(0, ellipticArc.getAxis1Start().getY(), 0); |
90 |
assertEquals(1, ellipticArc.getAxis1End().getX(), 0); |
91 |
assertEquals(1, ellipticArc.getAxis1End().getY(), 0); |
92 |
assertEquals(1, ellipticArc.getAxis2Dist(), axis2Dist);
|
93 |
assertEquals(1, ellipticArc.getAngSt(), angSt);
|
94 |
assertEquals(1, ellipticArc.getAngExt(), angExt);
|
95 |
} |
96 |
} |
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|