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