svn-gvsig-desktop / branches / gvSIG_GisPlanet / applications / appgvSIG / src / com / iver / cit / gvsig / project / ProjectView.java @ 2147
History | View | Annotate | Download (7.17 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 java.awt.Color; |
44 |
import java.text.DateFormat; |
45 |
import java.util.Date; |
46 |
|
47 |
import org.cresques.cts.IProjection; |
48 |
|
49 |
import com.iver.cit.gvsig.fmap.DriverException; |
50 |
import com.iver.cit.gvsig.fmap.FMap; |
51 |
import com.iver.cit.gvsig.fmap.ViewPort; |
52 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
54 |
import com.iver.utiles.XMLEntity; |
55 |
|
56 |
|
57 |
/**
|
58 |
* Clase que representa una vista del proyecto
|
59 |
*
|
60 |
* @author Fernando Gonz?lez Cort?s
|
61 |
*/
|
62 |
public class ProjectView extends ProjectElement { |
63 |
private static int numViews = 0; |
64 |
|
65 |
//public static int METROS = 0;
|
66 |
//public static int KILOMETROS = 1;
|
67 |
//public static int[] unidades = new int[] { METROS, KILOMETROS };
|
68 |
///private Color backgroundColor = new Color(255, 255, 255);
|
69 |
private FMap mapOverViewContext;
|
70 |
private FMap mapContext;
|
71 |
private int m_typeLink = 0; |
72 |
private String m_extLink; |
73 |
private String m_selectedField = null; |
74 |
|
75 |
/**
|
76 |
* DOCUMENT ME!
|
77 |
*
|
78 |
* @return
|
79 |
*/
|
80 |
public FMap getMapContext() {
|
81 |
return mapContext;
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* DOCUMENT ME!
|
86 |
*
|
87 |
* @return
|
88 |
*/
|
89 |
public FMap getMapOverViewContext() {
|
90 |
return mapOverViewContext;
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* DOCUMENT ME!
|
95 |
*
|
96 |
* @param baseName
|
97 |
*
|
98 |
* @return
|
99 |
*/
|
100 |
public static ProjectView createView(String baseName) { |
101 |
ProjectView v = new ProjectView();
|
102 |
v.mapContext = new FMap(new ViewPort(Project.getProjection())); |
103 |
v.mapOverViewContext = new FMap(null); |
104 |
|
105 |
//v.mapOverViewContext = null;
|
106 |
v.setName(baseName + " - " + numViews);
|
107 |
v.setCreationDate(DateFormat.getInstance().format(new Date())); |
108 |
numViews++; |
109 |
|
110 |
return v;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* @see com.iver.cit.gvsig.project.ProjectView#setMapContext(com.iver.cit.gvsig.fmap.FMap)
|
115 |
*/
|
116 |
public void setMapContext(FMap fmap) { |
117 |
mapContext = fmap; |
118 |
} |
119 |
|
120 |
/**
|
121 |
* DOCUMENT ME!
|
122 |
*
|
123 |
* @param fmap DOCUMENT ME!
|
124 |
*/
|
125 |
public void setMapOverViewContext(FMap fmap) { |
126 |
mapOverViewContext = fmap; |
127 |
} |
128 |
|
129 |
/**
|
130 |
* DOCUMENT ME!
|
131 |
*
|
132 |
* @return DOCUMENT ME!
|
133 |
* @throws XMLException
|
134 |
*/
|
135 |
public XMLEntity getXMLEntity() throws XMLException { |
136 |
XMLEntity xml = super.getXMLEntity();
|
137 |
//xml.putProperty("nameClass", this.getClass().getName());
|
138 |
xml.putProperty("numViews", numViews);
|
139 |
xml.putProperty("m_selectedField", m_selectedField);
|
140 |
xml.putProperty("m_typeLink", m_typeLink);
|
141 |
xml.putProperty("m_extLink", m_extLink);
|
142 |
xml.addChild(mapContext.getXMLEntity()); |
143 |
|
144 |
if (mapOverViewContext != null) { |
145 |
if (mapOverViewContext.getViewPort() != null) { |
146 |
xml.putProperty("mapOverView", true); |
147 |
xml.addChild(mapOverViewContext.getXMLEntity()); |
148 |
} else {
|
149 |
xml.putProperty("mapOverView", false); |
150 |
} |
151 |
} else {
|
152 |
xml.putProperty("mapOverView", false); |
153 |
} |
154 |
|
155 |
return xml;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* DOCUMENT ME!
|
160 |
*
|
161 |
* @param xml DOCUMENT ME!
|
162 |
* @param p DOCUMENT ME!
|
163 |
* @throws XMLException
|
164 |
* @throws DriverException
|
165 |
* @throws DriverIOException
|
166 |
*
|
167 |
* @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
168 |
*/
|
169 |
public void setXMLEntity03(XMLEntity xml, Project p) |
170 |
throws XMLException, DriverException, DriverIOException {
|
171 |
numViews = xml.getIntProperty("numViews");
|
172 |
m_selectedField = xml.getStringProperty("m_selectedField");
|
173 |
m_typeLink = xml.getIntProperty("m_typeLink");
|
174 |
m_extLink = xml.getStringProperty("m_extLink");
|
175 |
setMapContext(FMap.createFromXML03(xml.getChild(0)));
|
176 |
|
177 |
if (xml.getBooleanProperty("mapOverView")) { |
178 |
setMapOverViewContext(FMap.createFromXML03(xml.getChild(1)));
|
179 |
} |
180 |
} |
181 |
|
182 |
/**
|
183 |
* DOCUMENT ME!
|
184 |
*
|
185 |
* @param xml DOCUMENT ME!
|
186 |
* @param p DOCUMENT ME!
|
187 |
* @throws XMLException
|
188 |
* @throws DriverException
|
189 |
* @throws DriverIOException
|
190 |
*
|
191 |
* @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
192 |
*/
|
193 |
public void setXMLEntity(XMLEntity xml, Project p) |
194 |
throws XMLException, DriverException, DriverIOException {
|
195 |
numViews = xml.getIntProperty("numViews");
|
196 |
m_selectedField = xml.getStringProperty("m_selectedField");
|
197 |
m_typeLink = xml.getIntProperty("m_typeLink");
|
198 |
m_extLink = xml.getStringProperty("m_extLink");
|
199 |
setMapContext(FMap.createFromXML(xml.getChild(0)));
|
200 |
|
201 |
if (xml.getBooleanProperty("mapOverView")) { |
202 |
setMapOverViewContext(FMap.createFromXML(xml.getChild(1)));
|
203 |
} |
204 |
} |
205 |
|
206 |
/**
|
207 |
* DOCUMENT ME!
|
208 |
*
|
209 |
* @param p DOCUMENT ME!
|
210 |
*
|
211 |
* @return DOCUMENT ME!
|
212 |
* @throws XMLException
|
213 |
* @throws DriverException
|
214 |
* @throws DriverIOException
|
215 |
*/
|
216 |
public ProjectView cloneProjectView(Project p)
|
217 |
throws XMLException, DriverException, DriverIOException {
|
218 |
return (ProjectView) createFromXML(getXMLEntity(), p);
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* DOCUMENT ME!
|
223 |
*
|
224 |
* @return DOCUMENT ME!
|
225 |
*/
|
226 |
public IProjection getProjection() {
|
227 |
return mapContext.getProjection();
|
228 |
} |
229 |
|
230 |
/**
|
231 |
* DOCUMENT ME!
|
232 |
*
|
233 |
* @return DOCUMENT ME!
|
234 |
*/
|
235 |
public IProjection getOverViewProjection() {
|
236 |
return mapOverViewContext.getProjection();
|
237 |
} |
238 |
|
239 |
/**
|
240 |
* DOCUMENT ME!
|
241 |
*
|
242 |
* @return DOCUMENT ME!
|
243 |
*/
|
244 |
public String getExtLink() { |
245 |
return m_extLink;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* DOCUMENT ME!
|
250 |
*
|
251 |
* @return DOCUMENT ME!
|
252 |
*/
|
253 |
public int getTypeLink() { |
254 |
return m_typeLink;
|
255 |
} |
256 |
|
257 |
/**
|
258 |
* Se selecciona la extensi?n para realizar cuando se quiera el link.
|
259 |
*
|
260 |
* @param s nombre del campo.
|
261 |
*/
|
262 |
public void setExtLink(String s) { |
263 |
m_extLink = s; |
264 |
} |
265 |
|
266 |
/**
|
267 |
* Se selecciona el tipo de fichero para realizar cuando se quiera el link.
|
268 |
*
|
269 |
* @param i tipo de fichero.
|
270 |
*/
|
271 |
public void setTypeLink(int i) { |
272 |
m_typeLink = i; |
273 |
} |
274 |
|
275 |
/**
|
276 |
* DOCUMENT ME!
|
277 |
*
|
278 |
* @param c DOCUMENT ME!
|
279 |
*/
|
280 |
public void setBackColor(Color c) { |
281 |
// getMapContext().getViewPort().addViewPortListener(getMapContext()
|
282 |
// .getEventBuffer());
|
283 |
getMapContext().getViewPort().setBackColor(c); |
284 |
//getMapContext().getViewPort().removeViewPortListener(getMapContext()
|
285 |
// .getEventBuffer());
|
286 |
} |
287 |
|
288 |
/**
|
289 |
* Se selecciona el nombre del campo para realizar cuando se quiera el
|
290 |
* link.
|
291 |
*
|
292 |
* @param s nombre del campo.
|
293 |
*/
|
294 |
public void setSelectedField(String s) { |
295 |
m_selectedField = s; |
296 |
} |
297 |
|
298 |
/**
|
299 |
* DOCUMENT ME!
|
300 |
*
|
301 |
* @return DOCUMENT ME!
|
302 |
*/
|
303 |
public String getSelectedField() { |
304 |
return m_selectedField;
|
305 |
} |
306 |
} |