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