root / branches / Fmap_GisPlanet / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FSymbol.java @ 1993
History | View | Annotate | Download (22.6 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.fmap.core.v02; |
48 |
|
49 |
import java.awt.BasicStroke; |
50 |
import java.awt.Color; |
51 |
import java.awt.Font; |
52 |
import java.awt.Graphics2D; |
53 |
import java.awt.Image; |
54 |
import java.awt.Paint; |
55 |
import java.awt.Rectangle; |
56 |
import java.awt.Stroke; |
57 |
import java.awt.image.BufferedImage; |
58 |
import java.net.MalformedURLException; |
59 |
import java.net.URI; |
60 |
import java.net.URISyntaxException; |
61 |
|
62 |
import javax.swing.ImageIcon; |
63 |
|
64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
65 |
import com.iver.utiles.StringUtilities; |
66 |
import com.iver.utiles.XMLEntity; |
67 |
|
68 |
|
69 |
/**
|
70 |
* S?mbolo utilizado para guardar las caracter?sticas que se deben de aplicar a
|
71 |
* los Shapes a dibujar.
|
72 |
*
|
73 |
* @author Vicente Caballero Navarro
|
74 |
*/
|
75 |
public class FSymbol { |
76 |
private static BufferedImage img = new BufferedImage(1, 1, |
77 |
BufferedImage.TYPE_INT_ARGB);
|
78 |
private static Rectangle rect = new Rectangle(0, 0, 1, 1); |
79 |
private static Color selectionColor = Color.YELLOW; |
80 |
private int m_symbolType; |
81 |
private int m_Style; |
82 |
private boolean m_useOutline; |
83 |
private Color m_Color; |
84 |
private Color m_outlineColor; |
85 |
private Font m_Font; |
86 |
private Color m_FontColor; |
87 |
private float m_FontSize; |
88 |
private int rgb; |
89 |
|
90 |
/**
|
91 |
* Si <code>m_bUseFontSize</code> viene a false entonces m_FontSize viene
|
92 |
* en unidades de mapa (metros)
|
93 |
*/
|
94 |
private boolean m_bUseFontSizeInPixels; |
95 |
|
96 |
/**
|
97 |
* <code>m_bDrawShape</code> indica si queremos dibujar el shape de fondo.
|
98 |
* Es ?til cuando est?s etiquetando y no quieres que se dibuje el s?mbolo
|
99 |
* que te sirve de base para etiquetar.
|
100 |
*/
|
101 |
private boolean m_bDrawShape = true; |
102 |
private int m_Size; |
103 |
private Image m_Icon; |
104 |
private URI m_IconURI; |
105 |
private int m_Rotation; |
106 |
private Paint m_Fill; |
107 |
public String m_LinePattern = "0"; // Solo para poder mostrarlo cuando vamos a seleccionar un s?mbolo |
108 |
|
109 |
// En realidad lo podemos ver de BasicStroke, pero....
|
110 |
// ya veremos si luego lo quitamos.
|
111 |
private Stroke m_Stroke; |
112 |
|
113 |
//private float m_stroke=0;
|
114 |
// public int m_Transparency; // Ya la lleva dentro del Color
|
115 |
private boolean m_bUseSize; // Si est? a true, m_Size viene en coordenadas de mundo real. |
116 |
private int m_AlingVert; |
117 |
private int m_AlingHoriz; |
118 |
private String m_Descrip; |
119 |
public Color m_BackColor; |
120 |
public Paint m_BackFill; |
121 |
|
122 |
/**
|
123 |
* Crea un nuevo FSymbol.
|
124 |
*/
|
125 |
FSymbol() { |
126 |
} |
127 |
|
128 |
/**
|
129 |
* Creates a new FSymbol object.
|
130 |
*
|
131 |
* @param tipoSymbol Tipo de s?mbolo.
|
132 |
* @param c Color.
|
133 |
*/
|
134 |
public FSymbol(int tipoSymbol, Color c) { |
135 |
createSymbol(tipoSymbol, c); |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Crea un nuevo FSymbol.
|
140 |
*
|
141 |
* @param tipoSymbol Tipo de S?mbolo.
|
142 |
*/
|
143 |
public FSymbol(int tipoSymbol) { |
144 |
int numreg = (int) (Math.random() * 100); |
145 |
Color colorAleatorio = new Color(((numreg * numreg) + 100) % 255, |
146 |
(numreg + ((3 * numreg) + 100)) % 255, numreg % 255); |
147 |
|
148 |
createSymbol(tipoSymbol, colorAleatorio); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* A partir de un s?mbolo devuelve otro similar pero con el color de
|
153 |
* selecci?n.
|
154 |
*
|
155 |
* @param sym S?mbolo a modificar.
|
156 |
*
|
157 |
* @return S?mbolo modificado.
|
158 |
*/
|
159 |
public static FSymbol getSymbolForSelection(FSymbol sym) { |
160 |
FSymbol selecSymbol = sym.fastCloneSymbol(); |
161 |
selecSymbol.setColor(getSelectionColor()); |
162 |
selecSymbol.setFill(null);
|
163 |
// 050215, jmorell: Si en los drivers cambiamos el estilo, aqu? tenemos que
|
164 |
// actualizar los cambios. SYMBOL_STYLE_MARKER_SQUARE --> SYMBOL_STYLE_DGNSPECIAL.
|
165 |
if ((selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_FILL_TRANSPARENT)
|
166 |
|| (selecSymbol.getStyle() == FConstant.SYMBOL_STYLE_DGNSPECIAL)) |
167 |
selecSymbol.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
168 |
selecSymbol.rgb = getSelectionColor().getRGB(); |
169 |
|
170 |
return selecSymbol;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Clona el s?mbolo actual.
|
175 |
*
|
176 |
* @return Nuevo s?mbolo clonado.
|
177 |
*/
|
178 |
public FSymbol cloneSymbol() {
|
179 |
return createFromXML(getXMLEntity());
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* Se usa para el s?mbolo de selecci?n. Es una forma
|
184 |
* r?pida de clonar un s?mbolo, sin hacerlo via XML.
|
185 |
* Vicente, no lo borres!!!
|
186 |
* @return
|
187 |
*/
|
188 |
public FSymbol fastCloneSymbol()
|
189 |
{ |
190 |
FSymbol nS = new FSymbol();
|
191 |
|
192 |
|
193 |
nS.m_symbolType = m_symbolType; |
194 |
nS.m_Style = m_Style; |
195 |
nS.m_useOutline = m_useOutline; |
196 |
nS.m_Color = m_Color; |
197 |
nS.m_outlineColor = m_outlineColor; |
198 |
nS.m_Font = m_Font; |
199 |
nS.m_FontColor = m_FontColor; |
200 |
nS.m_FontSize = m_FontSize; |
201 |
nS.m_bUseFontSizeInPixels = m_bUseFontSizeInPixels; |
202 |
nS.m_bDrawShape = m_bDrawShape; |
203 |
nS.m_Size = m_Size; |
204 |
nS.m_Icon = m_Icon; |
205 |
nS.m_IconURI = m_IconURI; |
206 |
nS.m_Rotation = m_Rotation; |
207 |
nS.m_Fill = m_Fill; |
208 |
nS.m_Stroke = m_Stroke; |
209 |
// nS.m_Transparency =m_Transparency ;
|
210 |
nS.m_bUseSize = m_bUseSize; |
211 |
nS.m_AlingVert = m_AlingVert; |
212 |
nS.m_AlingHoriz = m_AlingHoriz; |
213 |
nS.m_Descrip = m_Descrip; |
214 |
nS.m_BackColor = m_BackColor; |
215 |
nS.m_BackFill = m_BackFill; |
216 |
|
217 |
nS.m_LinePattern = m_LinePattern; |
218 |
|
219 |
return nS;
|
220 |
} |
221 |
|
222 |
|
223 |
/**
|
224 |
* Crea un s?mbolo a partir del tipo y el color.
|
225 |
*
|
226 |
* @param tipoSymbol Tipo de s?mbolo.
|
227 |
* @param c Color del s?mbolo a crear.
|
228 |
*/
|
229 |
private void createSymbol(int tipoSymbol, Color c) { |
230 |
// OJO: HE HECHO COINCIDIR LOS TIPOS DE SIMBOLO
|
231 |
//FConstant.SYMBOL_TYPE_POINT, LINE Y FILL CON
|
232 |
// FShape.POINT, LINE, POLYGON. EL .MULTI SE REFIERE
|
233 |
// A MULTIPLES TIPO DENTRO DEL SHAPE, AS? QUE SER? UN
|
234 |
// MULTISIMBOLO
|
235 |
// Tipo de simbolo
|
236 |
m_symbolType = tipoSymbol; // Para no recalcular el pixel, no usamos los set
|
237 |
|
238 |
// Ponemos un estilo por defecto
|
239 |
m_useOutline = true;
|
240 |
m_Color = c; |
241 |
m_Stroke = null;
|
242 |
m_Fill = null;
|
243 |
|
244 |
m_FontColor = Color.BLACK;
|
245 |
m_FontSize = 10;
|
246 |
m_bUseFontSizeInPixels = true;
|
247 |
|
248 |
m_Size = 2;
|
249 |
|
250 |
switch (getSymbolType()) {
|
251 |
case FConstant.SYMBOL_TYPE_POINT:
|
252 |
case FConstant.SYMBOL_TYPE_POINTZ:
|
253 |
case FConstant.SYMBOL_TYPE_MULTIPOINT:
|
254 |
m_bUseSize = true; // Esto es lo primero que hay que hacer siempre |
255 |
|
256 |
// para evitar un StackOverflow
|
257 |
m_useOutline = false;
|
258 |
setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE); |
259 |
setSize(5); //pixels |
260 |
|
261 |
break;
|
262 |
|
263 |
case FConstant.SYMBOL_TYPE_LINE:
|
264 |
case FConstant.SYMBOL_TYPE_POLYLINEZ:
|
265 |
case FConstant.SYMBOL_TYPE_POLYGONZ:
|
266 |
setStroke(new BasicStroke()); |
267 |
setStyle(FConstant.SYMBOL_STYLE_LINE_SOLID); |
268 |
|
269 |
break;
|
270 |
|
271 |
case FConstant.SYMBOL_TYPE_FILL:
|
272 |
case FShape.MULTI:
|
273 |
setStroke(new BasicStroke()); |
274 |
setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
275 |
|
276 |
break;
|
277 |
} |
278 |
|
279 |
m_outlineColor = c.darker(); |
280 |
|
281 |
calculateRgb(); |
282 |
} |
283 |
|
284 |
/**
|
285 |
* Calcula el RGB del s?mbolo.
|
286 |
*/
|
287 |
public void calculateRgb() { |
288 |
// Recalculamos el RGB
|
289 |
Graphics2D g2 = img.createGraphics();
|
290 |
|
291 |
FGraphicUtilities.DrawSymbol(g2, g2.getTransform(), rect, this);
|
292 |
rgb = img.getRGB(0, 0); |
293 |
} |
294 |
|
295 |
/**
|
296 |
* Devuelve el rgb del s?mbolo.
|
297 |
*
|
298 |
* @return rgb del s?mbolo.
|
299 |
*/
|
300 |
public int getRgb() { |
301 |
return rgb;
|
302 |
} |
303 |
|
304 |
/**
|
305 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
306 |
*/
|
307 |
public XMLEntity getXMLEntity() {
|
308 |
XMLEntity xml = new XMLEntity();
|
309 |
xml.putProperty("className",this.getClass().getName()); |
310 |
xml.putProperty("m_symbolType", getSymbolType());
|
311 |
xml.putProperty("m_Style", getStyle());
|
312 |
xml.putProperty("m_useOutline", isOutlined());
|
313 |
|
314 |
if (getColor() != null) { |
315 |
xml.putProperty("m_Color", StringUtilities.color2String(getColor()));
|
316 |
} |
317 |
|
318 |
if (getOutlineColor() != null) { |
319 |
xml.putProperty("m_outlineColor",
|
320 |
StringUtilities.color2String(getOutlineColor())); |
321 |
} |
322 |
|
323 |
if (getFont() != null) { |
324 |
xml.putProperty("fontname", getFont().getName());
|
325 |
xml.putProperty("fontstyle", getFont().getStyle());
|
326 |
xml.putProperty("m_FontSize", getFontSize());
|
327 |
xml.putProperty("m_FontColor",
|
328 |
StringUtilities.color2String(getFontColor())); |
329 |
} |
330 |
|
331 |
xml.putProperty("m_bUseFontSize", isFontSizeInPixels());
|
332 |
xml.putProperty("m_bDrawShape", isShapeVisible());
|
333 |
xml.putProperty("m_Size", getSize());
|
334 |
|
335 |
//xml.putProperty("m_Icon",m_Icon.);
|
336 |
xml.putProperty("m_Rotation", getRotation());
|
337 |
|
338 |
if (getFill() instanceof Color) { |
339 |
xml.putProperty("m_Fill",
|
340 |
StringUtilities.color2String((Color) getFill()));
|
341 |
} |
342 |
else
|
343 |
if (getFill() != null) |
344 |
{ |
345 |
xml.putProperty("m_Fill", "WithFill"); |
346 |
} |
347 |
|
348 |
|
349 |
xml.putProperty("m_LinePattern", m_LinePattern);
|
350 |
|
351 |
//Ancho del stroke en float
|
352 |
if (getStroke() != null) { |
353 |
xml.putProperty("m_stroke",
|
354 |
((BasicStroke) getStroke()).getLineWidth());
|
355 |
} else {
|
356 |
xml.putProperty("m_stroke", 0f); |
357 |
} |
358 |
|
359 |
xml.putProperty("m_bUseSize", isSizeInPixels());
|
360 |
xml.putProperty("m_AlingVert", getAlingVert());
|
361 |
xml.putProperty("m_AlingHoriz", getAlingHoriz());
|
362 |
xml.putProperty("m_Descrip", getDescription());
|
363 |
|
364 |
if (m_BackColor != null) { |
365 |
xml.putProperty("m_BackColor",
|
366 |
StringUtilities.color2String(m_BackColor)); |
367 |
} |
368 |
|
369 |
if (m_BackFill instanceof Color) { |
370 |
xml.putProperty("m_BackFill",
|
371 |
StringUtilities.color2String((Color) m_BackFill));
|
372 |
} |
373 |
|
374 |
xml.putProperty("rgb", rgb);
|
375 |
|
376 |
if (m_Icon != null) |
377 |
{ |
378 |
xml.putProperty("m_IconURI", m_IconURI);
|
379 |
} |
380 |
|
381 |
return xml;
|
382 |
} |
383 |
/**
|
384 |
* Crea el s?mbolo a partir del xml.
|
385 |
*
|
386 |
* @param xml xml que contiene la informaci?n para crear el s?mbolo.
|
387 |
*
|
388 |
* @return S?mbolo creado a partir del XML.
|
389 |
*/
|
390 |
public static FSymbol createFromXML03(XMLEntity xml) { |
391 |
FSymbol symbol = new FSymbol();
|
392 |
symbol.setSymbolType(xml.getIntProperty("m_symbolType"));
|
393 |
symbol.setStyle(xml.getIntProperty("m_Style"));
|
394 |
System.out.println("createFromXML: m_Style=" + xml.getIntProperty("m_Style")); |
395 |
|
396 |
symbol.setOutlined(xml.getBooleanProperty("m_useOutline"));
|
397 |
|
398 |
if (xml.contains("m_Color")) { |
399 |
symbol.setColor(StringUtilities.string2Color(xml.getStringProperty( |
400 |
"m_Color")));
|
401 |
} |
402 |
|
403 |
if (xml.contains("m_outlineColor")) { |
404 |
symbol.setOutlineColor(StringUtilities.string2Color( |
405 |
xml.getStringProperty("m_outlineColor")));
|
406 |
} |
407 |
|
408 |
if (xml.contains("m_FontColor")) { |
409 |
symbol.setFont(new Font(xml.getStringProperty("fontname"), |
410 |
xml.getIntProperty("fontstyle"),
|
411 |
(int) xml.getFloatProperty("m_FontSize"))); |
412 |
symbol.setFontColor(StringUtilities.string2Color( |
413 |
xml.getStringProperty("m_FontColor")));
|
414 |
symbol.setFontSize(xml.getFloatProperty("m_FontSize"));
|
415 |
} |
416 |
|
417 |
symbol.setFontSizeInPixels(xml.getBooleanProperty("m_bUseFontSize"));
|
418 |
symbol.setShapeVisible(xml.getBooleanProperty("m_bDrawShape"));
|
419 |
symbol.setSize(xml.getIntProperty("m_Size"));
|
420 |
|
421 |
//xml.putProperty("m_Icon",m_Icon.);
|
422 |
symbol.setRotation(xml.getIntProperty("m_Rotation"));
|
423 |
|
424 |
if (xml.contains("m_Fill")) { |
425 |
// TODO: Si es un Fill de tipo imagen, deber?amos recuperar la imagen.
|
426 |
String strFill = xml.getStringProperty("m_Fill"); |
427 |
if (strFill.compareTo("WithFill") == 0) |
428 |
symbol.setFill(FSymbolFactory.createPatternFill(symbol.getStyle(), symbol.getColor())); |
429 |
else
|
430 |
symbol.setFill(StringUtilities.string2Color(strFill)); |
431 |
} |
432 |
|
433 |
|
434 |
symbol.m_LinePattern = xml.getStringProperty("m_LinePattern");
|
435 |
|
436 |
//Ancho del stroke en float
|
437 |
symbol.setStroke(new BasicStroke(xml.getFloatProperty("m_stroke"))); |
438 |
symbol.setSizeInPixels(xml.getBooleanProperty("m_bUseSize"));
|
439 |
symbol.setAlingVert(xml.getIntProperty("m_AlingVert"));
|
440 |
symbol.setAlingHoriz(xml.getIntProperty("m_AlingHoriz"));
|
441 |
symbol.setDescription(xml.getStringProperty("m_Descrip"));
|
442 |
|
443 |
if (xml.contains("m_BackColor")) { |
444 |
symbol.m_BackColor = StringUtilities.string2Color(xml.getStringProperty( |
445 |
"m_BackColor"));
|
446 |
} |
447 |
|
448 |
if (xml.contains("m_BackFill")) { |
449 |
symbol.m_BackFill = StringUtilities.string2Color(xml.getStringProperty( |
450 |
"m_BackFill"));
|
451 |
} |
452 |
|
453 |
symbol.rgb = xml.getIntProperty("rgb");
|
454 |
|
455 |
if (xml.contains("m_IconURI")) { |
456 |
try {
|
457 |
symbol.setIconURI(new URI(xml.getStringProperty("m_IconURI"))); |
458 |
} catch (URISyntaxException e) { |
459 |
// TODO Auto-generated catch block
|
460 |
e.printStackTrace(); |
461 |
} |
462 |
} |
463 |
|
464 |
return symbol;
|
465 |
} |
466 |
|
467 |
/**
|
468 |
* Crea el s?mbolo a partir del xml.
|
469 |
*
|
470 |
* @param xml xml que contiene la informaci?n para crear el s?mbolo.
|
471 |
*
|
472 |
* @return S?mbolo creado a partir del XML.
|
473 |
*/
|
474 |
public static FSymbol createFromXML(XMLEntity xml) { |
475 |
FSymbol symbol = new FSymbol();
|
476 |
symbol.setSymbolType(xml.getIntProperty("m_symbolType"));
|
477 |
symbol.setStyle(xml.getIntProperty("m_Style"));
|
478 |
System.out.println("createFromXML: m_Style=" + xml.getIntProperty("m_Style")); |
479 |
|
480 |
symbol.setOutlined(xml.getBooleanProperty("m_useOutline"));
|
481 |
|
482 |
if (xml.contains("m_Color")) { |
483 |
symbol.setColor(StringUtilities.string2Color(xml.getStringProperty( |
484 |
"m_Color")));
|
485 |
} |
486 |
|
487 |
if (xml.contains("m_outlineColor")) { |
488 |
symbol.setOutlineColor(StringUtilities.string2Color( |
489 |
xml.getStringProperty("m_outlineColor")));
|
490 |
} |
491 |
|
492 |
if (xml.contains("m_FontColor")) { |
493 |
symbol.setFont(new Font(xml.getStringProperty("fontname"), |
494 |
xml.getIntProperty("fontstyle"),
|
495 |
(int) xml.getFloatProperty("m_FontSize"))); |
496 |
symbol.setFontColor(StringUtilities.string2Color( |
497 |
xml.getStringProperty("m_FontColor")));
|
498 |
symbol.setFontSize(xml.getFloatProperty("m_FontSize"));
|
499 |
} |
500 |
|
501 |
symbol.setFontSizeInPixels(xml.getBooleanProperty("m_bUseFontSize"));
|
502 |
symbol.setShapeVisible(xml.getBooleanProperty("m_bDrawShape"));
|
503 |
symbol.setSize(xml.getIntProperty("m_Size"));
|
504 |
|
505 |
//xml.putProperty("m_Icon",m_Icon.);
|
506 |
symbol.setRotation(xml.getIntProperty("m_Rotation"));
|
507 |
|
508 |
if (xml.contains("m_Fill")) { |
509 |
// TODO: Si es un Fill de tipo imagen, deber?amos recuperar la imagen.
|
510 |
String strFill = xml.getStringProperty("m_Fill"); |
511 |
if (strFill.compareTo("WithFill") == 0) |
512 |
symbol.setFill(FSymbolFactory.createPatternFill(symbol.getStyle(), symbol.getColor())); |
513 |
else
|
514 |
symbol.setFill(StringUtilities.string2Color(strFill)); |
515 |
} |
516 |
|
517 |
|
518 |
symbol.m_LinePattern = xml.getStringProperty("m_LinePattern");
|
519 |
|
520 |
//Ancho del stroke en float
|
521 |
symbol.setStroke(new BasicStroke(xml.getFloatProperty("m_stroke"))); |
522 |
symbol.setSizeInPixels(xml.getBooleanProperty("m_bUseSize"));
|
523 |
symbol.setAlingVert(xml.getIntProperty("m_AlingVert"));
|
524 |
symbol.setAlingHoriz(xml.getIntProperty("m_AlingHoriz"));
|
525 |
symbol.setDescription(xml.getStringProperty("m_Descrip"));
|
526 |
|
527 |
if (xml.contains("m_BackColor")) { |
528 |
symbol.m_BackColor = StringUtilities.string2Color(xml.getStringProperty( |
529 |
"m_BackColor"));
|
530 |
} |
531 |
|
532 |
if (xml.contains("m_BackFill")) { |
533 |
symbol.m_BackFill = StringUtilities.string2Color(xml.getStringProperty( |
534 |
"m_BackFill"));
|
535 |
} |
536 |
|
537 |
symbol.rgb = xml.getIntProperty("rgb");
|
538 |
|
539 |
if (xml.contains("m_IconURI")) { |
540 |
try {
|
541 |
symbol.setIconURI(new URI(xml.getStringProperty("m_IconURI"))); |
542 |
} catch (URISyntaxException e) { |
543 |
// TODO Auto-generated catch block
|
544 |
e.printStackTrace(); |
545 |
} |
546 |
} |
547 |
|
548 |
return symbol;
|
549 |
} |
550 |
|
551 |
/**
|
552 |
* Introduce el estilo del s?mbolo.
|
553 |
*
|
554 |
* @param m_Style The m_Style to set.
|
555 |
*/
|
556 |
public void setStyle(int m_Style) { |
557 |
this.m_Style = m_Style;
|
558 |
|
559 |
// calculateRgb();
|
560 |
} |
561 |
|
562 |
/**
|
563 |
* Devuelve el estilo del s?mbolo.
|
564 |
*
|
565 |
* @return Returns the m_Style.
|
566 |
*/
|
567 |
public int getStyle() { |
568 |
return m_Style;
|
569 |
} |
570 |
|
571 |
/**
|
572 |
* Introduce el tipo de s?mbolo.
|
573 |
*
|
574 |
* @param m_symbolType The m_symbolType to set.
|
575 |
*/
|
576 |
public void setSymbolType(int m_symbolType) { |
577 |
this.m_symbolType = m_symbolType;
|
578 |
} |
579 |
|
580 |
/**
|
581 |
* Devuelve el tipo de s?mbolo.
|
582 |
*
|
583 |
* @return Returns the m_symbolType.
|
584 |
*/
|
585 |
public int getSymbolType() { |
586 |
return m_symbolType;
|
587 |
} |
588 |
|
589 |
/**
|
590 |
* Introduce si el s?mbolo contiene linea de brode o no.
|
591 |
*
|
592 |
* @param m_useOutline The m_useOutline to set.
|
593 |
*/
|
594 |
public void setOutlined(boolean m_useOutline) { |
595 |
this.m_useOutline = m_useOutline;
|
596 |
|
597 |
// calculateRgb();
|
598 |
} |
599 |
|
600 |
/**
|
601 |
* Devuelve si el s?mbolo contiene o no linea de borde.
|
602 |
*
|
603 |
* @return Returns the m_useOutline.
|
604 |
*/
|
605 |
public boolean isOutlined() { |
606 |
return m_useOutline;
|
607 |
} |
608 |
|
609 |
/**
|
610 |
* Introduce el color del s?mbolo.
|
611 |
*
|
612 |
* @param m_Color The m_Color to set.
|
613 |
*/
|
614 |
public void setColor(Color m_Color) { |
615 |
this.m_Color = m_Color;
|
616 |
|
617 |
// calculateRgb();
|
618 |
} |
619 |
|
620 |
/**
|
621 |
* Devuelve el color del s?mbolo.
|
622 |
*
|
623 |
* @return Returns the m_Color.
|
624 |
*/
|
625 |
public Color getColor() { |
626 |
return m_Color;
|
627 |
} |
628 |
|
629 |
/**
|
630 |
* Introduce el color de la l?nea de borde.
|
631 |
*
|
632 |
* @param m_outlineColor The m_outlineColor to set.
|
633 |
*/
|
634 |
public void setOutlineColor(Color m_outlineColor) { |
635 |
this.m_outlineColor = m_outlineColor;
|
636 |
|
637 |
// calculateRgb();
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* Devuelve el color de la l?nea de borde.
|
642 |
*
|
643 |
* @return Returns the m_outlineColor.
|
644 |
*/
|
645 |
public Color getOutlineColor() { |
646 |
return m_outlineColor;
|
647 |
} |
648 |
|
649 |
/**
|
650 |
* Introduce el Font del s?mbolo.
|
651 |
*
|
652 |
* @param m_Font The m_Font to set.
|
653 |
*/
|
654 |
public void setFont(Font m_Font) { |
655 |
this.m_Font = m_Font;
|
656 |
|
657 |
// calculateRgb();
|
658 |
} |
659 |
|
660 |
/**
|
661 |
* Devuelve el Font del s?mbolo.
|
662 |
*
|
663 |
* @return Returns the m_Font.
|
664 |
*/
|
665 |
public Font getFont() { |
666 |
return m_Font;
|
667 |
} |
668 |
|
669 |
/**
|
670 |
* Introduce el color de la fuente.
|
671 |
*
|
672 |
* @param m_FontColor The m_FontColor to set.
|
673 |
*/
|
674 |
public void setFontColor(Color m_FontColor) { |
675 |
this.m_FontColor = m_FontColor;
|
676 |
|
677 |
// calculateRgb();
|
678 |
} |
679 |
|
680 |
/**
|
681 |
* Devuelve el color de la fuente.
|
682 |
*
|
683 |
* @return Returns the m_FontColor.
|
684 |
*/
|
685 |
public Color getFontColor() { |
686 |
return m_FontColor;
|
687 |
} |
688 |
|
689 |
/**
|
690 |
* Introduce si se usa el tama?o de la fuente en pixels.
|
691 |
*
|
692 |
* @param m_bUseFontSize The m_bUseFontSize to set.
|
693 |
*/
|
694 |
public void setFontSizeInPixels(boolean m_bUseFontSize) { |
695 |
this.m_bUseFontSizeInPixels = m_bUseFontSize;
|
696 |
|
697 |
// calculateRgb();
|
698 |
} |
699 |
|
700 |
/**
|
701 |
* Devuelve true si el tama?o de la fuente esta seleccionado en pixels.
|
702 |
*
|
703 |
* @return Returns the m_bUseFontSize.
|
704 |
*/
|
705 |
public boolean isFontSizeInPixels() { |
706 |
return m_bUseFontSizeInPixels;
|
707 |
} |
708 |
|
709 |
/**
|
710 |
* Introduce si el shape e visible o no lo es.
|
711 |
*
|
712 |
* @param m_bDrawShape The m_bDrawShape to set.
|
713 |
*/
|
714 |
public void setShapeVisible(boolean m_bDrawShape) { |
715 |
this.m_bDrawShape = m_bDrawShape;
|
716 |
|
717 |
// calculateRgb();
|
718 |
} |
719 |
|
720 |
/**
|
721 |
* Devuelve true si el shape es visible.
|
722 |
*
|
723 |
* @return Returns the m_bDrawShape.
|
724 |
*/
|
725 |
public boolean isShapeVisible() { |
726 |
return m_bDrawShape;
|
727 |
} |
728 |
|
729 |
/**
|
730 |
* Introduce el tama?o del s?mbolo.
|
731 |
*
|
732 |
* @param m_Size The m_Size to set.
|
733 |
*/
|
734 |
public void setSize(int m_Size) { |
735 |
this.m_Size = m_Size;
|
736 |
|
737 |
// calculateRgb();
|
738 |
} |
739 |
|
740 |
/**
|
741 |
* Devuelve el tama?o del s?mbolo.
|
742 |
*
|
743 |
* @return Returns the m_Size.
|
744 |
*/
|
745 |
public int getSize() { |
746 |
return m_Size;
|
747 |
} |
748 |
|
749 |
/**
|
750 |
* Introduce la imagen que hace de icono.
|
751 |
*
|
752 |
* @param m_Icon The m_Icon to set.
|
753 |
*/
|
754 |
public void setIcon(Image m_Icon) { |
755 |
this.m_Icon = m_Icon;
|
756 |
|
757 |
// calculateRgb();
|
758 |
} |
759 |
|
760 |
/**
|
761 |
* Devuelve el icono.
|
762 |
*
|
763 |
* @return Returns the m_Icon.
|
764 |
*/
|
765 |
public Image getIcon() { |
766 |
return m_Icon;
|
767 |
} |
768 |
|
769 |
/**
|
770 |
* Introduce la rotaci?n.
|
771 |
*
|
772 |
* @param m_Rotation The m_Rotation to set.
|
773 |
*/
|
774 |
public void setRotation(int m_Rotation) { |
775 |
this.m_Rotation = m_Rotation;
|
776 |
|
777 |
// calculateRgb();
|
778 |
} |
779 |
|
780 |
/**
|
781 |
* Devuelve la rotaci?n.
|
782 |
*
|
783 |
* @return Returns the m_Rotation.
|
784 |
*/
|
785 |
public int getRotation() { |
786 |
return m_Rotation;
|
787 |
} |
788 |
|
789 |
/**
|
790 |
* Introduce el relleno.
|
791 |
*
|
792 |
* @param m_Fill The m_Fill to set.
|
793 |
*/
|
794 |
public void setFill(Paint m_Fill) { |
795 |
this.m_Fill = m_Fill;
|
796 |
|
797 |
// calculateRgb();
|
798 |
} |
799 |
|
800 |
/**
|
801 |
* Devuelve el relleno.
|
802 |
*
|
803 |
* @return Returns the m_Fill.
|
804 |
*/
|
805 |
public Paint getFill() { |
806 |
return m_Fill;
|
807 |
} |
808 |
|
809 |
/**
|
810 |
* Introduce el Stroke.
|
811 |
*
|
812 |
* @param m_Stroke The m_Stroke to set.
|
813 |
*/
|
814 |
public void setStroke(Stroke m_Stroke) { |
815 |
this.m_Stroke = m_Stroke;
|
816 |
|
817 |
// calculateRgb();
|
818 |
} |
819 |
|
820 |
/**
|
821 |
* Devuelve el Stroke.
|
822 |
*
|
823 |
* @return Returns the m_Stroke.
|
824 |
*/
|
825 |
public Stroke getStroke() { |
826 |
return m_Stroke;
|
827 |
} |
828 |
|
829 |
/**
|
830 |
* Introduce si el tama?o del simbolo est? en pixels.
|
831 |
*
|
832 |
* @param m_bUseSize The m_bUseSize to set.
|
833 |
*/
|
834 |
public void setSizeInPixels(boolean m_bUseSize) { |
835 |
this.m_bUseSize = m_bUseSize;
|
836 |
|
837 |
// calculateRgb();
|
838 |
} |
839 |
|
840 |
/**
|
841 |
* Devuelve si el tama?o del s?mbolo est? en pixels.
|
842 |
*
|
843 |
* @return Returns the m_bUseSize.
|
844 |
*/
|
845 |
public boolean isSizeInPixels() { |
846 |
return m_bUseSize;
|
847 |
} |
848 |
|
849 |
/**
|
850 |
* Introduce la descripci?n del s?mbolo.
|
851 |
*
|
852 |
* @param m_Descrip The m_Descrip to set.
|
853 |
*/
|
854 |
public void setDescription(String m_Descrip) { |
855 |
this.m_Descrip = m_Descrip;
|
856 |
} |
857 |
|
858 |
/**
|
859 |
* Devuelve la descripci?n del s?mbolo.
|
860 |
*
|
861 |
* @return Returns the m_Descrip.
|
862 |
*/
|
863 |
public String getDescription() { |
864 |
return m_Descrip;
|
865 |
} |
866 |
|
867 |
/**
|
868 |
* Introduce la alineaci?n en vertical.
|
869 |
*
|
870 |
* @param m_AlingVert The m_AlingVert to set.
|
871 |
*/
|
872 |
public void setAlingVert(int m_AlingVert) { |
873 |
this.m_AlingVert = m_AlingVert;
|
874 |
|
875 |
// calculateRgb();
|
876 |
} |
877 |
|
878 |
/**
|
879 |
* Devuelve la alineaci?n en vertical.
|
880 |
*
|
881 |
* @return Returns the m_AlingVert.
|
882 |
*/
|
883 |
public int getAlingVert() { |
884 |
return m_AlingVert;
|
885 |
} |
886 |
|
887 |
/**
|
888 |
* Introduce la alineaci?n en horizontal.
|
889 |
*
|
890 |
* @param m_AlingHoriz The m_AlingHoriz to set.
|
891 |
*/
|
892 |
public void setAlingHoriz(int m_AlingHoriz) { |
893 |
this.m_AlingHoriz = m_AlingHoriz;
|
894 |
|
895 |
// calculateRgb();
|
896 |
} |
897 |
|
898 |
/**
|
899 |
* Devuelve la alineaci?n en horizontal.
|
900 |
*
|
901 |
* @return Returns the m_AlingHoriz.
|
902 |
*/
|
903 |
public int getAlingHoriz() { |
904 |
return m_AlingHoriz;
|
905 |
} |
906 |
|
907 |
/**
|
908 |
* Devuelve el color que se aplica a los shapes seleccionados.
|
909 |
*
|
910 |
* @return DOCUMENT ME!
|
911 |
*/
|
912 |
public static Color getSelectionColor() { |
913 |
return selectionColor;
|
914 |
} |
915 |
|
916 |
/**
|
917 |
* Introduce el color que se aplica a los shapes seleccionados.
|
918 |
*
|
919 |
* @param selectionColor DOCUMENT ME!
|
920 |
*/
|
921 |
public static void setSelectionColor(Color selectionColor) { |
922 |
FSymbol.selectionColor = selectionColor; |
923 |
} |
924 |
|
925 |
/**
|
926 |
* Introduce el tama?o de la fuente.
|
927 |
*
|
928 |
* @param m_FontSize The m_FontSize to set.
|
929 |
*/
|
930 |
public void setFontSize(float m_FontSize) { |
931 |
this.m_FontSize = m_FontSize;
|
932 |
} |
933 |
|
934 |
/**
|
935 |
* Devuelve el tama?o de la fuente.
|
936 |
*
|
937 |
* @return Returns the m_FontSize.
|
938 |
*/
|
939 |
public float getFontSize() { |
940 |
return m_FontSize;
|
941 |
} |
942 |
public URI getIconURI() { |
943 |
return m_IconURI;
|
944 |
} |
945 |
public void setIconURI(URI iconURI) { |
946 |
m_IconURI = iconURI; |
947 |
ImageIcon prov;
|
948 |
try {
|
949 |
prov = new ImageIcon(iconURI.toURL()); |
950 |
m_Icon = prov.getImage(); |
951 |
} catch (MalformedURLException e) { |
952 |
// TODO Auto-generated catch block
|
953 |
e.printStackTrace(); |
954 |
} |
955 |
|
956 |
} |
957 |
} |