Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / primitive / EllipseTest.java @ 26866

History | View | Annotate | Download (2.85 KB)

1 26788 jpiera
/* 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 26866 jpiera
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
37
import org.gvsig.fmap.geom.Geometry.TYPES;
38 26788 jpiera
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 EllipseTest 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 testEllipse2D() throws InstantiationException, IllegalAccessException{
64 26866 jpiera
                Ellipse ellipse = (Ellipse)manager.create(TYPES.ELLIPSE, SUBTYPES.GEOM2D);
65 26788 jpiera
                GeneralPathX generalPathX = new GeneralPathX();
66
                Exception e = null;
67
                try{
68
                        ellipse.setGeneralPath(generalPathX);
69
                }catch (UnsupportedOperationException e1){
70
                        e = e1;
71
                }
72
                Assert.assertTrue(e instanceof UnsupportedOperationException);
73
74 26866 jpiera
                Point initPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
75 26788 jpiera
                initPoint.setCoordinateAt(0, 0);
76
                initPoint.setCoordinateAt(1, 0);
77
78 26866 jpiera
                Point endPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
79 26788 jpiera
                endPoint.setCoordinateAt(0, 1);
80
                endPoint.setCoordinateAt(1, 1);
81
82 26810 jpiera
                double axisLength = 1;
83 26788 jpiera
84 26810 jpiera
                ellipse.setPoints(initPoint, endPoint, axisLength);
85
86
                assertEquals(0, ellipse.getAxis1Start().getX(), 0);
87
                assertEquals(0, ellipse.getAxis1Start().getY(), 0);
88
                assertEquals(1, ellipse.getAxis1End().getX(), 0);
89
                assertEquals(1, ellipse.getAxis1End().getY(), 0);
90
                assertEquals(1, ellipse.getAxis2Dist(), axisLength);
91
        ;
92 26788 jpiera
        }
93
}
94
95