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