root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / Envelope2D.java @ 29097
History | View | Annotate | Download (2.16 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.primitive.Envelope; |
34 |
import org.gvsig.fmap.geom.primitive.Point; |
35 |
|
36 |
/**
|
37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
38 |
*/
|
39 |
public class Envelope2D extends DefaultEnvelope{ |
40 |
|
41 |
public Envelope2D() {
|
42 |
super();
|
43 |
min = new Point2D(0, 0); |
44 |
max = new Point2D(0, 0); |
45 |
} |
46 |
|
47 |
public Envelope2D(Point min, Point max) { |
48 |
super(min, max);
|
49 |
} |
50 |
|
51 |
public Envelope2D(double minX,double minY,double maxX, double maxY){ |
52 |
this(new Point2D(minX, minY), new Point2D(maxX, maxY)); |
53 |
} |
54 |
|
55 |
/* (non-Javadoc)
|
56 |
* @see org.gvsig.fmap.geom.primitive.Envelope#getDimension()
|
57 |
*/
|
58 |
public int getDimension() { |
59 |
return 2; |
60 |
} |
61 |
|
62 |
/*
|
63 |
* (non-Javadoc)
|
64 |
* @see org.gvsig.fmap.geom.primitive.Envelope#convert(org.cresques.cts.ICoordTrans)
|
65 |
*/
|
66 |
public Envelope convert(ICoordTrans trans) {
|
67 |
if (this.getDimension() > 2) { |
68 |
return null; |
69 |
} |
70 |
Rectangle2D rect = new Rectangle2D.Double(this.getMinimum(0), this |
71 |
.getMinimum(1), this.getLength(0), this.getLength(1)); |
72 |
Rectangle2D rectDest = trans.convert(rect);
|
73 |
if (rectDest == null){ |
74 |
return null; |
75 |
} |
76 |
|
77 |
return new Envelope2D(min, max); |
78 |
} |
79 |
|
80 |
} |
81 |
|