root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / castor / ProjectView.java @ 1094
History | View | Annotate | Download (5.15 KB)
1 |
package com.iver.cit.gvsig.project.castor; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.text.DateFormat; |
5 |
import java.util.Date; |
6 |
|
7 |
import org.cresques.cts.IProjection; |
8 |
|
9 |
import com.iver.cit.gvsig.fmap.DriverException; |
10 |
import com.iver.cit.gvsig.fmap.FMap; |
11 |
import com.iver.cit.gvsig.fmap.ViewPort; |
12 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
13 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
14 |
import com.iver.utiles.XMLEntity; |
15 |
|
16 |
|
17 |
/**
|
18 |
* Clase que representa una vista del proyecto
|
19 |
*
|
20 |
* @author Fernando Gonz?lez Cort?s
|
21 |
*/
|
22 |
public class ProjectView extends ProjectElement { |
23 |
private static int numViews = 0; |
24 |
|
25 |
//public static int METROS = 0;
|
26 |
//public static int KILOMETROS = 1;
|
27 |
//public static int[] unidades = new int[] { METROS, KILOMETROS };
|
28 |
///private Color backgroundColor = new Color(255, 255, 255);
|
29 |
private FMap mapOverViewContext;
|
30 |
private FMap mapContext;
|
31 |
private int m_typeLink = 0; |
32 |
private String m_extLink; |
33 |
private String m_selectedField = null; |
34 |
|
35 |
/**
|
36 |
* DOCUMENT ME!
|
37 |
*
|
38 |
* @return
|
39 |
*/
|
40 |
public FMap getMapContext() {
|
41 |
return mapContext;
|
42 |
} |
43 |
|
44 |
/**
|
45 |
* DOCUMENT ME!
|
46 |
*
|
47 |
* @return
|
48 |
*/
|
49 |
public FMap getMapOverViewContext() {
|
50 |
return mapOverViewContext;
|
51 |
} |
52 |
|
53 |
/**
|
54 |
* DOCUMENT ME!
|
55 |
*
|
56 |
* @param baseName
|
57 |
*
|
58 |
* @return
|
59 |
*/
|
60 |
public static ProjectView createView(String baseName) { |
61 |
ProjectView v = new ProjectView();
|
62 |
v.mapContext = new FMap(new ViewPort(Project.getProjection())); |
63 |
v.mapOverViewContext = new FMap(null); |
64 |
|
65 |
//v.mapOverViewContext = null;
|
66 |
v.setName(baseName + " - " + numViews);
|
67 |
v.setCreationDate(DateFormat.getInstance().format(new Date())); |
68 |
numViews++; |
69 |
|
70 |
return v;
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* @see com.iver.cit.gvsig.project.ProjectView#setMapContext(com.iver.cit.gvsig.fmap.FMap)
|
75 |
*/
|
76 |
public void setMapContext(FMap fmap) { |
77 |
mapContext = fmap; |
78 |
} |
79 |
|
80 |
/**
|
81 |
* DOCUMENT ME!
|
82 |
*
|
83 |
* @param fmap DOCUMENT ME!
|
84 |
*/
|
85 |
public void setMapOverViewContext(FMap fmap) { |
86 |
mapOverViewContext = fmap; |
87 |
} |
88 |
|
89 |
/**
|
90 |
* DOCUMENT ME!
|
91 |
*
|
92 |
* @return DOCUMENT ME!
|
93 |
*/
|
94 |
public XMLEntity getXMLEntity() {
|
95 |
XMLEntity xml = super.getXMLEntity();
|
96 |
//xml.putProperty("nameClass", this.getClass().getName());
|
97 |
xml.putProperty("numViews", numViews);
|
98 |
xml.putProperty("m_selectedField", m_selectedField);
|
99 |
xml.putProperty("m_typeLink", m_typeLink);
|
100 |
xml.putProperty("m_extLink", m_extLink);
|
101 |
xml.addChild(mapContext.getXMLEntity()); |
102 |
|
103 |
if ((mapOverViewContext != null) && |
104 |
(mapOverViewContext.getViewPort().getExtent() != null)) {
|
105 |
xml.putProperty("mapOverView", true); |
106 |
xml.addChild(mapOverViewContext.getXMLEntity()); |
107 |
} else {
|
108 |
xml.putProperty("mapOverView", false); |
109 |
} |
110 |
|
111 |
return xml;
|
112 |
} |
113 |
|
114 |
/**
|
115 |
* DOCUMENT ME!
|
116 |
*
|
117 |
* @param xml DOCUMENT ME!
|
118 |
* @param p DOCUMENT ME!
|
119 |
* @throws XMLException
|
120 |
* @throws DriverException
|
121 |
* @throws DriverIOException
|
122 |
*
|
123 |
* @see com.iver.cit.gvsig.project.castor.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
124 |
*/
|
125 |
public void setXMLEntity(XMLEntity xml, Project p) |
126 |
throws XMLException, DriverException, DriverIOException {
|
127 |
numViews = xml.getIntProperty("numViews");
|
128 |
m_selectedField = xml.getStringProperty("m_selectedField");
|
129 |
m_typeLink = xml.getIntProperty("m_typeLink");
|
130 |
m_extLink = xml.getStringProperty("m_extLink");
|
131 |
setMapContext(FMap.createFromXML(xml.getChild(0)));
|
132 |
|
133 |
if (xml.getBooleanProperty("mapOverView")) { |
134 |
setMapOverViewContext(FMap.createFromXML(xml.getChild(1)));
|
135 |
} |
136 |
} |
137 |
|
138 |
/**
|
139 |
* DOCUMENT ME!
|
140 |
*
|
141 |
* @param p DOCUMENT ME!
|
142 |
*
|
143 |
* @return DOCUMENT ME!
|
144 |
* @throws XMLException
|
145 |
* @throws DriverException
|
146 |
* @throws DriverIOException
|
147 |
*/
|
148 |
public ProjectView cloneProjectView(Project p)
|
149 |
throws XMLException, DriverException, DriverIOException {
|
150 |
return (ProjectView) createFromXML(getXMLEntity(), p);
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* DOCUMENT ME!
|
155 |
*
|
156 |
* @return DOCUMENT ME!
|
157 |
*/
|
158 |
public IProjection getProjection() {
|
159 |
return mapContext.getProjection();
|
160 |
} |
161 |
|
162 |
/**
|
163 |
* DOCUMENT ME!
|
164 |
*
|
165 |
* @return DOCUMENT ME!
|
166 |
*/
|
167 |
public IProjection getOverViewProjection() {
|
168 |
return mapOverViewContext.getProjection();
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* DOCUMENT ME!
|
173 |
*
|
174 |
* @return DOCUMENT ME!
|
175 |
*/
|
176 |
public String getExtLink() { |
177 |
return m_extLink;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* DOCUMENT ME!
|
182 |
*
|
183 |
* @return DOCUMENT ME!
|
184 |
*/
|
185 |
public int getTypeLink() { |
186 |
return m_typeLink;
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* Se selecciona la extensi?n para realizar cuando se quiera el link.
|
191 |
*
|
192 |
* @param s nombre del campo.
|
193 |
*/
|
194 |
public void setExtLink(String s) { |
195 |
m_extLink = s; |
196 |
} |
197 |
|
198 |
/**
|
199 |
* Se selecciona el tipo de fichero para realizar cuando se quiera el link.
|
200 |
*
|
201 |
* @param i tipo de fichero.
|
202 |
*/
|
203 |
public void setTypeLink(int i) { |
204 |
m_typeLink = i; |
205 |
} |
206 |
|
207 |
/**
|
208 |
* DOCUMENT ME!
|
209 |
*
|
210 |
* @param c DOCUMENT ME!
|
211 |
*/
|
212 |
public void setBackColor(Color c) { |
213 |
getMapContext().getViewPort().addColorListener(getMapContext() |
214 |
.getEventBuffer()); |
215 |
getMapContext().getViewPort().setBackColor(c); |
216 |
getMapContext().getViewPort().removeColorListener(getMapContext() |
217 |
.getEventBuffer()); |
218 |
} |
219 |
|
220 |
/**
|
221 |
* Se selecciona el nombre del campo para realizar cuando se quiera el
|
222 |
* link.
|
223 |
*
|
224 |
* @param s nombre del campo.
|
225 |
*/
|
226 |
public void setSelectedField(String s) { |
227 |
m_selectedField = s; |
228 |
} |
229 |
|
230 |
/**
|
231 |
* DOCUMENT ME!
|
232 |
*
|
233 |
* @return DOCUMENT ME!
|
234 |
*/
|
235 |
public String getSelectedField() { |
236 |
return m_selectedField;
|
237 |
} |
238 |
} |