root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / ProjectExtent.java @ 2183
History | View | Annotate | Download (4.19 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.project; |
42 |
|
43 |
import com.iver.utiles.XMLEntity; |
44 |
|
45 |
import java.awt.geom.Rectangle2D; |
46 |
|
47 |
|
48 |
/**
|
49 |
* DOCUMENT ME!
|
50 |
*
|
51 |
* @author Fernando Gonz?lez Cort?s
|
52 |
*/
|
53 |
public class ProjectExtent { |
54 |
private Rectangle2D extent = new Rectangle2D.Double(); |
55 |
private String description; |
56 |
|
57 |
/**
|
58 |
* DOCUMENT ME!
|
59 |
*
|
60 |
* @return
|
61 |
*/
|
62 |
public String getDescription() { |
63 |
return description;
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* DOCUMENT ME!
|
68 |
*
|
69 |
* @return
|
70 |
*/
|
71 |
public Rectangle2D getExtent() { |
72 |
return extent;
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* DOCUMENT ME!
|
77 |
*
|
78 |
* @param string
|
79 |
*/
|
80 |
public void setDescription(String string) { |
81 |
description = string; |
82 |
} |
83 |
|
84 |
/**
|
85 |
* DOCUMENT ME!
|
86 |
*
|
87 |
* @param rectangle2D
|
88 |
*/
|
89 |
public void setExtent(Rectangle2D rectangle2D) { |
90 |
extent = rectangle2D; |
91 |
} |
92 |
|
93 |
/**
|
94 |
* DOCUMENT ME!
|
95 |
*
|
96 |
* @return DOCUMENT ME!
|
97 |
*/
|
98 |
public String getEncuadre() { |
99 |
return extent.getMinX() + "," + extent.getMinY() + "," + |
100 |
extent.getWidth() + "," + extent.getHeight();
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* DOCUMENT ME!
|
105 |
*
|
106 |
* @param encuadre DOCUMENT ME!
|
107 |
*/
|
108 |
public void setEncuadre(String encuadre) { |
109 |
String[] coords = encuadre.split(","); |
110 |
extent = new Rectangle2D.Double(new Double(coords[0]).doubleValue(), |
111 |
new Double(coords[1]).doubleValue(), |
112 |
new Double(coords[2]).doubleValue(), |
113 |
new Double(coords[3]).doubleValue()); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* @see java.lang.Object#toString()
|
118 |
*/
|
119 |
public String toString() { |
120 |
return description;
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* DOCUMENT ME!
|
125 |
*
|
126 |
* @return DOCUMENT ME!
|
127 |
*/
|
128 |
public XMLEntity getXMLEntity() {
|
129 |
XMLEntity xml = new XMLEntity();
|
130 |
xml.putProperty("description", description);
|
131 |
xml.putProperty("extentX", extent.getX());
|
132 |
xml.putProperty("extentY", extent.getY());
|
133 |
xml.putProperty("extentW", extent.getWidth());
|
134 |
xml.putProperty("extentH", extent.getHeight());
|
135 |
|
136 |
return xml;
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* DOCUMENT ME!
|
141 |
*
|
142 |
* @param xml DOCUMENT ME!
|
143 |
*
|
144 |
* @return DOCUMENT ME!
|
145 |
*/
|
146 |
public static ProjectExtent createFromXML03(XMLEntity xml) { |
147 |
ProjectExtent pe = new ProjectExtent();
|
148 |
pe.description = xml.getStringProperty("description");
|
149 |
pe.extent.setRect(xml.getDoubleProperty("extentX"),
|
150 |
xml.getDoubleProperty("extentY"), xml.getDoubleProperty("extentW"), |
151 |
xml.getDoubleProperty("extentH"));
|
152 |
|
153 |
return pe;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* DOCUMENT ME!
|
158 |
*
|
159 |
* @param xml DOCUMENT ME!
|
160 |
*
|
161 |
* @return DOCUMENT ME!
|
162 |
*/
|
163 |
public static ProjectExtent createFromXML(XMLEntity xml) { |
164 |
ProjectExtent pe = new ProjectExtent();
|
165 |
pe.description = xml.getStringProperty("description");
|
166 |
pe.extent.setRect(xml.getDoubleProperty("extentX"),
|
167 |
xml.getDoubleProperty("extentY"), xml.getDoubleProperty("extentW"), |
168 |
xml.getDoubleProperty("extentH"));
|
169 |
|
170 |
return pe;
|
171 |
} |
172 |
} |