svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / castor / ProjectView.java @ 1201
History | View | Annotate | Download (6.35 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.castor; |
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 |
*/
|
134 |
public XMLEntity getXMLEntity() {
|
135 |
XMLEntity xml = super.getXMLEntity();
|
136 |
//xml.putProperty("nameClass", this.getClass().getName());
|
137 |
xml.putProperty("numViews", numViews);
|
138 |
xml.putProperty("m_selectedField", m_selectedField);
|
139 |
xml.putProperty("m_typeLink", m_typeLink);
|
140 |
xml.putProperty("m_extLink", m_extLink);
|
141 |
xml.addChild(mapContext.getXMLEntity()); |
142 |
|
143 |
if ((mapOverViewContext != null) && |
144 |
(mapOverViewContext.getViewPort().getExtent() != null)) {
|
145 |
xml.putProperty("mapOverView", true); |
146 |
xml.addChild(mapOverViewContext.getXMLEntity()); |
147 |
} else {
|
148 |
xml.putProperty("mapOverView", false); |
149 |
} |
150 |
|
151 |
return xml;
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* DOCUMENT ME!
|
156 |
*
|
157 |
* @param xml DOCUMENT ME!
|
158 |
* @param p DOCUMENT ME!
|
159 |
* @throws XMLException
|
160 |
* @throws DriverException
|
161 |
* @throws DriverIOException
|
162 |
*
|
163 |
* @see com.iver.cit.gvsig.project.castor.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
164 |
*/
|
165 |
public void setXMLEntity(XMLEntity xml, Project p) |
166 |
throws XMLException, DriverException, DriverIOException {
|
167 |
numViews = xml.getIntProperty("numViews");
|
168 |
m_selectedField = xml.getStringProperty("m_selectedField");
|
169 |
m_typeLink = xml.getIntProperty("m_typeLink");
|
170 |
m_extLink = xml.getStringProperty("m_extLink");
|
171 |
setMapContext(FMap.createFromXML(xml.getChild(0)));
|
172 |
|
173 |
if (xml.getBooleanProperty("mapOverView")) { |
174 |
setMapOverViewContext(FMap.createFromXML(xml.getChild(1)));
|
175 |
} |
176 |
} |
177 |
|
178 |
/**
|
179 |
* DOCUMENT ME!
|
180 |
*
|
181 |
* @param p DOCUMENT ME!
|
182 |
*
|
183 |
* @return DOCUMENT ME!
|
184 |
* @throws XMLException
|
185 |
* @throws DriverException
|
186 |
* @throws DriverIOException
|
187 |
*/
|
188 |
public ProjectView cloneProjectView(Project p)
|
189 |
throws XMLException, DriverException, DriverIOException {
|
190 |
return (ProjectView) createFromXML(getXMLEntity(), p);
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* DOCUMENT ME!
|
195 |
*
|
196 |
* @return DOCUMENT ME!
|
197 |
*/
|
198 |
public IProjection getProjection() {
|
199 |
return mapContext.getProjection();
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* DOCUMENT ME!
|
204 |
*
|
205 |
* @return DOCUMENT ME!
|
206 |
*/
|
207 |
public IProjection getOverViewProjection() {
|
208 |
return mapOverViewContext.getProjection();
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* DOCUMENT ME!
|
213 |
*
|
214 |
* @return DOCUMENT ME!
|
215 |
*/
|
216 |
public String getExtLink() { |
217 |
return m_extLink;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* DOCUMENT ME!
|
222 |
*
|
223 |
* @return DOCUMENT ME!
|
224 |
*/
|
225 |
public int getTypeLink() { |
226 |
return m_typeLink;
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* Se selecciona la extensi?n para realizar cuando se quiera el link.
|
231 |
*
|
232 |
* @param s nombre del campo.
|
233 |
*/
|
234 |
public void setExtLink(String s) { |
235 |
m_extLink = s; |
236 |
} |
237 |
|
238 |
/**
|
239 |
* Se selecciona el tipo de fichero para realizar cuando se quiera el link.
|
240 |
*
|
241 |
* @param i tipo de fichero.
|
242 |
*/
|
243 |
public void setTypeLink(int i) { |
244 |
m_typeLink = i; |
245 |
} |
246 |
|
247 |
/**
|
248 |
* DOCUMENT ME!
|
249 |
*
|
250 |
* @param c DOCUMENT ME!
|
251 |
*/
|
252 |
public void setBackColor(Color c) { |
253 |
// getMapContext().getViewPort().addViewPortListener(getMapContext()
|
254 |
// .getEventBuffer());
|
255 |
getMapContext().getViewPort().setBackColor(c); |
256 |
//getMapContext().getViewPort().removeViewPortListener(getMapContext()
|
257 |
// .getEventBuffer());
|
258 |
} |
259 |
|
260 |
/**
|
261 |
* Se selecciona el nombre del campo para realizar cuando se quiera el
|
262 |
* link.
|
263 |
*
|
264 |
* @param s nombre del campo.
|
265 |
*/
|
266 |
public void setSelectedField(String s) { |
267 |
m_selectedField = s; |
268 |
} |
269 |
|
270 |
/**
|
271 |
* DOCUMENT ME!
|
272 |
*
|
273 |
* @return DOCUMENT ME!
|
274 |
*/
|
275 |
public String getSelectedField() { |
276 |
return m_selectedField;
|
277 |
} |
278 |
} |