svn-gvsig-desktop / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / rendering / Annotation_Legend.java @ 26937
History | View | Annotate | Download (11.3 KB)
1 | 11536 | caballero | /* 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.values.Value; |
||
48 | 24191 | vcaballero | import com.iver.cit.gvsig.fmap.core.CartographicSupportToolkit; |
49 | 11536 | caballero | import com.iver.cit.gvsig.fmap.core.IFeature; |
50 | 13512 | caballero | import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
51 | import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
||
52 | import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
||
53 | import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
||
54 | 11536 | caballero | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
55 | import com.iver.cit.gvsig.fmap.layers.XMLException; |
||
56 | import com.iver.utiles.XMLEntity; |
||
57 | |||
58 | /**
|
||
59 | * Leyenda vectorial para labels.
|
||
60 | *
|
||
61 | * @author Vicente Caballero Navarro
|
||
62 | */
|
||
63 | 14220 | jdominguez | public class Annotation_Legend extends AbstractLegend implements IVectorLegend{ |
64 | 11536 | caballero | private String fieldName; |
65 | |||
66 | 13512 | caballero | protected int fieldId = -1; |
67 | 11536 | caballero | |
68 | 13512 | caballero | private String labelFieldName; |
69 | 11536 | caballero | |
70 | 13512 | caballero | private String labelFieldHeight; |
71 | 11536 | caballero | |
72 | 13512 | caballero | private String labelFieldRotation; |
73 | 11536 | caballero | |
74 | 13512 | caballero | private ITextSymbol defaultSymbol = SymbologyFactory.createDefaultTextSymbol();
|
75 | 11536 | caballero | |
76 | 13512 | caballero | private int shapeType; |
77 | 11536 | caballero | |
78 | 13512 | caballero | private boolean useDefaultSymbol = false; |
79 | 11536 | caballero | |
80 | 13512 | caballero | // private boolean overwrite=true;
|
81 | 11536 | caballero | |
82 | 13512 | caballero | private boolean avoidoverlapping=false; |
83 | 11536 | caballero | |
84 | 13512 | caballero | private boolean deloverlapping=false; |
85 | 11536 | caballero | |
86 | 13512 | caballero | private boolean isFontInPixels; |
87 | 11536 | caballero | |
88 | 13512 | caballero | private boolean pointVisible=true; |
89 | 11536 | caballero | |
90 | 24191 | vcaballero | private int units = CartographicSupportToolkit.DefaultMeasureUnit; |
91 | |||
92 | 13512 | caballero | public Annotation_Legend() {
|
93 | isFontInPixels=true;
|
||
94 | defaultSymbol.setTextColor(Color.black);
|
||
95 | ((SimpleTextSymbol)defaultSymbol).setRotation(0);
|
||
96 | defaultSymbol.setFontSize(10);
|
||
97 | } |
||
98 | |||
99 | 11536 | caballero | /**
|
100 | 13512 | caballero | * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
|
101 | * ISymbol)
|
||
102 | */
|
||
103 | public void addSymbol(Object key, ISymbol symbol) { |
||
104 | } |
||
105 | 11536 | caballero | |
106 | 13512 | caballero | /**
|
107 | * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
|
||
108 | */
|
||
109 | public void clear() { |
||
110 | } |
||
111 | 11536 | caballero | |
112 | 13512 | caballero | /**
|
113 | * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getDescriptions()
|
||
114 | */
|
||
115 | public String[] getDescriptions() { |
||
116 | return null; |
||
117 | } |
||
118 | 11536 | caballero | |
119 | 13512 | caballero | /**
|
120 | * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
|
||
121 | */
|
||
122 | public ISymbol[] getSymbols() { |
||
123 | return null; |
||
124 | } |
||
125 | 11536 | caballero | |
126 | 13512 | caballero | /**
|
127 | * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getFieldName()
|
||
128 | */
|
||
129 | public String getFieldName() { |
||
130 | return fieldName;
|
||
131 | } |
||
132 | 11536 | caballero | |
133 | 13512 | caballero | /**
|
134 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
|
||
135 | */
|
||
136 | public void setDefaultSymbol(ISymbol s) { |
||
137 | defaultSymbol = (ITextSymbol) s; |
||
138 | } |
||
139 | 11536 | caballero | |
140 | 13512 | caballero | /*
|
141 | * (non-Javadoc)
|
||
142 | *
|
||
143 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelField()
|
||
144 | */
|
||
145 | public String getLabelField() { |
||
146 | return labelFieldName;
|
||
147 | } |
||
148 | 11536 | caballero | |
149 | 13512 | caballero | /**
|
150 | * @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
|
||
151 | */
|
||
152 | public void setLabelField(String fieldName) { |
||
153 | labelFieldName = fieldName; |
||
154 | } |
||
155 | 11536 | caballero | |
156 | 13512 | caballero | /**
|
157 | * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setField()
|
||
158 | */
|
||
159 | public void setFieldName(String str) { |
||
160 | fieldName = str; |
||
161 | } |
||
162 | 11536 | caballero | |
163 | 13512 | caballero | /**
|
164 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
|
||
165 | */
|
||
166 | public ISymbol getSymbol(int recordIndex){ |
||
167 | return null; |
||
168 | } |
||
169 | 11536 | caballero | |
170 | 13512 | caballero | /**
|
171 | * Devuelve un s?mbolo a partir de una IFeature. OJO!! Cuando usamos un
|
||
172 | * feature iterator de base de datos el ?nico campo que vendr? rellenado es
|
||
173 | * el de fieldID. Los dem?s vendr?n a nulos para ahorra tiempo de creaci?n.
|
||
174 | *
|
||
175 | * @param feat
|
||
176 | * IFeature
|
||
177 | *
|
||
178 | * @return S?mbolo.
|
||
179 | */
|
||
180 | public ISymbol getSymbolByFeature(IFeature feat) {
|
||
181 | return null; |
||
182 | } |
||
183 | 11536 | caballero | |
184 | 13512 | caballero | /**
|
185 | * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
|
||
186 | */
|
||
187 | public ISymbol getDefaultSymbol() {
|
||
188 | return defaultSymbol;
|
||
189 | } |
||
190 | 11536 | caballero | |
191 | 13512 | caballero | /**
|
192 | * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getValues()
|
||
193 | */
|
||
194 | public Object[] getValues() { |
||
195 | // return symbols.keySet().toArray(new Object[0]);
|
||
196 | return null; |
||
197 | } |
||
198 | 11536 | caballero | |
199 | 13512 | caballero | /**
|
200 | * @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
|
||
201 | */
|
||
202 | public XMLEntity getXMLEntity() {
|
||
203 | XMLEntity xml = new XMLEntity();
|
||
204 | xml.putProperty("className", this.getClass().getName()); |
||
205 | xml.putProperty("fieldName", fieldName);
|
||
206 | xml.putProperty("labelfield", labelFieldName);
|
||
207 | xml.putProperty("labelFieldHeight", labelFieldHeight);
|
||
208 | xml.putProperty("labelFieldRotation", labelFieldRotation);
|
||
209 | xml.putProperty("avoidoverlapping",avoidoverlapping);
|
||
210 | xml.putProperty("deloverlapping",deloverlapping);
|
||
211 | 26937 | vcaballero | |
212 | 13512 | caballero | // xml.putProperty("overwrite",overwrite);
|
213 | 24191 | vcaballero | xml.putProperty("units", units);
|
214 | 13512 | caballero | xml.putProperty("isFontInPixels",isFontInPixels);
|
215 | xml.putProperty("pointVisible",pointVisible);
|
||
216 | 11536 | caballero | |
217 | 13512 | caballero | xml.putProperty("useDefaultSymbol", useDefaultSymbol);
|
218 | xml.addChild(getDefaultSymbol().getXMLEntity()); |
||
219 | return xml;
|
||
220 | } |
||
221 | 11536 | caballero | |
222 | 13512 | caballero | /**
|
223 | * Inserta el XMLEntity.
|
||
224 | *
|
||
225 | * @param xml
|
||
226 | * XMLEntity.
|
||
227 | */
|
||
228 | public void setXMLEntity03(XMLEntity xml) { |
||
229 | 11536 | caballero | |
230 | 13512 | caballero | } |
231 | 11536 | caballero | |
232 | 13512 | caballero | /**
|
233 | * Inserta el XMLEntity.
|
||
234 | *
|
||
235 | * @param xml
|
||
236 | * XMLEntity.
|
||
237 | */
|
||
238 | public void setXMLEntity(XMLEntity xml) { |
||
239 | clear(); |
||
240 | setFieldName(xml.getStringProperty("fieldName"));
|
||
241 | setLabelField(xml.getStringProperty("labelfield"));
|
||
242 | 11536 | caballero | |
243 | 13512 | caballero | if (xml.contains("labelFieldHeight")) { |
244 | setLabelHeightField(xml.getStringProperty("labelFieldHeight"));
|
||
245 | } |
||
246 | 11536 | caballero | |
247 | 13512 | caballero | if (xml.contains("labelFieldRotation")) { |
248 | setLabelRotationField(xml.getStringProperty("labelFieldRotation"));
|
||
249 | } |
||
250 | 11536 | caballero | |
251 | 13512 | caballero | useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol");
|
252 | if (xml.contains("avoidoverlapping")){ |
||
253 | avoidoverlapping=xml.getBooleanProperty("avoidoverlapping");
|
||
254 | deloverlapping=xml.getBooleanProperty("deloverlapping");
|
||
255 | } |
||
256 | 24191 | vcaballero | if (xml.contains("pointVisible")) { |
257 | pointVisible = xml.getBooleanProperty("pointVisible");
|
||
258 | } |
||
259 | if (xml.contains("units")) { |
||
260 | units = xml.getIntProperty("units");
|
||
261 | } |
||
262 | 13512 | caballero | if (xml.contains("isFontInPixels")) { |
263 | isFontInPixels=xml.getBooleanProperty("isFontInPixels");
|
||
264 | defaultSymbol = (ITextSymbol)SymbologyFactory.createSymbolFromXML(xml.getChild(0),"default symbol"); |
||
265 | 11536 | caballero | |
266 | 24191 | vcaballero | } |
267 | else {
|
||
268 | 13512 | caballero | FSymbol symbol=(FSymbol)SymbologyFactory.createSymbolFromXML(xml.getChild(0),"default symbol"); |
269 | isFontInPixels =symbol.isFontSizeInPixels(); |
||
270 | pointVisible=symbol.isShapeVisible(); |
||
271 | defaultSymbol=(SimpleTextSymbol)SymbologyFactory.createDefaultTextSymbol(); |
||
272 | } |
||
273 | 11536 | caballero | |
274 | |||
275 | 13512 | caballero | } |
276 | 11536 | caballero | |
277 | 13512 | caballero | /**
|
278 | * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
|
||
279 | */
|
||
280 | public ILegend cloneLegend() throws XMLException { |
||
281 | return LegendFactory.createFromXML(getXMLEntity());
|
||
282 | } |
||
283 | |||
284 | /*
|
||
285 | * (non-Javadoc)
|
||
286 | *
|
||
287 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
|
||
288 | */
|
||
289 | public void setDataSource(DataSource ds) { |
||
290 | // try {
|
||
291 | // dataSource = ds;
|
||
292 | // ds.start();
|
||
293 | // fieldId = ds.getFieldIndexByName(fieldName);
|
||
294 | // ds.stop();
|
||
295 | // } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
296 | // throw new DriverException(e);
|
||
297 | // }
|
||
298 | } |
||
299 | |||
300 | /*
|
||
301 | * (non-Javadoc)
|
||
302 | *
|
||
303 | * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getSymbolByValue(com.hardcode.gdbms.engine.values.Value)
|
||
304 | */
|
||
305 | public ISymbol getSymbolByValue(Value key) {
|
||
306 | return null; |
||
307 | } |
||
308 | |||
309 | /*
|
||
310 | * (non-Javadoc)
|
||
311 | *
|
||
312 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType()
|
||
313 | */
|
||
314 | public int getShapeType() { |
||
315 | return shapeType;
|
||
316 | } |
||
317 | |||
318 | /*
|
||
319 | * (non-Javadoc)
|
||
320 | *
|
||
321 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
|
||
322 | */
|
||
323 | public String getLabelHeightField() { |
||
324 | return labelFieldHeight;
|
||
325 | } |
||
326 | |||
327 | /**
|
||
328 | * Inserta el alto de campo.
|
||
329 | *
|
||
330 | * @param str
|
||
331 | * alto.
|
||
332 | */
|
||
333 | public void setLabelHeightField(String str) { |
||
334 | labelFieldHeight = str; |
||
335 | } |
||
336 | |||
337 | /*
|
||
338 | * (non-Javadoc)
|
||
339 | *
|
||
340 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
|
||
341 | */
|
||
342 | public String getLabelRotationField() { |
||
343 | return labelFieldRotation;
|
||
344 | } |
||
345 | |||
346 | /**
|
||
347 | * Inserta rotaci?n.
|
||
348 | *
|
||
349 | * @param str
|
||
350 | * Rotaci?n.
|
||
351 | */
|
||
352 | public void setLabelRotationField(String str) { |
||
353 | labelFieldRotation = str; |
||
354 | } |
||
355 | |||
356 | /**
|
||
357 | * Introduce si se tiene que representar el resto de valores o no.
|
||
358 | *
|
||
359 | * @param b
|
||
360 | * True si se utiliza el resto de valores.
|
||
361 | */
|
||
362 | public void useDefaultSymbol(boolean b) { |
||
363 | useDefaultSymbol = b; |
||
364 | } |
||
365 | |||
366 | /**
|
||
367 | * Devuelve si se utiliza o no el resto de valores para representarse.
|
||
368 | *
|
||
369 | * @return True si se utiliza el resto de valores.
|
||
370 | */
|
||
371 | public boolean isUseDefaultSymbol() { |
||
372 | return useDefaultSymbol;
|
||
373 | } |
||
374 | |||
375 | /**
|
||
376 | * Elimina el s?mbolo que tiene como clave el valor que se pasa como
|
||
377 | * par?metro.
|
||
378 | *
|
||
379 | * @param key
|
||
380 | * clave.
|
||
381 | */
|
||
382 | public void delSymbol(Object key) { |
||
383 | } |
||
384 | |||
385 | /*
|
||
386 | * (non-Javadoc)
|
||
387 | *
|
||
388 | * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields()
|
||
389 | */
|
||
390 | public String[] getUsedFields() { |
||
391 | ArrayList usedFields = new ArrayList(); |
||
392 | if (getFieldName() != null) |
||
393 | usedFields.add(getFieldName()); |
||
394 | if (getLabelField() != null) |
||
395 | usedFields.add(getLabelField()); |
||
396 | if (getLabelHeightField() != null) |
||
397 | usedFields.add(getLabelHeightField()); |
||
398 | if (getLabelRotationField() != null) |
||
399 | usedFields.add(getLabelRotationField()); |
||
400 | |||
401 | return (String[]) usedFields.toArray(new String[0]); |
||
402 | |||
403 | } |
||
404 | |||
405 | 11536 | caballero | public void setShapeType(int shapeType) { |
406 | // TODO Auto-generated method stub
|
||
407 | |||
408 | } |
||
409 | |||
410 | public String getSLDString(String layerName) { |
||
411 | // TODO Auto-generated method stub
|
||
412 | return null; |
||
413 | } |
||
414 | 13512 | caballero | // public void setIsOverWrite(boolean b) {
|
415 | // overwrite=b;
|
||
416 | 11536 | caballero | //
|
417 | 13512 | caballero | // }
|
418 | 11536 | caballero | |
419 | 13512 | caballero | // public boolean isOverWrite() {
|
420 | // return overwrite;
|
||
421 | // }
|
||
422 | 11536 | caballero | |
423 | 13512 | caballero | public boolean isAvoidOverLapping() { |
424 | return avoidoverlapping;
|
||
425 | } |
||
426 | 11536 | caballero | |
427 | 13512 | caballero | public void setAvoidOverLapping(boolean avoidoverlapping) { |
428 | this.avoidoverlapping = avoidoverlapping;
|
||
429 | } |
||
430 | 11536 | caballero | |
431 | 13512 | caballero | public boolean isDelOverLapping() { |
432 | return deloverlapping;
|
||
433 | } |
||
434 | 11536 | caballero | |
435 | 13512 | caballero | public void setDelOverLapping(boolean deloverlapping) { |
436 | this.deloverlapping = deloverlapping;
|
||
437 | 11536 | caballero | } |
438 | |||
439 | 13512 | caballero | public ZSort getZSort() {
|
440 | // TODO Auto-generated method stub
|
||
441 | return null; |
||
442 | } |
||
443 | 11536 | caballero | |
444 | 13512 | caballero | public void setZSort(ZSort zSort) { |
445 | // TODO Auto-generated method stub
|
||
446 | 11536 | caballero | |
447 | } |
||
448 | 13512 | caballero | public String getClassName() { |
449 | return this.getClass().getName(); |
||
450 | } |
||
451 | 11536 | caballero | |
452 | 13512 | caballero | public boolean isFontSizeInPixels() { |
453 | return isFontInPixels;
|
||
454 | 11536 | caballero | } |
455 | 13512 | caballero | |
456 | public void setFontInPixels(boolean isFontInPixels) { |
||
457 | this.isFontInPixels = isFontInPixels;
|
||
458 | } |
||
459 | |||
460 | 24191 | vcaballero | public int getUnits() { |
461 | return units;
|
||
462 | } |
||
463 | |||
464 | public void setUnits(int units) { |
||
465 | 26937 | vcaballero | if(units == -1){ |
466 | this.isFontInPixels = true; |
||
467 | } |
||
468 | 24191 | vcaballero | this.units = units;
|
469 | } |
||
470 | |||
471 | 13512 | caballero | public void setPointVisible(boolean b) { |
472 | this.pointVisible=b;
|
||
473 | |||
474 | } |
||
475 | |||
476 | public boolean isPointVisible() { |
||
477 | return pointVisible;
|
||
478 | } |
||
479 | 21473 | jmvivo | |
480 | public boolean isSuitableForShapeType(int shapeType) { |
||
481 | return this.shapeType == shapeType; |
||
482 | } |
||
483 | 11536 | caballero | } |