Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.impl / src / main / java / org / cresques / impl / geo / cover / Hoja.java @ 40559

History | View | Annotate | Download (4.01 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.impl.geo.cover;
25

    
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

    
29
import org.cresques.geo.Projected;
30

    
31
import org.cresques.px.Extent;
32

    
33
import java.awt.geom.Point2D;
34

    
35
import java.io.InputStream;
36
import java.io.OutputStream;
37

    
38
import java.util.Vector;
39

    
40

    
41
/**
42
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
43
 */
44
public class Hoja implements Projected {
45
    IProjection proj;
46
    String code = null;
47
    String name = null;
48
    Extent extent = null;
49
    Point2D tl;
50
    Point2D tr;
51
    Point2D bl;
52
    Point2D br;
53

    
54
    public Hoja(IProjection proj, String code, String name) {
55
        this.proj = proj;
56
        this.code = code;
57
        this.name = name;
58
        tl = tr = bl = br = null;
59
    }
60

    
61
    public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4,
62
                String name) {
63
        code = cod;
64
        tl = p1;
65
        tr = p2;
66
        bl = p3;
67
        br = p4;
68

    
69
        if (name != null) {
70
            this.name = name;
71
        }
72

    
73
        setExtent();
74
    }
75

    
76
    public Hoja(String cod, Point2D[] pt, String name) {
77
        code = cod;
78
        tl = pt[0];
79
        tr = pt[1];
80
        br = pt[2];
81
        bl = pt[3];
82

    
83
        if (name != null) {
84
            this.name = name;
85
        }
86

    
87
        setExtent();
88
    }
89

    
90
    public Hoja(String cod, Vector pt, String name) {
91
        code = cod;
92
        tl = (Point2D) pt.get(0);
93
        tr = (Point2D) pt.get(1);
94
        br = (Point2D) pt.get(2);
95
        bl = (Point2D) pt.get(3);
96

    
97
        if (name != null) {
98
            this.name = name;
99
        }
100

    
101
        setExtent();
102
    }
103

    
104
    public Hoja(String cod, Hoja h, String name) {
105
        code = cod;
106
        tl = h.tl;
107
        tr = h.tr;
108
        br = h.br;
109
        bl = h.bl;
110

    
111
        if (name != null) {
112
            this.name = name;
113
        }
114

    
115
        setExtent();
116
    }
117

    
118
    public IProjection getProjection() {
119
        return proj;
120
    }
121

    
122
    public void setProjection(IProjection p) {
123
        proj = p;
124
    }
125

    
126
    public void reProject(ICoordTrans rp) {
127
        // TODO metodo reProject pendiente de implementar
128
    }
129

    
130
    public Point2D getTL() {
131
        return tl;
132
    }
133

    
134
    public void setTL(Point2D pt) {
135
        tl = pt;
136
        extent.add(pt);
137
    }
138

    
139
    public Point2D getTR() {
140
        return tr;
141
    }
142

    
143
    public void setTR(Point2D pt) {
144
        tr = pt;
145
        extent.add(pt);
146
    }
147

    
148
    public Point2D getBL() {
149
        return bl;
150
    }
151

    
152
    public void setBL(Point2D pt) {
153
        bl = pt;
154
        extent.add(pt);
155
    }
156

    
157
    public Point2D getBR() {
158
        return br;
159
    }
160

    
161
    public void setBR(Point2D pt) {
162
        br = pt;
163
        extent.add(pt);
164
    }
165

    
166
    public Extent getExtent() {
167
        return extent;
168
    }
169

    
170
    private void setExtent() {
171
        extent = new Extent(tl, br);
172
        extent.add(tr);
173
        extent.add(bl);
174
    }
175

    
176
    public String getCode() {
177
        return code;
178
    }
179

    
180
    public String getName() {
181
        return name;
182
    }
183

    
184
    public Point2D[] getVertex() {
185
        Point2D[] v = { tl, tr, br, bl };
186

    
187
        return v;
188
    }
189

    
190
    public void toXml(OutputStream os) {
191
    }
192

    
193
    public void fromXml(InputStream is) {
194
    }
195
}