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