root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FSymbol.java @ 7000
History | View | Annotate | Download (30.5 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.fmap.core.v02; |
48 |
|
49 |
import java.awt.BasicStroke; |
50 |
import java.awt.Color; |
51 |
import java.awt.Font; |
52 |
import java.awt.Graphics2D; |
53 |
import java.awt.Image; |
54 |
import java.awt.Paint; |
55 |
import java.awt.Rectangle; |
56 |
import java.awt.Stroke; |
57 |
import java.awt.image.BufferedImage; |
58 |
import java.awt.image.ImageObserver; |
59 |
import java.net.MalformedURLException; |
60 |
import java.net.URI; |
61 |
import java.net.URISyntaxException; |
62 |
import java.util.StringTokenizer; |
63 |
import javax.swing.ImageIcon; |
64 |
|
65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
66 |
import com.iver.cit.gvsig.fmap.core.ISLDCompatible; |
67 |
import com.iver.cit.gvsig.fmap.core.SLDTags; |
68 |
import com.iver.cit.gvsig.fmap.core.SLDUtils; |
69 |
import com.iver.cit.gvsig.fmap.rendering.XmlBuilder; |
70 |
import com.iver.utiles.StringUtilities; |
71 |
import com.iver.utiles.XMLEntity; |
72 |
|
73 |
|
74 |
/**
|
75 |
* S?mbolo utilizado para guardar las caracter?sticas que se deben de aplicar a
|
76 |
* los Shapes a dibujar.
|
77 |
*
|
78 |
* @author Vicente Caballero Navarro
|
79 |
*/
|
80 |
public class FSymbol implements ISLDCompatible{ |
81 |
private static BufferedImage img = new BufferedImage(1, 1, |
82 |
BufferedImage.TYPE_INT_ARGB);
|
83 |
private static Rectangle rect = new Rectangle(0, 0, 1, 1); |
84 |
private static Color selectionColor = Color.YELLOW; |
85 |
private int m_symbolType; |
86 |
private int m_Style; |
87 |
private boolean m_useOutline; |
88 |
private Color m_Color; |
89 |
private Color m_outlineColor; |
90 |
private Font m_Font; |
91 |
private Color m_FontColor; |
92 |
private float m_FontSize; |
93 |
private int rgb; |
94 |
private ImageObserver imgObserver; |
95 |
|
96 |
/**
|
97 |
* Si <code>m_bUseFontSize</code> viene a false entonces m_FontSize viene
|
98 |
* en unidades de mapa (metros)
|
99 |
*/
|
100 |
private boolean m_bUseFontSizeInPixels; |
101 |
|
102 |
/**
|
103 |
* <code>m_bDrawShape</code> indica si queremos dibujar el shape de fondo.
|
104 |
* Es ?til cuando est?s etiquetando y no quieres que se dibuje el s?mbolo
|
105 |
* que te sirve de base para etiquetar.
|
106 |
*/
|
107 |
private boolean m_bDrawShape = true; |
108 |
private int m_Size; |
109 |
private Image m_Icon; |
110 |
private URI m_IconURI; |
111 |
private int m_Rotation; |
112 |
private Paint m_Fill; |
113 |
public String m_LinePattern = "0"; // Solo para poder mostrarlo cuando vamos a seleccionar un s?mbolo |
114 |
|
115 |
// En realidad lo podemos ver de BasicStroke, pero....
|
116 |
// ya veremos si luego lo quitamos.
|
117 |
private Stroke m_Stroke; |
118 |
|
119 |
//private float m_stroke=0;
|
120 |
// public int m_Transparency; // Ya la lleva dentro del Color
|
121 |
private boolean m_bUseSize; // Si est? a true, m_Size viene en coordenadas de mundo real. |
122 |
private int m_AlingVert; |
123 |
private int m_AlingHoriz; |
124 |
private String m_Descrip; |
125 |
public Color m_BackColor; |
126 |
public Paint m_BackFill; |
127 |
|
128 |
/**
|
129 |
* Converts the comma-delimited string into a List of trimmed strings.
|
130 |
*
|
131 |
* @param linePattern a String with comma-delimited values
|
132 |
* @param lineWidth DOCUMENT ME!
|
133 |
*
|
134 |
* @return a List of the Strings that were delimited by commas
|
135 |
*
|
136 |
* @throws IllegalArgumentException DOCUMENT ME!
|
137 |
*/
|
138 |
public static float[] toArray(String linePattern, float lineWidth) { |
139 |
StringTokenizer st = new StringTokenizer(linePattern, ","); |
140 |
int numTokens = st.countTokens();
|
141 |
|
142 |
float[] array = new float[numTokens]; |
143 |
|
144 |
for (int i = 0; i < numTokens; i++) { |
145 |
String string = st.nextToken();
|
146 |
array[i] = Float.parseFloat(string) * lineWidth;
|
147 |
|
148 |
if (array[i] <= 0) { |
149 |
return null; |
150 |
} |
151 |
} |
152 |
|
153 |
return array;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* Crea un nuevo FSymbol.
|
158 |
*/
|
159 |
FSymbol() { |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Creates a new FSymbol object.
|
164 |
*
|
165 |
* @param tipoSymbol Tipo de s?mbolo.
|
166 |
* @param c Color.
|
167 |
*/
|
168 |
public FSymbol(int tipoSymbol, Color c) { |
169 |
createSymbol(tipoSymbol, c); |
170 |
} |
171 |
|
172 |
/**
|
173 |
* Crea un nuevo FSymbol.
|
174 |
*
|
175 |
* @param tipoSymbol Tipo de S?mbolo.
|
176 |
* case FConstant.SYMBOL_TYPE_POINT:
|
177 |
case FConstant.SYMBOL_TYPE_POINTZ:
|
178 |
case FConstant.SYMBOL_TYPE_MULTIPOINT:
|
179 |
m_bUseSize = true; // Esto es lo primero que hay que hacer siempre
|
180 |
|
181 |
// para evitar un StackOverflow
|
182 |
m_useOutline = false;
|
183 |
setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
|
184 |
setSize(5); //pixels
|
185 |
|
186 |
break;
|
187 |
|
188 |
case FConstant.SYMBOL_TYPE_LINE:
|
189 |
case FConstant.SYMBOL_TYPE_POLYLINEZ:
|
190 |
case FConstant.SYMBOL_TYPE_POLYGONZ:
|
191 |
setStroke(new BasicStroke());
|
192 |
setStyle(FConstant.SYMBOL_STYLE_LINE_SOLID);
|
193 |
|
194 |
break;
|
195 |
|
196 |
case FConstant.SYMBOL_TYPE_FILL:
|
197 |
setStroke(new BasicStroke());
|
198 |
setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
|
199 |
|
200 |
break;
|
201 |
case FShape.MULTI:
|
202 |
m_bUseSize = true;
|
203 |
setStroke(new BasicStroke());
|
204 |
setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
|
205 |
|
206 |
// setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
|
207 |
setSize(5); //pixels
|
208 |
break;
|
209 |
|
210 |
case FConstant.SYMBOL_TYPE_TEXT:
|
211 |
setStroke(new BasicStroke());
|
212 |
setStyle(FConstant.SYMBOL_STYLE_TEXT_NORMAL);
|
213 |
setFont(new Font("Dialog",Font.PLAIN,12));
|
214 |
break;
|
215 |
|
216 |
*/
|
217 |
public FSymbol(int tipoSymbol) { |
218 |
int numreg = (int) (Math.random() * 100); |
219 |
Color colorAleatorio = new Color(((numreg * numreg) + 100) % 255, |
220 |
(numreg + ((3 * numreg) + 100)) % 255, numreg % 255); |
221 |
|
222 |
createSymbol(tipoSymbol, colorAleatorio); |
223 |
} |
224 |
|
225 |
/**
|
226 |
* A partir de un s?mbolo devuelve otro similar pero con el color de
|
227 |
* selecci?n.
|
228 |
*
|
229 |
* @param sym S?mbolo a modificar.
|
230 |
*
|
231 |
* @return S?mbolo modificado.
|
232 |
*/
|
233 |
public static FSymbol getSymbolForSelection(FSymbol sym) { |
234 |
FSymbol selecSymbol = sym.fastCloneSymbol(); |
235 |
selecSymbol.setColor(getSelectionColor()); |
236 |
|
237 |
selecSymbol.setFill(null);
|
238 |
// 050215, jmorell: Si en los drivers cambiamos el estilo, aqu? tenemos que
|
239 |
// actualizar los cambios. SYMBOL_STYLE_MARKER_SQUARE --> SYMBOL_STYLE_DGNSPECIAL.
|
240 |
if ((selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_FILL_TRANSPARENT)
|
241 |
|| (selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_DGNSPECIAL)) |
242 |
selecSymbol.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
243 |
|
244 |
|
245 |
else if (selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_TEXT_BOLD || |
246 |
selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_TEXT_BOLDCURSIVE || |
247 |
selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_TEXT_CURSIVE || |
248 |
selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_TEXT_NORMAL){ |
249 |
selecSymbol.setFontColor(getSelectionColor()); |
250 |
} |
251 |
selecSymbol.rgb = getSelectionColor().getRGB(); |
252 |
|
253 |
return selecSymbol;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Clona el s?mbolo actual.
|
258 |
*
|
259 |
* @return Nuevo s?mbolo clonado.
|
260 |
*/
|
261 |
public FSymbol cloneSymbol() {
|
262 |
return createFromXML(getXMLEntity());
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* Se usa para el s?mbolo de selecci?n. Es una forma
|
267 |
* r?pida de clonar un s?mbolo, sin hacerlo via XML.
|
268 |
* Vicente, no lo borres!!!
|
269 |
* @return
|
270 |
*/
|
271 |
public FSymbol fastCloneSymbol()
|
272 |
{ |
273 |
FSymbol nS = new FSymbol();
|
274 |
|
275 |
|
276 |
nS.m_symbolType = m_symbolType; |
277 |
nS.m_Style = m_Style; |
278 |
nS.m_useOutline = m_useOutline; |
279 |
nS.m_Color = m_Color; |
280 |
nS.m_outlineColor = m_outlineColor; |
281 |
nS.m_Font = m_Font; |
282 |
nS.m_FontColor = m_FontColor; |
283 |
nS.m_FontSize = m_FontSize; |
284 |
nS.m_bUseFontSizeInPixels = m_bUseFontSizeInPixels; |
285 |
nS.m_bDrawShape = m_bDrawShape; |
286 |
nS.m_Size = m_Size; |
287 |
nS.m_Icon = m_Icon; |
288 |
nS.m_IconURI = m_IconURI; |
289 |
nS.m_Rotation = m_Rotation; |
290 |
nS.m_Fill = m_Fill; |
291 |
nS.m_Stroke = m_Stroke; |
292 |
// nS.m_Transparency =m_Transparency ;
|
293 |
nS.m_bUseSize = m_bUseSize; |
294 |
nS.m_AlingVert = m_AlingVert; |
295 |
nS.m_AlingHoriz = m_AlingHoriz; |
296 |
nS.m_Descrip = m_Descrip; |
297 |
nS.m_BackColor = m_BackColor; |
298 |
nS.m_BackFill = m_BackFill; |
299 |
|
300 |
nS.m_LinePattern = m_LinePattern; |
301 |
|
302 |
return nS;
|
303 |
} |
304 |
|
305 |
|
306 |
/**
|
307 |
* Crea un s?mbolo a partir del tipo y el color.
|
308 |
*
|
309 |
* @param tipoSymbol Tipo de s?mbolo.
|
310 |
* @param c Color del s?mbolo a crear.
|
311 |
*/
|
312 |
private void createSymbol(int tipoSymbol, Color c) { |
313 |
// OJO: HE HECHO COINCIDIR LOS TIPOS DE SIMBOLO
|
314 |
//FConstant.SYMBOL_TYPE_POINT, LINE Y FILL CON
|
315 |
// FShape.POINT, LINE, POLYGON. EL .MULTI SE REFIERE
|
316 |
// A MULTIPLES TIPO DENTRO DEL SHAPE, AS? QUE SER? UN
|
317 |
// MULTISIMBOLO
|
318 |
// Tipo de simbolo
|
319 |
m_symbolType = tipoSymbol; // Para no recalcular el pixel, no usamos los set
|
320 |
|
321 |
// Ponemos un estilo por defecto
|
322 |
m_useOutline = true;
|
323 |
m_Color = c; |
324 |
m_Stroke = null;
|
325 |
m_Fill = null;
|
326 |
|
327 |
m_FontColor = Color.BLACK;
|
328 |
m_FontSize = 10;
|
329 |
m_bUseFontSizeInPixels = true;
|
330 |
|
331 |
m_Size = 2;
|
332 |
|
333 |
switch (getSymbolType()) {
|
334 |
case FConstant.SYMBOL_TYPE_POINT:
|
335 |
case FConstant.SYMBOL_TYPE_POINTZ:
|
336 |
case FConstant.SYMBOL_TYPE_MULTIPOINT:
|
337 |
m_bUseSize = true; // Esto es lo primero que hay que hacer siempre |
338 |
|
339 |
// para evitar un StackOverflow
|
340 |
m_useOutline = false;
|
341 |
setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE); |
342 |
setSize(5); //pixels |
343 |
|
344 |
break;
|
345 |
|
346 |
case FConstant.SYMBOL_TYPE_LINE:
|
347 |
case FConstant.SYMBOL_TYPE_POLYLINEZ:
|
348 |
case FConstant.SYMBOL_TYPE_POLYGONZ:
|
349 |
setStroke(new BasicStroke()); |
350 |
setStyle(FConstant.SYMBOL_STYLE_LINE_SOLID); |
351 |
|
352 |
break;
|
353 |
|
354 |
case FConstant.SYMBOL_TYPE_FILL:
|
355 |
setStroke(new BasicStroke()); |
356 |
setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
357 |
|
358 |
break;
|
359 |
case FShape.MULTI:
|
360 |
m_bUseSize = true;
|
361 |
setStroke(new BasicStroke()); |
362 |
setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
363 |
|
364 |
// setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
|
365 |
setSize(5); //pixels |
366 |
break;
|
367 |
|
368 |
case FConstant.SYMBOL_TYPE_TEXT:
|
369 |
setStroke(new BasicStroke()); |
370 |
setStyle(FConstant.SYMBOL_STYLE_TEXT_NORMAL); |
371 |
setFont(new Font("Dialog",Font.PLAIN,12)); |
372 |
break;
|
373 |
} |
374 |
|
375 |
m_outlineColor = c.darker(); |
376 |
|
377 |
calculateRgb(); |
378 |
} |
379 |
|
380 |
/**
|
381 |
* Calcula el RGB del s?mbolo.
|
382 |
*/
|
383 |
public void calculateRgb() { |
384 |
// Recalculamos el RGB
|
385 |
Graphics2D g2 = img.createGraphics();
|
386 |
|
387 |
FGraphicUtilities.DrawSymbol(g2, g2.getTransform(), rect, this);
|
388 |
rgb = img.getRGB(0, 0); |
389 |
} |
390 |
|
391 |
/**
|
392 |
* Devuelve el rgb del s?mbolo.
|
393 |
*
|
394 |
* @return rgb del s?mbolo.
|
395 |
*/
|
396 |
public int getRgb() { |
397 |
return rgb;
|
398 |
} |
399 |
|
400 |
/**
|
401 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
402 |
*/
|
403 |
public XMLEntity getXMLEntity() {
|
404 |
XMLEntity xml = new XMLEntity();
|
405 |
xml.putProperty("className",this.getClass().getName()); |
406 |
xml.putProperty("m_symbolType", getSymbolType());
|
407 |
xml.putProperty("m_Style", getStyle());
|
408 |
xml.putProperty("m_useOutline", isOutlined());
|
409 |
|
410 |
if (getColor() != null) { |
411 |
xml.putProperty("m_Color", StringUtilities.color2String(getColor()));
|
412 |
} |
413 |
|
414 |
if (getOutlineColor() != null) { |
415 |
xml.putProperty("m_outlineColor",
|
416 |
StringUtilities.color2String(getOutlineColor())); |
417 |
} |
418 |
|
419 |
if (getFont() != null) { |
420 |
xml.putProperty("fontname", getFont().getName());
|
421 |
xml.putProperty("fontstyle", getFont().getStyle());
|
422 |
|
423 |
xml.putProperty("m_FontSize", getFontSize());
|
424 |
xml.putProperty("m_FontColor",
|
425 |
StringUtilities.color2String(getFontColor())); |
426 |
|
427 |
} |
428 |
xml.putProperty("m_bUseFontSize", isFontSizeInPixels());
|
429 |
xml.putProperty("m_bDrawShape", isShapeVisible());
|
430 |
xml.putProperty("m_Size", getSize());
|
431 |
|
432 |
//xml.putProperty("m_Icon",m_Icon.);
|
433 |
xml.putProperty("m_Rotation", getRotation());
|
434 |
|
435 |
if (getFill() instanceof Color) { |
436 |
xml.putProperty("m_Fill",
|
437 |
StringUtilities.color2String((Color) getFill()));
|
438 |
} |
439 |
else
|
440 |
if (getFill() != null) |
441 |
{ |
442 |
xml.putProperty("m_Fill", "WithFill"); |
443 |
} |
444 |
|
445 |
|
446 |
xml.putProperty("m_LinePattern", m_LinePattern);
|
447 |
|
448 |
//Ancho del stroke en float
|
449 |
if (getStroke() != null) { |
450 |
xml.putProperty("m_stroke",
|
451 |
((BasicStroke) getStroke()).getLineWidth());
|
452 |
} else {
|
453 |
xml.putProperty("m_stroke", 0f); |
454 |
} |
455 |
|
456 |
xml.putProperty("m_bUseSize", isSizeInPixels());
|
457 |
xml.putProperty("m_AlingVert", getAlingVert());
|
458 |
xml.putProperty("m_AlingHoriz", getAlingHoriz());
|
459 |
xml.putProperty("m_Descrip", getDescription());
|
460 |
|
461 |
if (m_BackColor != null) { |
462 |
xml.putProperty("m_BackColor",
|
463 |
StringUtilities.color2String(m_BackColor)); |
464 |
} |
465 |
|
466 |
if (m_BackFill instanceof Color) { |
467 |
xml.putProperty("m_BackFill",
|
468 |
StringUtilities.color2String((Color) m_BackFill));
|
469 |
} |
470 |
|
471 |
xml.putProperty("rgb", rgb);
|
472 |
|
473 |
if (m_Icon != null) |
474 |
{ |
475 |
xml.putProperty("m_IconURI", m_IconURI);
|
476 |
} |
477 |
|
478 |
return xml;
|
479 |
} |
480 |
/**
|
481 |
* Crea el s?mbolo a partir del xml.
|
482 |
*
|
483 |
* @param xml xml que contiene la informaci?n para crear el s?mbolo.
|
484 |
*
|
485 |
* @return S?mbolo creado a partir del XML.
|
486 |
*/
|
487 |
public static FSymbol createFromXML03(XMLEntity xml) { |
488 |
FSymbol symbol = new FSymbol();
|
489 |
symbol.setSymbolType(xml.getIntProperty("m_symbolType"));
|
490 |
symbol.setStyle(xml.getIntProperty("m_Style"));
|
491 |
// System.out.println("createFromXML: m_Style=" + xml.getIntProperty("m_Style"));
|
492 |
|
493 |
symbol.setOutlined(xml.getBooleanProperty("m_useOutline"));
|
494 |
|
495 |
if (xml.contains("m_Color")) { |
496 |
symbol.setColor(StringUtilities.string2Color(xml.getStringProperty( |
497 |
"m_Color")));
|
498 |
} |
499 |
|
500 |
if (xml.contains("m_outlineColor")) { |
501 |
symbol.setOutlineColor(StringUtilities.string2Color( |
502 |
xml.getStringProperty("m_outlineColor")));
|
503 |
} |
504 |
|
505 |
if (xml.contains("m_FontColor")) { |
506 |
symbol.setFont(new Font(xml.getStringProperty("fontname"), |
507 |
xml.getIntProperty("fontstyle"),
|
508 |
(int) xml.getFloatProperty("m_FontSize"))); |
509 |
symbol.setFontColor(StringUtilities.string2Color( |
510 |
xml.getStringProperty("m_FontColor")));
|
511 |
symbol.setFontSize(xml.getFloatProperty("m_FontSize"));
|
512 |
} |
513 |
|
514 |
symbol.setFontSizeInPixels(xml.getBooleanProperty("m_bUseFontSize"));
|
515 |
symbol.setShapeVisible(xml.getBooleanProperty("m_bDrawShape"));
|
516 |
symbol.setSize(xml.getIntProperty("m_Size"));
|
517 |
|
518 |
//xml.putProperty("m_Icon",m_Icon.);
|
519 |
symbol.setRotation(xml.getIntProperty("m_Rotation"));
|
520 |
|
521 |
if (xml.contains("m_Fill")) { |
522 |
// TODO: Si es un Fill de tipo imagen, deber?amos recuperar la imagen.
|
523 |
String strFill = xml.getStringProperty("m_Fill"); |
524 |
if (strFill.compareTo("WithFill") == 0) |
525 |
symbol.setFill(FSymbolFactory.createPatternFill(symbol.getStyle(), symbol.getColor())); |
526 |
else
|
527 |
symbol.setFill(StringUtilities.string2Color(strFill)); |
528 |
} |
529 |
|
530 |
|
531 |
symbol.m_LinePattern = xml.getStringProperty("m_LinePattern");
|
532 |
|
533 |
//Ancho del stroke en float
|
534 |
symbol.setStroke(new BasicStroke(xml.getFloatProperty("m_stroke"))); |
535 |
symbol.setSizeInPixels(xml.getBooleanProperty("m_bUseSize"));
|
536 |
symbol.setAlingVert(xml.getIntProperty("m_AlingVert"));
|
537 |
symbol.setAlingHoriz(xml.getIntProperty("m_AlingHoriz"));
|
538 |
symbol.setDescription(xml.getStringProperty("m_Descrip"));
|
539 |
|
540 |
if (xml.contains("m_BackColor")) { |
541 |
symbol.m_BackColor = StringUtilities.string2Color(xml.getStringProperty( |
542 |
"m_BackColor"));
|
543 |
} |
544 |
|
545 |
if (xml.contains("m_BackFill")) { |
546 |
symbol.m_BackFill = StringUtilities.string2Color(xml.getStringProperty( |
547 |
"m_BackFill"));
|
548 |
} |
549 |
|
550 |
symbol.rgb = xml.getIntProperty("rgb");
|
551 |
|
552 |
if (xml.contains("m_IconURI")) { |
553 |
try {
|
554 |
symbol.setIconURI(new URI(xml.getStringProperty("m_IconURI"))); |
555 |
} catch (URISyntaxException e) { |
556 |
// TODO Auto-generated catch block
|
557 |
e.printStackTrace(); |
558 |
} |
559 |
} |
560 |
|
561 |
return symbol;
|
562 |
} |
563 |
|
564 |
/**
|
565 |
* Crea el s?mbolo a partir del xml.
|
566 |
*
|
567 |
* @param xml xml que contiene la informaci?n para crear el s?mbolo.
|
568 |
*
|
569 |
* @return S?mbolo creado a partir del XML.
|
570 |
*/
|
571 |
public static FSymbol createFromXML(XMLEntity xml) { |
572 |
FSymbol symbol = new FSymbol();
|
573 |
symbol.setSymbolType(xml.getIntProperty("m_symbolType"));
|
574 |
symbol.setStyle(xml.getIntProperty("m_Style"));
|
575 |
// System.out.println("createFromXML: m_Style=" + xml.getIntProperty("m_Style"));
|
576 |
|
577 |
symbol.setOutlined(xml.getBooleanProperty("m_useOutline"));
|
578 |
|
579 |
if (xml.contains("m_Color")) { |
580 |
symbol.setColor(StringUtilities.string2Color(xml.getStringProperty( |
581 |
"m_Color")));
|
582 |
} |
583 |
|
584 |
if (xml.contains("m_outlineColor")) { |
585 |
symbol.setOutlineColor(StringUtilities.string2Color( |
586 |
xml.getStringProperty("m_outlineColor")));
|
587 |
} |
588 |
|
589 |
if (xml.contains("fontname")) { |
590 |
symbol.setFont(new Font(xml.getStringProperty("fontname"), |
591 |
xml.getIntProperty("fontstyle"),
|
592 |
(int) xml.getFloatProperty("m_FontSize"))); |
593 |
|
594 |
symbol.setFontColor(StringUtilities.string2Color( |
595 |
xml.getStringProperty("m_FontColor")));
|
596 |
symbol.setFontSize(xml.getFloatProperty("m_FontSize"));
|
597 |
|
598 |
} |
599 |
symbol.setFontSizeInPixels(xml.getBooleanProperty("m_bUseFontSize"));
|
600 |
symbol.setShapeVisible(xml.getBooleanProperty("m_bDrawShape"));
|
601 |
symbol.setSize(xml.getIntProperty("m_Size"));
|
602 |
|
603 |
//xml.putProperty("m_Icon",m_Icon.);
|
604 |
symbol.setRotation(xml.getIntProperty("m_Rotation"));
|
605 |
|
606 |
if (xml.contains("m_Fill")) { |
607 |
// TODO: Si es un Fill de tipo imagen, deber?amos recuperar la imagen.
|
608 |
String strFill = xml.getStringProperty("m_Fill"); |
609 |
if (strFill.compareTo("WithFill") == 0) |
610 |
symbol.setFill(FSymbolFactory.createPatternFill(symbol.getStyle(), symbol.getColor())); |
611 |
else
|
612 |
symbol.setFill(StringUtilities.string2Color(strFill)); |
613 |
} |
614 |
|
615 |
|
616 |
symbol.m_LinePattern = xml.getStringProperty("m_LinePattern");
|
617 |
|
618 |
//Ancho del stroke en float
|
619 |
float lineWidth = xml.getFloatProperty("m_stroke"); |
620 |
if (symbol.m_LinePattern.compareTo("0") == 0) |
621 |
{ |
622 |
symbol.setStroke(new BasicStroke(lineWidth)); |
623 |
} |
624 |
else
|
625 |
{ |
626 |
symbol.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, |
627 |
BasicStroke.JOIN_BEVEL, 1.0f, |
628 |
toArray(symbol.m_LinePattern, lineWidth), 0));
|
629 |
} |
630 |
|
631 |
symbol.setSizeInPixels(xml.getBooleanProperty("m_bUseSize"));
|
632 |
symbol.setAlingVert(xml.getIntProperty("m_AlingVert"));
|
633 |
symbol.setAlingHoriz(xml.getIntProperty("m_AlingHoriz"));
|
634 |
symbol.setDescription(xml.getStringProperty("m_Descrip"));
|
635 |
|
636 |
if (xml.contains("m_BackColor")) { |
637 |
symbol.m_BackColor = StringUtilities.string2Color(xml.getStringProperty( |
638 |
"m_BackColor"));
|
639 |
} |
640 |
|
641 |
if (xml.contains("m_BackFill")) { |
642 |
symbol.m_BackFill = StringUtilities.string2Color(xml.getStringProperty( |
643 |
"m_BackFill"));
|
644 |
} |
645 |
|
646 |
symbol.rgb = xml.getIntProperty("rgb");
|
647 |
|
648 |
if (xml.contains("m_IconURI")) { |
649 |
try {
|
650 |
symbol.setIconURI(new URI(xml.getStringProperty("m_IconURI"))); |
651 |
} catch (URISyntaxException e) { |
652 |
// TODO Auto-generated catch block
|
653 |
e.printStackTrace(); |
654 |
} |
655 |
} |
656 |
|
657 |
return symbol;
|
658 |
} |
659 |
|
660 |
/**
|
661 |
* Introduce el estilo del s?mbolo.
|
662 |
*
|
663 |
* @param m_Style The m_Style to set.
|
664 |
*/
|
665 |
public void setStyle(int m_Style) { |
666 |
this.m_Style = m_Style;
|
667 |
|
668 |
// calculateRgb();
|
669 |
} |
670 |
|
671 |
/**
|
672 |
* Devuelve el estilo del s?mbolo.
|
673 |
*
|
674 |
* @return Returns the m_Style.
|
675 |
*/
|
676 |
public int getStyle() { |
677 |
return m_Style;
|
678 |
} |
679 |
|
680 |
/**
|
681 |
* Introduce el tipo de s?mbolo.
|
682 |
*
|
683 |
* @param m_symbolType The m_symbolType to set.
|
684 |
*/
|
685 |
public void setSymbolType(int m_symbolType) { |
686 |
this.m_symbolType = m_symbolType;
|
687 |
} |
688 |
|
689 |
/**
|
690 |
* Devuelve el tipo de s?mbolo.
|
691 |
*
|
692 |
* @return Returns the m_symbolType.
|
693 |
*/
|
694 |
public int getSymbolType() { |
695 |
return m_symbolType;
|
696 |
} |
697 |
|
698 |
/**
|
699 |
* Introduce si el s?mbolo contiene linea de brode o no.
|
700 |
*
|
701 |
* @param m_useOutline The m_useOutline to set.
|
702 |
*/
|
703 |
public void setOutlined(boolean m_useOutline) { |
704 |
this.m_useOutline = m_useOutline;
|
705 |
|
706 |
// calculateRgb();
|
707 |
} |
708 |
|
709 |
/**
|
710 |
* Devuelve si el s?mbolo contiene o no linea de borde.
|
711 |
*
|
712 |
* @return Returns the m_useOutline.
|
713 |
*/
|
714 |
public boolean isOutlined() { |
715 |
return m_useOutline;
|
716 |
} |
717 |
|
718 |
/**
|
719 |
* Introduce el color del s?mbolo.
|
720 |
*
|
721 |
* @param m_Color The m_Color to set.
|
722 |
*/
|
723 |
public void setColor(Color m_Color) { |
724 |
this.m_Color = m_Color;
|
725 |
calculateRgb(); |
726 |
} |
727 |
|
728 |
/**
|
729 |
* Devuelve el color del s?mbolo.
|
730 |
*
|
731 |
* @return Returns the m_Color.
|
732 |
*/
|
733 |
public Color getColor() { |
734 |
return m_Color;
|
735 |
} |
736 |
|
737 |
/**
|
738 |
* Introduce el color de la l?nea de borde.
|
739 |
*
|
740 |
* @param m_outlineColor The m_outlineColor to set.
|
741 |
*/
|
742 |
public void setOutlineColor(Color m_outlineColor) { |
743 |
this.m_outlineColor = m_outlineColor;
|
744 |
|
745 |
// calculateRgb();
|
746 |
} |
747 |
|
748 |
/**
|
749 |
* Devuelve el color de la l?nea de borde.
|
750 |
*
|
751 |
* @return Returns the m_outlineColor.
|
752 |
*/
|
753 |
public Color getOutlineColor() { |
754 |
return m_outlineColor;
|
755 |
} |
756 |
|
757 |
/**
|
758 |
* Introduce el Font del s?mbolo.
|
759 |
*
|
760 |
* @param m_Font The m_Font to set.
|
761 |
*/
|
762 |
public void setFont(Font m_Font) { |
763 |
this.m_Font = m_Font;
|
764 |
|
765 |
// calculateRgb();
|
766 |
} |
767 |
|
768 |
/**
|
769 |
* Devuelve el Font del s?mbolo.
|
770 |
*
|
771 |
* @return Returns the m_Font.
|
772 |
*/
|
773 |
public Font getFont() { |
774 |
return m_Font;
|
775 |
} |
776 |
|
777 |
/**
|
778 |
* Introduce el color de la fuente.
|
779 |
*
|
780 |
* @param m_FontColor The m_FontColor to set.
|
781 |
*/
|
782 |
public void setFontColor(Color m_FontColor) { |
783 |
this.m_FontColor = m_FontColor;
|
784 |
|
785 |
// calculateRgb();
|
786 |
} |
787 |
|
788 |
/**
|
789 |
* Devuelve el color de la fuente.
|
790 |
*
|
791 |
* @return Returns the m_FontColor.
|
792 |
*/
|
793 |
public Color getFontColor() { |
794 |
return m_FontColor;
|
795 |
} |
796 |
|
797 |
/**
|
798 |
* Introduce si se usa el tama?o de la fuente en pixels.
|
799 |
*
|
800 |
* @param m_bUseFontSize The m_bUseFontSize to set.
|
801 |
*/
|
802 |
public void setFontSizeInPixels(boolean m_bUseFontSize) { |
803 |
this.m_bUseFontSizeInPixels = m_bUseFontSize;
|
804 |
|
805 |
// calculateRgb();
|
806 |
} |
807 |
|
808 |
/**
|
809 |
* Devuelve true si el tama?o de la fuente esta seleccionado en pixels.
|
810 |
*
|
811 |
* @return Returns the m_bUseFontSize.
|
812 |
*/
|
813 |
public boolean isFontSizeInPixels() { |
814 |
return m_bUseFontSizeInPixels;
|
815 |
} |
816 |
|
817 |
/**
|
818 |
* Introduce si el shape e visible o no lo es.
|
819 |
*
|
820 |
* @param m_bDrawShape The m_bDrawShape to set.
|
821 |
*/
|
822 |
public void setShapeVisible(boolean m_bDrawShape) { |
823 |
this.m_bDrawShape = m_bDrawShape;
|
824 |
|
825 |
// calculateRgb();
|
826 |
} |
827 |
|
828 |
/**
|
829 |
* Devuelve true si el shape es visible.
|
830 |
*
|
831 |
* @return Returns the m_bDrawShape.
|
832 |
*/
|
833 |
public boolean isShapeVisible() { |
834 |
return m_bDrawShape;
|
835 |
} |
836 |
|
837 |
/**
|
838 |
* Introduce el tama?o del s?mbolo.
|
839 |
*
|
840 |
* @param m_Size The m_Size to set.
|
841 |
*/
|
842 |
public void setSize(int m_Size) { |
843 |
this.m_Size = m_Size;
|
844 |
|
845 |
// calculateRgb();
|
846 |
} |
847 |
|
848 |
/**
|
849 |
* Devuelve el tama?o del s?mbolo.
|
850 |
*
|
851 |
* @return Returns the m_Size.
|
852 |
*/
|
853 |
public int getSize() { |
854 |
return m_Size;
|
855 |
} |
856 |
|
857 |
/**
|
858 |
* Introduce la imagen que hace de icono.
|
859 |
*
|
860 |
* @param m_Icon The m_Icon to set.
|
861 |
*/
|
862 |
public void setIcon(Image m_Icon) { |
863 |
this.m_Icon = m_Icon;
|
864 |
|
865 |
// calculateRgb();
|
866 |
} |
867 |
|
868 |
/**
|
869 |
* Devuelve el icono.
|
870 |
*
|
871 |
* @return Returns the m_Icon.
|
872 |
*/
|
873 |
public Image getIcon() { |
874 |
return m_Icon;
|
875 |
} |
876 |
|
877 |
/**
|
878 |
* Introduce la rotaci?n.
|
879 |
*
|
880 |
* @param m_Rotation The m_Rotation to set.
|
881 |
*/
|
882 |
public void setRotation(int m_Rotation) { |
883 |
this.m_Rotation = m_Rotation;
|
884 |
|
885 |
// calculateRgb();
|
886 |
} |
887 |
|
888 |
/**
|
889 |
* Devuelve la rotaci?n.
|
890 |
*
|
891 |
* @return Returns the m_Rotation.
|
892 |
*/
|
893 |
public int getRotation() { |
894 |
return m_Rotation;
|
895 |
} |
896 |
|
897 |
/**
|
898 |
* Introduce el relleno.
|
899 |
*
|
900 |
* @param m_Fill The m_Fill to set.
|
901 |
*/
|
902 |
public void setFill(Paint m_Fill) { |
903 |
this.m_Fill = m_Fill;
|
904 |
|
905 |
// calculateRgb();
|
906 |
} |
907 |
|
908 |
/**
|
909 |
* Devuelve el relleno.
|
910 |
*
|
911 |
* @return Returns the m_Fill.
|
912 |
*/
|
913 |
public Paint getFill() { |
914 |
return m_Fill;
|
915 |
} |
916 |
|
917 |
/**
|
918 |
* Introduce el Stroke.
|
919 |
*
|
920 |
* @param m_Stroke The m_Stroke to set.
|
921 |
*/
|
922 |
public void setStroke(Stroke m_Stroke) { |
923 |
this.m_Stroke = m_Stroke;
|
924 |
|
925 |
// calculateRgb();
|
926 |
} |
927 |
|
928 |
/**
|
929 |
* Devuelve el Stroke.
|
930 |
*
|
931 |
* @return Returns the m_Stroke.
|
932 |
*/
|
933 |
public Stroke getStroke() { |
934 |
return m_Stroke;
|
935 |
} |
936 |
|
937 |
/**
|
938 |
* Introduce si el tama?o del simbolo est? en pixels.
|
939 |
*
|
940 |
* @param m_bUseSize The m_bUseSize to set.
|
941 |
*/
|
942 |
public void setSizeInPixels(boolean m_bUseSize) { |
943 |
this.m_bUseSize = m_bUseSize;
|
944 |
|
945 |
// calculateRgb();
|
946 |
} |
947 |
|
948 |
/**
|
949 |
* Devuelve si el tama?o del s?mbolo est? en pixels.
|
950 |
*
|
951 |
* @return Returns the m_bUseSize.
|
952 |
*/
|
953 |
public boolean isSizeInPixels() { |
954 |
return m_bUseSize;
|
955 |
} |
956 |
|
957 |
/**
|
958 |
* Introduce la descripci?n del s?mbolo.
|
959 |
*
|
960 |
* @param m_Descrip The m_Descrip to set.
|
961 |
*/
|
962 |
public void setDescription(String m_Descrip) { |
963 |
this.m_Descrip = m_Descrip;
|
964 |
} |
965 |
|
966 |
/**
|
967 |
* Devuelve la descripci?n del s?mbolo.
|
968 |
*
|
969 |
* @return Returns the m_Descrip.
|
970 |
*/
|
971 |
public String getDescription() { |
972 |
return m_Descrip;
|
973 |
} |
974 |
|
975 |
/**
|
976 |
* Introduce la alineaci?n en vertical.
|
977 |
*
|
978 |
* @param m_AlingVert The m_AlingVert to set.
|
979 |
*/
|
980 |
public void setAlingVert(int m_AlingVert) { |
981 |
this.m_AlingVert = m_AlingVert;
|
982 |
|
983 |
// calculateRgb();
|
984 |
} |
985 |
|
986 |
/**
|
987 |
* Devuelve la alineaci?n en vertical.
|
988 |
*
|
989 |
* @return Returns the m_AlingVert.
|
990 |
*/
|
991 |
public int getAlingVert() { |
992 |
return m_AlingVert;
|
993 |
} |
994 |
|
995 |
/**
|
996 |
* Introduce la alineaci?n en horizontal.
|
997 |
*
|
998 |
* @param m_AlingHoriz The m_AlingHoriz to set.
|
999 |
*/
|
1000 |
public void setAlingHoriz(int m_AlingHoriz) { |
1001 |
this.m_AlingHoriz = m_AlingHoriz;
|
1002 |
|
1003 |
// calculateRgb();
|
1004 |
} |
1005 |
|
1006 |
/**
|
1007 |
* Devuelve la alineaci?n en horizontal.
|
1008 |
*
|
1009 |
* @return Returns the m_AlingHoriz.
|
1010 |
*/
|
1011 |
public int getAlingHoriz() { |
1012 |
return m_AlingHoriz;
|
1013 |
} |
1014 |
|
1015 |
/**
|
1016 |
* Devuelve el color que se aplica a los shapes seleccionados.
|
1017 |
*
|
1018 |
* @return DOCUMENT ME!
|
1019 |
*/
|
1020 |
public static Color getSelectionColor() { |
1021 |
return selectionColor;
|
1022 |
} |
1023 |
|
1024 |
/**
|
1025 |
* Introduce el color que se aplica a los shapes seleccionados.
|
1026 |
*
|
1027 |
* @param selectionColor DOCUMENT ME!
|
1028 |
*/
|
1029 |
public static void setSelectionColor(Color selectionColor) { |
1030 |
FSymbol.selectionColor = selectionColor; |
1031 |
} |
1032 |
|
1033 |
/**
|
1034 |
* Introduce el tama?o de la fuente.
|
1035 |
*
|
1036 |
* @param m_FontSize The m_FontSize to set.
|
1037 |
*/
|
1038 |
public void setFontSize(float m_FontSize) { |
1039 |
this.m_FontSize = m_FontSize;
|
1040 |
} |
1041 |
|
1042 |
/**
|
1043 |
* Devuelve el tama?o de la fuente.
|
1044 |
*
|
1045 |
* @return Returns the m_FontSize.
|
1046 |
*/
|
1047 |
public float getFontSize() { |
1048 |
return m_FontSize;
|
1049 |
} |
1050 |
public URI getIconURI() { |
1051 |
return m_IconURI;
|
1052 |
} |
1053 |
public void setIconURI(URI iconURI) { |
1054 |
m_IconURI = iconURI; |
1055 |
ImageIcon prov;
|
1056 |
try {
|
1057 |
prov = new ImageIcon(iconURI.toURL()); |
1058 |
m_Icon = prov.getImage(); |
1059 |
} catch (MalformedURLException e) { |
1060 |
// TODO Auto-generated catch block
|
1061 |
e.printStackTrace(); |
1062 |
} |
1063 |
|
1064 |
} |
1065 |
//methods to be ISLDCompatible
|
1066 |
/**
|
1067 |
* converts FSymbol to Geotools symbol.
|
1068 |
*/
|
1069 |
public String toSLD () |
1070 |
{ |
1071 |
XmlBuilder xmlBuilder = new XmlBuilder();
|
1072 |
|
1073 |
try
|
1074 |
{ |
1075 |
switch (this.getSymbolType()) |
1076 |
{ |
1077 |
|
1078 |
case FConstant.SYMBOL_TYPE_POINT:
|
1079 |
xmlBuilder.openTag(SLDTags.POINTSYMBOLIZER); |
1080 |
xmlBuilder.openTag(SLDTags.GRAPHIC); |
1081 |
xmlBuilder.openTag(SLDTags.MARK); |
1082 |
|
1083 |
if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_CIRCLE ){ |
1084 |
xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"circle");
|
1085 |
}else if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_SQUARE ){ |
1086 |
xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"square");
|
1087 |
}else if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_TRIANGLE ){ |
1088 |
xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"triangle");
|
1089 |
}else if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_CROSS ){ |
1090 |
xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"cross");
|
1091 |
} |
1092 |
|
1093 |
if(this.m_Color != null){ |
1094 |
xmlBuilder.openTag(SLDTags.FILL); |
1095 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER, |
1096 |
SLDUtils.convertColorToHexString(this.m_Color),
|
1097 |
SLDTags.NAME_ATTR, |
1098 |
SLDTags.FILL_ATTR); |
1099 |
xmlBuilder.closeTag(); |
1100 |
} |
1101 |
xmlBuilder.closeTag(); |
1102 |
|
1103 |
//boolean bAux2 = this.isSizeInPixels();
|
1104 |
int alturaMetros = this.getSize(); |
1105 |
xmlBuilder.writeTag(SLDTags.SIZE,""+alturaMetros);
|
1106 |
xmlBuilder.closeTag(); |
1107 |
xmlBuilder.closeTag(); |
1108 |
|
1109 |
//TODO: Ver como a?adir un texto a cada feature de una capa de puntos...
|
1110 |
if (this.getFont() != null) { |
1111 |
//boolean bAux = this.isFontSizeInPixels();
|
1112 |
} |
1113 |
break;
|
1114 |
|
1115 |
case FConstant.SYMBOL_TYPE_LINE:
|
1116 |
xmlBuilder.openTag(SLDTags.LINESYMBOLIZER); |
1117 |
// Add geometry tag with the column that gives the geometric infrmation
|
1118 |
// Maybe this is not necessary
|
1119 |
// sld.append(SLDTags.OT_GEOMETRY);
|
1120 |
// sld.append(SLDTags.CT_GEOMETRY);
|
1121 |
|
1122 |
if(this.m_Color != null){ |
1123 |
xmlBuilder.openTag(SLDTags.STROKE); |
1124 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER |
1125 |
,SLDUtils.convertColorToHexString(this.m_Color)
|
1126 |
,SLDTags.NAME,SLDTags.STROKE_ATTR); |
1127 |
|
1128 |
if (getStroke() != null) { |
1129 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER |
1130 |
,Float.toString(((BasicStroke) getStroke()).getLineWidth()) |
1131 |
,SLDTags.NAME,SLDTags.STROKE_WIDTH_ATTR); |
1132 |
} |
1133 |
//TODO: Add to the SLD all the line styles
|
1134 |
// if (this.getStyle() == FConstant.SYMBOL_STYLE_LINE_DASH
|
1135 |
// <CssParameter name="stroke">#FFFF00</CssParameter>
|
1136 |
// <CssParameter name="stroke-opacity">1.0</CssParameter>
|
1137 |
// <CssParameter name="stroke-width">6.0</CssParameter>
|
1138 |
// <CssParameter name="stroke-dasharray">1</CssParameter>
|
1139 |
|
1140 |
xmlBuilder.closeTag(); |
1141 |
} |
1142 |
xmlBuilder.closeTag(); |
1143 |
break;
|
1144 |
|
1145 |
case FConstant.SYMBOL_TYPE_FILL:
|
1146 |
xmlBuilder.openTag(SLDTags.POLYGONSYMBOLIZER); |
1147 |
if(this.m_Color != null){ |
1148 |
xmlBuilder.openTag(SLDTags.FILL); |
1149 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER, |
1150 |
SLDUtils.convertColorToHexString(this.m_Color),
|
1151 |
SLDTags.NAME_ATTR, |
1152 |
SLDTags.FILL_ATTR); |
1153 |
xmlBuilder.closeTag(); |
1154 |
} |
1155 |
if (this.m_outlineColor != null){ |
1156 |
xmlBuilder.openTag(SLDTags.STROKE); |
1157 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER, |
1158 |
SLDUtils.convertColorToHexString(this.m_outlineColor),
|
1159 |
SLDTags.NAME_ATTR, |
1160 |
SLDTags.STROKE_ATTR); |
1161 |
if (getStroke() != null) { |
1162 |
xmlBuilder.writeTag(SLDTags.CSSPARAMETER |
1163 |
,Float.toString(((BasicStroke) getStroke()).getLineWidth()) |
1164 |
,SLDTags.NAME,SLDTags.STROKE_WIDTH_ATTR); |
1165 |
} |
1166 |
xmlBuilder.closeTag(); |
1167 |
} |
1168 |
// TODO: Fill opacity and other graphic features
|
1169 |
xmlBuilder.closeTag(); |
1170 |
break;
|
1171 |
|
1172 |
case FShape.MULTI:
|
1173 |
if (this.getFont() != null) { |
1174 |
// Para no tener que clonarlo si viene en unidades de mapa
|
1175 |
boolean bAux = this.isFontSizeInPixels(); |
1176 |
this.setFontSizeInPixels(true); |
1177 |
//FGraphicUtilities.DrawLabel(g2, mT, shp, symbol,new FLabel("Abcd"));
|
1178 |
this.setFontSizeInPixels(bAux);
|
1179 |
} |
1180 |
break;
|
1181 |
} |
1182 |
return xmlBuilder.getXML();
|
1183 |
} |
1184 |
catch(Exception e) |
1185 |
{ |
1186 |
e.printStackTrace(); |
1187 |
return null; |
1188 |
} |
1189 |
} |
1190 |
|
1191 |
/**
|
1192 |
* creates an FSymbol from an SLD
|
1193 |
*/
|
1194 |
public String fromSLD (String sld) |
1195 |
{ |
1196 |
//TODO: This function can be implemented later...
|
1197 |
StringBuffer sb = new StringBuffer(); |
1198 |
try
|
1199 |
{ |
1200 |
|
1201 |
return sb.toString();
|
1202 |
} |
1203 |
catch(Exception e) |
1204 |
{ |
1205 |
e.printStackTrace(); |
1206 |
return null; |
1207 |
} |
1208 |
} |
1209 |
|
1210 |
/**
|
1211 |
* @return Returns the imgObserver.
|
1212 |
*/
|
1213 |
public ImageObserver getImgObserver() { |
1214 |
return imgObserver;
|
1215 |
} |
1216 |
|
1217 |
/**
|
1218 |
* @param imgObserver The imgObserver to set.
|
1219 |
*/
|
1220 |
public void setImgObserver(ImageObserver imgObserver) { |
1221 |
this.imgObserver = imgObserver;
|
1222 |
} |
1223 |
|
1224 |
} |