root / branches / Mobile_Compatible_Hito_1 / libProjectionCresques / src / org / gvsig / projection / cresques / geo / cover / Hoja.java @ 21932
History | View | Annotate | Download (4.18 KB)
1 | 21932 | csanchez | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | package org.gvsig.projection.cresques.geo.cover; |
||
25 | |||
26 | |||
27 | |||
28 | import java.awt.geom.Point2D; |
||
29 | import java.io.InputStream; |
||
30 | import java.io.OutputStream; |
||
31 | import java.util.Vector; |
||
32 | |||
33 | import org.gvsig.projection.cts.ICoordTrans; |
||
34 | import org.gvsig.projection.cts.IProjection; |
||
35 | import org.gvsig.projection.geo.Projected; |
||
36 | import org.gvsig.projection.px.Extent; |
||
37 | |||
38 | |||
39 | /**
|
||
40 | * @author Luis W. Sevilla <sevilla_lui@gva.es>
|
||
41 | */
|
||
42 | public class Hoja implements Projected { |
||
43 | IProjection proj; |
||
44 | String code = null; |
||
45 | String name = null; |
||
46 | Extent extent = null;
|
||
47 | Point2D tl;
|
||
48 | Point2D tr;
|
||
49 | Point2D bl;
|
||
50 | Point2D br;
|
||
51 | |||
52 | public Hoja(IProjection proj, String code, String name) { |
||
53 | this.proj = proj;
|
||
54 | this.code = code;
|
||
55 | this.name = name;
|
||
56 | tl = tr = bl = br = null;
|
||
57 | } |
||
58 | |||
59 | public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4, |
||
60 | String name) {
|
||
61 | code = cod; |
||
62 | tl = p1; |
||
63 | tr = p2; |
||
64 | bl = p3; |
||
65 | br = p4; |
||
66 | |||
67 | if (name != null) { |
||
68 | this.name = name;
|
||
69 | } |
||
70 | |||
71 | setExtent(); |
||
72 | } |
||
73 | |||
74 | public Hoja(String cod, Point2D[] pt, String name) { |
||
75 | code = cod; |
||
76 | tl = pt[0];
|
||
77 | tr = pt[1];
|
||
78 | br = pt[2];
|
||
79 | bl = pt[3];
|
||
80 | |||
81 | if (name != null) { |
||
82 | this.name = name;
|
||
83 | } |
||
84 | |||
85 | setExtent(); |
||
86 | } |
||
87 | |||
88 | public Hoja(String cod, Vector pt, String name) { |
||
89 | code = cod; |
||
90 | tl = (Point2D) pt.get(0); |
||
91 | tr = (Point2D) pt.get(1); |
||
92 | br = (Point2D) pt.get(2); |
||
93 | bl = (Point2D) pt.get(3); |
||
94 | |||
95 | if (name != null) { |
||
96 | this.name = name;
|
||
97 | } |
||
98 | |||
99 | setExtent(); |
||
100 | } |
||
101 | |||
102 | public Hoja(String cod, Hoja h, String name) { |
||
103 | code = cod; |
||
104 | tl = h.tl; |
||
105 | tr = h.tr; |
||
106 | br = h.br; |
||
107 | bl = h.bl; |
||
108 | |||
109 | if (name != null) { |
||
110 | this.name = name;
|
||
111 | } |
||
112 | |||
113 | setExtent(); |
||
114 | } |
||
115 | |||
116 | public IProjection getProjection() {
|
||
117 | return proj;
|
||
118 | } |
||
119 | |||
120 | public void setProjection(IProjection p) { |
||
121 | proj = p; |
||
122 | } |
||
123 | |||
124 | public void reProject(ICoordTrans rp) { |
||
125 | // TODO metodo reProject pendiente de implementar
|
||
126 | } |
||
127 | |||
128 | public Point2D getTL() { |
||
129 | return tl;
|
||
130 | } |
||
131 | |||
132 | public void setTL(Point2D pt) { |
||
133 | tl = pt; |
||
134 | extent.add(pt); |
||
135 | } |
||
136 | |||
137 | public Point2D getTR() { |
||
138 | return tr;
|
||
139 | } |
||
140 | |||
141 | public void setTR(Point2D pt) { |
||
142 | tr = pt; |
||
143 | extent.add(pt); |
||
144 | } |
||
145 | |||
146 | public Point2D getBL() { |
||
147 | return bl;
|
||
148 | } |
||
149 | |||
150 | public void setBL(Point2D pt) { |
||
151 | bl = pt; |
||
152 | extent.add(pt); |
||
153 | } |
||
154 | |||
155 | public Point2D getBR() { |
||
156 | return br;
|
||
157 | } |
||
158 | |||
159 | public void setBR(Point2D pt) { |
||
160 | br = pt; |
||
161 | extent.add(pt); |
||
162 | } |
||
163 | |||
164 | public Extent getExtent() {
|
||
165 | return extent;
|
||
166 | } |
||
167 | |||
168 | private void setExtent() { |
||
169 | extent = new Extent(tl, br);
|
||
170 | extent.add(tr); |
||
171 | extent.add(bl); |
||
172 | } |
||
173 | |||
174 | public String getCode() { |
||
175 | return code;
|
||
176 | } |
||
177 | |||
178 | public String getName() { |
||
179 | return name;
|
||
180 | } |
||
181 | |||
182 | public Point2D[] getVertex() { |
||
183 | Point2D[] v = { tl, tr, br, bl }; |
||
184 | |||
185 | return v;
|
||
186 | } |
||
187 | |||
188 | public void toXml(OutputStream os) { |
||
189 | } |
||
190 | |||
191 | public void fromXml(InputStream is) { |
||
192 | } |
||
193 | } |