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