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