Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / Envelope2D.java @ 27049

History | View | Annotate | Download (2.15 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.impl;
29

    
30
import java.awt.geom.Rectangle2D;
31

    
32
import org.cresques.cts.ICoordTrans;
33
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
34
import org.gvsig.fmap.geom.primitive.Envelope;
35
import org.gvsig.fmap.geom.primitive.Point;
36

    
37
/**
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public class Envelope2D extends DefaultEnvelope{
41
        
42
        public Envelope2D() {
43
                super();                
44
        }
45
        
46
        public Envelope2D(Point min, Point max) {
47
                super(min, max);
48
        }
49

    
50
        public Envelope2D(double minX,double minY,double maxX, double maxY){
51
                this(new Point2D(minX, minY), new Point2D(maxX, maxY));
52
        }
53

    
54
        /* (non-Javadoc)
55
         * @see org.gvsig.fmap.geom.primitive.Envelope#getDimension()
56
         */
57
        public int getDimension() {
58
                return 2;
59
        }
60

    
61
        /*
62
         * (non-Javadoc)
63
         * @see org.gvsig.fmap.geom.primitive.Envelope#convert(org.cresques.cts.ICoordTrans)
64
         */
65
        public Envelope convert(ICoordTrans trans) {
66
                if (this.getDimension() > 2) {
67
                        return null;
68
                }
69
                Rectangle2D rect = new Rectangle2D.Double(this.getMinimum(0), this
70
                                .getMinimum(1), this.getLength(0), this.getLength(1));
71
                Rectangle2D rectDest = trans.convert(rect);
72
                if (rectDest == null){
73
                        return null;
74
                }
75

    
76
                return new Envelope2D(min, max);
77
        }
78

    
79
}
80