Statistics
| Revision:

root / tags / v2_0_0_Build_2059 / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / primitive / EllipseTest.java @ 39313

History | View | Annotate | Download (2.77 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
32
import org.gvsig.fmap.geom.GeometryLocator;
33
import org.gvsig.fmap.geom.GeometryManager;
34 26866 jpiera
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
35
import org.gvsig.fmap.geom.Geometry.TYPES;
36 27397 jpiera
import org.gvsig.fmap.geom.exception.CreateGeometryException;
37 33388 jpiera
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
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 33388 jpiera
public class EllipseTest extends AbstractLibraryAutoInitTestCase {
45 26788 jpiera
        private GeometryManager manager;
46
47
        final static private Logger logger = LoggerFactory.getLogger("org.gvsig");
48
49 33388 jpiera
        protected void doSetUp() throws Exception {
50
                manager = GeometryLocator.getGeometryManager();
51 26788 jpiera
        }
52
53 27397 jpiera
        public void testEllipse2D() throws InstantiationException, IllegalAccessException, CreateGeometryException{
54 26866 jpiera
                Ellipse ellipse = (Ellipse)manager.create(TYPES.ELLIPSE, SUBTYPES.GEOM2D);
55 26788 jpiera
                GeneralPathX generalPathX = new GeneralPathX();
56
                Exception e = null;
57
                try{
58
                        ellipse.setGeneralPath(generalPathX);
59
                }catch (UnsupportedOperationException e1){
60
                        e = e1;
61
                }
62
                Assert.assertTrue(e instanceof UnsupportedOperationException);
63
64 26866 jpiera
                Point initPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
65 26788 jpiera
                initPoint.setCoordinateAt(0, 0);
66
                initPoint.setCoordinateAt(1, 0);
67
68 26866 jpiera
                Point endPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
69 26788 jpiera
                endPoint.setCoordinateAt(0, 1);
70
                endPoint.setCoordinateAt(1, 1);
71
72 26810 jpiera
                double axisLength = 1;
73 26788 jpiera
74 26810 jpiera
                ellipse.setPoints(initPoint, endPoint, axisLength);
75
76
                assertEquals(0, ellipse.getAxis1Start().getX(), 0);
77
                assertEquals(0, ellipse.getAxis1Start().getY(), 0);
78
                assertEquals(1, ellipse.getAxis1End().getX(), 0);
79
                assertEquals(1, ellipse.getAxis1End().getY(), 0);
80
                assertEquals(1, ellipse.getAxis2Dist(), axisLength);
81
        ;
82 26788 jpiera
        }
83
}
84
85