svn-gvsig-desktop / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / rendering / Annotation_Legend.java @ 11615
History | View | Annotate | Download (8.86 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.fmap.rendering; |
42 |
|
43 |
import java.awt.Color; |
44 |
import java.util.ArrayList; |
45 |
|
46 |
import com.hardcode.gdbms.engine.data.DataSource; |
47 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
48 |
import com.hardcode.gdbms.engine.values.Value; |
49 |
import com.iver.cit.gvsig.fmap.DriverException; |
50 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
51 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
52 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
53 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
54 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
55 |
import com.iver.utiles.XMLEntity; |
56 |
|
57 |
/**
|
58 |
* Leyenda vectorial para labels.
|
59 |
*
|
60 |
* @author Vicente Caballero Navarro
|
61 |
*/
|
62 |
public class Annotation_Legend implements VectorialLegend { |
63 |
private String fieldName; |
64 |
|
65 |
protected int fieldId = -1; |
66 |
|
67 |
private String labelFieldName; |
68 |
|
69 |
private String labelFieldHeight; |
70 |
|
71 |
private String labelFieldRotation; |
72 |
|
73 |
private FSymbol defaultSymbol = new FSymbol( |
74 |
FConstant.SYMBOL_TYPE_TEXT); |
75 |
|
76 |
private int shapeType; |
77 |
|
78 |
private boolean useDefaultSymbol = false; |
79 |
|
80 |
public Annotation_Legend() {
|
81 |
defaultSymbol.setFontSizeInPixels(true);
|
82 |
defaultSymbol.setFontColor(Color.black);
|
83 |
defaultSymbol.setRotation(0);
|
84 |
defaultSymbol.setFontSize(10);
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
|
89 |
* ISymbol)
|
90 |
*/
|
91 |
public void addSymbol(Object key, ISymbol symbol) { |
92 |
} |
93 |
|
94 |
/**
|
95 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
|
96 |
*/
|
97 |
public void clear() { |
98 |
} |
99 |
|
100 |
/**
|
101 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getDescriptions()
|
102 |
*/
|
103 |
public String[] getDescriptions() { |
104 |
return null; |
105 |
} |
106 |
|
107 |
/**
|
108 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
|
109 |
*/
|
110 |
public ISymbol[] getSymbols() { |
111 |
return null; |
112 |
} |
113 |
|
114 |
/**
|
115 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getFieldName()
|
116 |
*/
|
117 |
public String getFieldName() { |
118 |
return fieldName;
|
119 |
} |
120 |
|
121 |
/**
|
122 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
|
123 |
*/
|
124 |
public void setDefaultSymbol(ISymbol s) { |
125 |
defaultSymbol = (FSymbol) s; |
126 |
} |
127 |
|
128 |
/*
|
129 |
* (non-Javadoc)
|
130 |
*
|
131 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelField()
|
132 |
*/
|
133 |
public String getLabelField() { |
134 |
return labelFieldName;
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
|
139 |
*/
|
140 |
public void setLabelField(String fieldName) { |
141 |
labelFieldName = fieldName; |
142 |
} |
143 |
|
144 |
/**
|
145 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setField()
|
146 |
*/
|
147 |
public void setFieldName(String str) { |
148 |
fieldName = str; |
149 |
} |
150 |
|
151 |
/**
|
152 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
|
153 |
*/
|
154 |
public ISymbol getSymbol(int recordIndex) throws DriverException { |
155 |
return null; |
156 |
} |
157 |
|
158 |
/**
|
159 |
* Devuelve un s?mbolo a partir de una IFeature. OJO!! Cuando usamos un
|
160 |
* feature iterator de base de datos el ?nico campo que vendr? rellenado es
|
161 |
* el de fieldID. Los dem?s vendr?n a nulos para ahorra tiempo de creaci?n.
|
162 |
*
|
163 |
* @param feat
|
164 |
* IFeature
|
165 |
*
|
166 |
* @return S?mbolo.
|
167 |
*/
|
168 |
public ISymbol getSymbolByFeature(IFeature feat) {
|
169 |
return null; |
170 |
} |
171 |
|
172 |
/**
|
173 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
|
174 |
*/
|
175 |
public ISymbol getDefaultSymbol() {
|
176 |
return defaultSymbol;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getValues()
|
181 |
*/
|
182 |
public Object[] getValues() { |
183 |
// return symbols.keySet().toArray(new Object[0]);
|
184 |
return null; |
185 |
} |
186 |
|
187 |
/**
|
188 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
|
189 |
*/
|
190 |
public XMLEntity getXMLEntity() {
|
191 |
XMLEntity xml = new XMLEntity();
|
192 |
xml.putProperty("className", this.getClass().getName()); |
193 |
xml.putProperty("fieldName", fieldName);
|
194 |
xml.putProperty("labelfield", labelFieldName);
|
195 |
xml.putProperty("labelFieldHeight", labelFieldHeight);
|
196 |
xml.putProperty("labelFieldRotation", labelFieldRotation);
|
197 |
|
198 |
xml.putProperty("useDefaultSymbol", useDefaultSymbol);
|
199 |
xml.addChild(getDefaultSymbol().getXMLEntity()); |
200 |
return xml;
|
201 |
} |
202 |
|
203 |
/**
|
204 |
* Inserta el XMLEntity.
|
205 |
*
|
206 |
* @param xml
|
207 |
* XMLEntity.
|
208 |
*/
|
209 |
public void setXMLEntity03(XMLEntity xml) { |
210 |
|
211 |
} |
212 |
|
213 |
/**
|
214 |
* Inserta el XMLEntity.
|
215 |
*
|
216 |
* @param xml
|
217 |
* XMLEntity.
|
218 |
*/
|
219 |
public void setXMLEntity(XMLEntity xml) { |
220 |
clear(); |
221 |
setFieldName(xml.getStringProperty("fieldName"));
|
222 |
setLabelField(xml.getStringProperty("labelfield"));
|
223 |
|
224 |
if (xml.contains("labelFieldHeight")) { |
225 |
setLabelHeightField(xml.getStringProperty("labelFieldHeight"));
|
226 |
} |
227 |
|
228 |
if (xml.contains("labelFieldRotation")) { |
229 |
setLabelRotationField(xml.getStringProperty("labelFieldRotation"));
|
230 |
} |
231 |
|
232 |
useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol");
|
233 |
defaultSymbol = FSymbol.createFromXML(xml.getChild(0));
|
234 |
|
235 |
} |
236 |
|
237 |
/**
|
238 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
|
239 |
*/
|
240 |
public Legend cloneLegend() throws XMLException { |
241 |
return LegendFactory.createFromXML(getXMLEntity());
|
242 |
} |
243 |
|
244 |
/*
|
245 |
* (non-Javadoc)
|
246 |
*
|
247 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
|
248 |
*/
|
249 |
public void setDataSource(DataSource ds) throws FieldNotFoundException, |
250 |
DriverException { |
251 |
// try {
|
252 |
// dataSource = ds;
|
253 |
// ds.start();
|
254 |
// fieldId = ds.getFieldIndexByName(fieldName);
|
255 |
// ds.stop();
|
256 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
257 |
// throw new DriverException(e);
|
258 |
// }
|
259 |
} |
260 |
|
261 |
/*
|
262 |
* (non-Javadoc)
|
263 |
*
|
264 |
* @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getSymbolByValue(com.hardcode.gdbms.engine.values.Value)
|
265 |
*/
|
266 |
public ISymbol getSymbolByValue(Value key) {
|
267 |
return null; |
268 |
} |
269 |
|
270 |
/*
|
271 |
* (non-Javadoc)
|
272 |
*
|
273 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType()
|
274 |
*/
|
275 |
public int getShapeType() { |
276 |
return shapeType;
|
277 |
} |
278 |
|
279 |
/*
|
280 |
* (non-Javadoc)
|
281 |
*
|
282 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
|
283 |
*/
|
284 |
public String getLabelHeightField() { |
285 |
return labelFieldHeight;
|
286 |
} |
287 |
|
288 |
/**
|
289 |
* Inserta el alto de campo.
|
290 |
*
|
291 |
* @param str
|
292 |
* alto.
|
293 |
*/
|
294 |
public void setLabelHeightField(String str) { |
295 |
labelFieldHeight = str; |
296 |
} |
297 |
|
298 |
/*
|
299 |
* (non-Javadoc)
|
300 |
*
|
301 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
|
302 |
*/
|
303 |
public String getLabelRotationField() { |
304 |
return labelFieldRotation;
|
305 |
} |
306 |
|
307 |
/**
|
308 |
* Inserta rotaci?n.
|
309 |
*
|
310 |
* @param str
|
311 |
* Rotaci?n.
|
312 |
*/
|
313 |
public void setLabelRotationField(String str) { |
314 |
labelFieldRotation = str; |
315 |
} |
316 |
|
317 |
/**
|
318 |
* Introduce si se tiene que representar el resto de valores o no.
|
319 |
*
|
320 |
* @param b
|
321 |
* True si se utiliza el resto de valores.
|
322 |
*/
|
323 |
public void useDefaultSymbol(boolean b) { |
324 |
useDefaultSymbol = b; |
325 |
} |
326 |
|
327 |
/**
|
328 |
* Devuelve si se utiliza o no el resto de valores para representarse.
|
329 |
*
|
330 |
* @return True si se utiliza el resto de valores.
|
331 |
*/
|
332 |
public boolean isUseDefaultSymbol() { |
333 |
return useDefaultSymbol;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* Elimina el s?mbolo que tiene como clave el valor que se pasa como
|
338 |
* par?metro.
|
339 |
*
|
340 |
* @param key
|
341 |
* clave.
|
342 |
*/
|
343 |
public void delSymbol(Object key) { |
344 |
} |
345 |
|
346 |
/*
|
347 |
* (non-Javadoc)
|
348 |
*
|
349 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields()
|
350 |
*/
|
351 |
public String[] getUsedFields() { |
352 |
ArrayList usedFields = new ArrayList(); |
353 |
if (getFieldName() != null) |
354 |
usedFields.add(getFieldName()); |
355 |
if (getLabelField() != null) |
356 |
usedFields.add(getLabelField()); |
357 |
if (getLabelHeightField() != null) |
358 |
usedFields.add(getLabelHeightField()); |
359 |
if (getLabelRotationField() != null) |
360 |
usedFields.add(getLabelRotationField()); |
361 |
|
362 |
return (String[]) usedFields.toArray(new String[0]); |
363 |
|
364 |
} |
365 |
|
366 |
public void setShapeType(int shapeType) { |
367 |
// TODO Auto-generated method stub
|
368 |
|
369 |
} |
370 |
|
371 |
public String getSLDString(String layerName) { |
372 |
// TODO Auto-generated method stub
|
373 |
return null; |
374 |
} |
375 |
|
376 |
public void setInPixels(boolean b) { |
377 |
defaultSymbol.setFontSizeInPixels(b); |
378 |
|
379 |
} |
380 |
} |