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