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