Statistics
| Revision:

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

History | View | Annotate | Download (2.96 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 ArcTest extends TestCase {
45
        private GeometryManager manager;
46
        
47
        final static private Logger logger = LoggerFactory.getLogger("org.gvsig");
48
        static {
49
                //logger.addAppender(new ConsoleAppender(new SimpleLayout()));
50
        }
51

    
52
        public void setUp() throws Exception {
53
                super.setUp();
54

    
55
                GeometryLibrary lib = new GeometryLibrary();                
56
                lib.initialize();
57
                lib.postInitialize();
58
                
59
                manager = GeometryLocator.getGeometryManager();
60
        }
61
        
62
        public void testCreateArc2D() throws InstantiationException, IllegalAccessException{
63
                Arc arc = (Arc)manager.create(TYPES.ARC, SUBTYPES.GEOM2D);
64
                GeneralPathX generalPathX = new GeneralPathX();
65
                Exception e = null;
66
                try{
67
                        arc.setGeneralPath(generalPathX);
68
                }catch (UnsupportedOperationException e1){
69
                        e = e1;
70
                }
71
                Assert.assertTrue(e instanceof UnsupportedOperationException);
72
                
73
                Point center = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
74
                center.setCoordinateAt(0, 0);
75
                center.setCoordinateAt(1, 0);
76
                
77
                Point initPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
78
                initPoint.setCoordinateAt(0, 1);
79
                initPoint.setCoordinateAt(1, 1);
80
                
81
                Point endPoint = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
82
                endPoint.setCoordinateAt(0, 0);
83
                endPoint.setCoordinateAt(1, 1);
84
                
85
                arc.setPoints(center, initPoint, endPoint);
86
                
87
                assertEquals(0.5, arc.getCenterPoint().getX(), 0);
88
                assertEquals(0.5, arc.getCenterPoint().getX(), 0);
89
                assertEquals(1.0, arc.getInitPoint().getX(), 0);
90
                assertEquals(1.0, arc.getInitPoint().getX(), 0);
91
                assertEquals(0, arc.getEndPoint().getX(), 0);
92
                assertEquals(0, arc.getEndPoint().getX(), 0);
93
        }        
94
}
95

    
96

    
97