Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FGraphicUtilities.java @ 1100

History | View | Annotate | Download (18 KB)

1
/*
2
 * Created on 28-abr-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 com.iver.cit.gvsig.fmap.core.FPoint2D;
50
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
51
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
52
import com.iver.cit.gvsig.fmap.core.FShape;
53
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
54

    
55
import com.vividsolutions.jts.geom.Geometry;
56
import com.vividsolutions.jts.geom.Point;
57

    
58
import org.apache.batik.ext.awt.geom.PathLength;
59

    
60
import java.awt.Font;
61
import java.awt.FontMetrics;
62
import java.awt.Graphics2D;
63
import java.awt.Rectangle;
64
import java.awt.geom.AffineTransform;
65
import java.awt.geom.Point2D;
66

    
67

    
68
/**
69
 * Clase con m?todos est?ticos para dibujar sobre el Graphics que se les pase
70
 * como par?metro.
71
 *
72
 * @author fjp
73
 */
74
public class FGraphicUtilities {
75
        /**
76
         * Dibuja el s?mbolo que se le pasa como par?metro en el Graphics.
77
         *
78
         * @param g2 Graphics2D sobre el que dibujar.
79
         * @param mT2 Matriz de transformaci?n.
80
         * @param r Rect?ngulo.
81
         * @param symbol S?mbolo a dibujar.
82
         */
83
        public static void DrawSymbol(Graphics2D g2, AffineTransform mT2,
84
                Rectangle r, FSymbol symbol) {
85
                FShape shp;
86

    
87
                AffineTransform mT = new AffineTransform();
88
                mT.setToIdentity();
89

    
90
                Rectangle r2 = new Rectangle(r.x + 2 + (r.width / 3), r.y, r.width / 3,
91
                                r.height);
92
                Rectangle r3 = new Rectangle(r.x + 2 + ((2 * r.width) / 3), r.y,
93
                                r.width / 3, r.height);
94

    
95
                // g2.clearRect(r.x, r.y, r.width, r.height);
96
                // System.out.println("r = " + r.toString() + " Color preview:" + symbol.m_Color.toString());
97
                // System.out.println("symbol.m_symbolType= "+symbol.m_symbolType);
98
                switch (symbol.getSymbolType()) {
99
                        case FConstant.SYMBOL_TYPE_POINT:
100
                                shp = new FPoint2D(r.x + (r.width / 2), r.y + (r.height / 2));
101

    
102
                                //  Para no tener que clonarlo si viene en unidades de mapa
103
                                boolean bAux2 = symbol.isSizeInPixels();
104
                                int alturaMetros = symbol.getSize(); // Nota: Cambiar m_Size a float
105

    
106
                                if (!bAux2) {
107
                                        symbol.setSizeInPixels(true);
108
                                        symbol.setSize(8); // tama?o fijo
109
                                }
110

    
111
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
112

    
113
                                if (!bAux2) {
114
                                        symbol.setSize(alturaMetros);
115
                                        symbol.setSizeInPixels(bAux2);
116
                                }
117

    
118
                                if (symbol.getFont() != null) {
119
                                        // Para no tener que clonarlo si viene en unidades de mapa
120
                                        boolean bAux = symbol.isFontSizeInPixels();
121
                                        symbol.setFontSizeInPixels(true);
122
                                        FGraphicUtilities.DrawLabel(g2, mT, shp, symbol,
123
                                                new FLabel("Abcd"));
124
                                        symbol.setFontSizeInPixels(bAux);
125
                                }
126

    
127
                                break;
128

    
129
                        case FConstant.SYMBOL_TYPE_LINE:
130

    
131
                                Rectangle rect = mT2.createTransformedShape(r).getBounds();
132
                                GeneralPathX line = new GeneralPathX();
133
                                line.moveTo(rect.x, rect.y + (rect.height / 2));
134

    
135
                                // line.lineTo(rect.x + rect.width/3, rect.y + rect.height);                                                                
136
                                // line.lineTo(rect.x + 2*rect.width/3, rect.y);                                
137
                                // line.lineTo(rect.x + rect.width, rect.y + rect.height/2);
138
                                line.curveTo(rect.x + (rect.width / 3),
139
                                        rect.y + (2 * rect.height),
140
                                        rect.x + ((2 * rect.width) / 3), rect.y - rect.height,
141
                                        rect.x + rect.width, rect.y + (rect.height / 2));
142

    
143
                                shp = new FPolyline2D(line);
144
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
145

    
146
                                break;
147

    
148
                        case FConstant.SYMBOL_TYPE_FILL:
149

    
150
                                GeneralPathX rectAux = new GeneralPathX(r);
151
                                rectAux.transform(mT2);
152
                                shp = new FPolygon2D(rectAux);
153

    
154
                                // System.out.println("rect = "+rectAux.getBounds());
155
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
156

    
157
                                break;
158

    
159
                        case FShape.MULTI:
160

    
161
                                // Pol?gono
162
                                r.resize(r.width / 3, r.height);
163

    
164
                                GeneralPathX rectAux2 = new GeneralPathX(r);
165
                                rectAux2.transform(mT2);
166
                                shp = new FPolygon2D(rectAux2);
167
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
168

    
169
                                // L?nea
170
                                rect = mT2.createTransformedShape(r2).getBounds();
171
                                line = new GeneralPathX();
172
                                line.moveTo(rect.x, rect.y + (rect.height / 2));
173

    
174
                                line.curveTo(rect.x + (rect.width / 3),
175
                                        rect.y + (2 * rect.height),
176
                                        rect.x + ((2 * rect.width) / 3), rect.y - rect.height,
177
                                        rect.x + rect.width, rect.y + (rect.height / 2));
178

    
179
                                shp = new FPolyline2D(line);
180
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
181

    
182
                                // Punto:
183
                                shp = new FPoint2D(r3.x + (r3.width / 2), r3.y +
184
                                                (r3.height / 2));
185

    
186
                                //  Para no tener que clonarlo si viene en unidades de mapa
187
                                bAux2 = symbol.isSizeInPixels();
188
                                alturaMetros = symbol.getSize(); // Nota: Cambiar m_Size a float
189

    
190
                                if (!bAux2) {
191
                                        symbol.setSizeInPixels(true);
192
                                        symbol.setSize(4); // tama?o fijo
193
                                }
194

    
195
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
196

    
197
                                if (!bAux2) {
198
                                        symbol.setSize(alturaMetros);
199
                                        symbol.setSizeInPixels(bAux2);
200
                                }
201

    
202
                                if (symbol.getFont() != null) {
203
                                        // Para no tener que clonarlo si viene en unidades de mapa
204
                                        boolean bAux = symbol.isFontSizeInPixels();
205
                                        symbol.setFontSizeInPixels(true);
206
                                        FGraphicUtilities.DrawLabel(g2, mT, shp, symbol,
207
                                                new FLabel("Abcd"));
208
                                        symbol.setFontSizeInPixels(bAux);
209
                                }
210

    
211
                                break;
212
                }
213
        }
214

    
215
        /**
216
         * Dibuja el shape que se pasa como par?metro con las caracter?sticas que
217
         * aporta el s?mbolo sobre el Graphics2D.
218
         *
219
         * @param g2 Graphics2D sobre el que dibujar.
220
         * @param mT Matriz de transformaci?n.
221
         * @param shp FShape a dibujar.
222
         * @param theSymbol S?mbolo.
223
         */
224
        public static void DrawShape(Graphics2D g2, AffineTransform mT, FShape shp,
225
                FSymbol theSymbol) {
226
                // Hacemos la transformaci?n del shape aqu? dentro... por ahora.
227
                if (shp == null) {
228
                        return;
229
                }
230

    
231
                g2.setColor(theSymbol.getColor());
232

    
233
                /* if (shp instanceof FPolygon2D)
234
                   {
235
                           System.out.println("Entra pol?gono");
236
                   } */
237
                switch (shp.getShapeType()) {
238
                        case FShape.POINT: //Tipo punto
239
                                drawSymbolPoint(g2, mT, (FPoint2D) shp, theSymbol);
240

    
241
                                break;
242

    
243
                        case FShape.LINE:
244

    
245
                                // Shape theShp = mT.createTransformedShape(shp.m_Polyline);
246
                                // g2.setColor(theSymbol.m_Color);
247
                                if (theSymbol.getStroke() != null) {
248
                                        g2.setStroke(theSymbol.getStroke());
249
                                }
250

    
251
                                g2.draw(shp);
252

    
253
                                break;
254

    
255
                        case FShape.POLYGON:
256
                                g2.setPaint(theSymbol.getFill());
257

    
258
                                if (theSymbol.getColor() != null) {
259
                                        g2.fill(shp);
260
                                }
261

    
262
                                if (theSymbol.isOutlined()) {
263
                                        g2.setColor(theSymbol.getOutlineColor());
264

    
265
                                        if (theSymbol.getStroke() != null) {
266
                                                g2.setStroke(theSymbol.getStroke());
267
                                        }
268

    
269
                                        g2.draw(shp);
270
                                }
271

    
272
                                break;
273
                }
274
        }
275

    
276
        /**
277
         * Dibuja el FLabel que se pasa como par?metro sobre el Graphics2D.
278
         *
279
         * @param g2 Graphics2D sobre el que dibujar.
280
         * @param mT Matriz de transformaci?n.
281
         * @param shp FShape a dibujar.
282
         * @param theSymbol S?mbolo para aplicar.
283
         * @param theLabel FLabel que contiene el texto que se debe dibujar.
284
         */
285
        public static void DrawLabel(Graphics2D g2, AffineTransform mT, FShape shp,
286
                FSymbol theSymbol, FLabel theLabel) {
287
                float angle;
288
                float x;
289
                float y;
290
                Point2D pAux = null;
291

    
292
                // USAR TEXTLAYOUT SI QUEREMOS PERMITIR SELECCIONAR UN TEXTO
293
                // Y/O EDITARLO "IN SITU"
294

    
295
                /* if (m_labelValues[numReg].length() > 0)
296
                   {
297
                           TextLayout layout = new TextLayout(m_labelValues[numReg], font, frc);
298
                           layout.draw(g2, x, y);
299
                   } */
300
                if (shp == null) {
301
                        return;
302
                }
303

    
304
                // Las etiquetas que pongamos a nulo ser? porque no la queremos dibujar.
305
                // ?til para cuando queramos eliminar duplicados.
306
                if (theLabel.getString() == null) {
307
                        return;
308
                }
309

    
310
                FontMetrics metrics = g2.getFontMetrics();
311
                int width = metrics.stringWidth(theLabel.getString());
312
                int height = metrics.getMaxAscent();
313

    
314
                // int height = metrics.getHeight();
315
                g2.setFont(theSymbol.getFont());
316
                g2.setColor(theSymbol.getFontColor());
317

    
318
                // Aqu? hay que mirar m_Size y m_useSize...
319
                if (!theSymbol.isFontSizeInPixels()) {
320
                        // Suponemos que m_Size viene en coordenadas de mundo real
321
                        // Esto habr? que cambiarlo. Probablemente usar Style2d de geotools en lugar
322
                        // de FSymbol.
323
                        // CAMBIO: La altura del texto la miramos en FLabel
324
                        // float alturaPixels = (float) (theSymbol.m_FontSize * mT.getScaleX());
325
                        float alturaPixels = (float) (theLabel.getHeight() * mT.getScaleX());
326

    
327
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
328
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
329
                        if (alturaPixels < 3) {
330
                                return; // No leemos nada
331
                        }
332

    
333
                        Font nuevaFuente = theSymbol.getFont().deriveFont(alturaPixels);
334
                        g2.setFont(nuevaFuente);
335
                        width = g2.getFontMetrics().stringWidth(theLabel.getString());
336
                }
337

    
338
                switch (shp.getShapeType()) {
339
                        case FShape.POINT: //Tipo punto
340
                                pAux = new Point2D.Double(((FPoint2D) shp).getX(),
341
                                                ((FPoint2D) shp).getY());
342
                                pAux = mT.transform(pAux, null);
343

    
344
                                break;
345

    
346
                        case FShape.LINE:
347

    
348
                                // 
349
                                if (theLabel.getOrig() == null) // Calculamos el punto y la orientaci?n solo la primera vez
350
                                 {
351
                                        PathLength pathLen = new PathLength(shp);
352

    
353
                                        // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
354
                                        float midDistance = pathLen.lengthOfPath() / 2;
355
                                        pAux = pathLen.pointAtLength(midDistance);
356
                                        angle = pathLen.angleAtLength(midDistance);
357

    
358
                                        if (angle < 0) {
359
                                                angle = angle + (float) (2 * Math.PI);
360
                                        }
361

    
362
                                        if ((angle > (Math.PI / 2)) &&
363
                                                        (angle < ((3 * Math.PI) / 2))) {
364
                                                angle = angle - (float) Math.PI;
365
                                        }
366

    
367
                                        theLabel.setRotation(Math.toDegrees(angle));
368
                                        theLabel.setOrig(pAux);
369
                                }
370

    
371
                                pAux = mT.transform(theLabel.getOrig(), null);
372

    
373
                                // pAux = theLabel.getOrig();
374
                                // GlyphVector theGlyphs = theSymbol.m_Font.createGlyphVector(g2.getFontRenderContext(), theLabel);
375
                                // Shape txtShp = TextPathLayout.layoutGlyphVector(theGlyphs, shp.m_Polyline,TextPathLayout.ALIGN_MIDDLE);                                
376
                                // g2.draw(txtShp);
377
                                // System.out.println("Pintando etiqueta " + theLabel );
378
                                break;
379

    
380
                        case FShape.POLYGON:
381

    
382
                                if (theLabel.getOrig() == null) // Calculamos el punto solo la primera vez
383
                                 {
384
                                        Geometry geo = FConverter.java2d_to_jts(shp);
385

    
386
                                        // System.out.println("Area de " + m_labelValues[numReg] + " = "
387
                                        //   + geo.getArea());
388
                                        //   System.out.println(geo.toText()); 
389
                                        Point pJTS = geo.getInteriorPoint();
390
                                        FShape pLabel = FConverter.jts_to_java2d(pJTS);
391
                                        theLabel.setRotation(0);
392
                                        theLabel.setOrig(new Point2D.Double(
393
                                                        ((FPoint2D) pLabel).getX(),
394
                                                        ((FPoint2D) pLabel).getX()));
395
                                }
396

    
397
                                pAux = mT.transform(theLabel.getOrig(), null);
398

    
399
                                break;
400
                }
401

    
402
                AffineTransform ant = g2.getTransform();
403

    
404
                x = (float) pAux.getX();
405
                y = (float) pAux.getY();
406

    
407
                AffineTransform Tx = (AffineTransform) ant.clone();
408
                Tx.translate(x, y); // S3: final translation
409
                Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
410
                g2.setTransform(Tx);
411

    
412
                switch (theLabel.getJustification()) {
413
                        case FLabel.LEFT_BOTTOM:
414
                                g2.drawString(theLabel.getString(), 0, 0 - 3);
415

    
416
                                break;
417

    
418
                        case FLabel.LEFT_CENTER:
419
                                g2.drawString(theLabel.getString(), 0, 0 - (height / 2));
420

    
421
                                break;
422

    
423
                        case FLabel.LEFT_TOP:
424
                                g2.drawString(theLabel.getString(), 0, 0 - height);
425

    
426
                                break;
427

    
428
                        case FLabel.CENTER_BOTTOM:
429
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 - 3);
430

    
431
                                break;
432

    
433
                        case FLabel.CENTER_CENTER:
434
                                g2.drawString(theLabel.getString(), 0 - (width / 2),
435
                                        0 - (height / 2));
436

    
437
                                break;
438

    
439
                        case FLabel.CENTER_TOP:
440
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 -
441
                                        height);
442

    
443
                                break;
444

    
445
                        case FLabel.RIGHT_BOTTOM:
446
                                g2.drawString(theLabel.getString(), 0 - width, 0 - 3);
447

    
448
                                break;
449

    
450
                        case FLabel.RIGHT_CENTER:
451
                                g2.drawString(theLabel.getString(), 0 - width, 0 -
452
                                        (height / 2));
453

    
454
                                break;
455

    
456
                        case FLabel.RIGHT_TOP:
457
                                g2.drawString(theLabel.getString(), 0 - width, 0 - height);
458

    
459
                                break;
460
                }
461

    
462
                // Restauramos
463
                g2.setTransform(ant);
464
        }
465

    
466
        /**
467
         * Dibuja un punto sobre el Graphics2D que se pasa como par?metro.
468
         *
469
         * @param g2 Graphics2D sobre el que dibujar.
470
         * @param mT MAtriz de transformaci?n.
471
         * @param pAux punto a dibujar.
472
         * @param theSymbol S?mbolo a aplicar.
473
         */
474
        private static void drawSymbolPoint(Graphics2D g2, AffineTransform mT,
475
                FPoint2D pAux, FSymbol theSymbol) {
476
                int x;
477
                int y;
478
                x = (int) pAux.getX();
479
                y = (int) pAux.getY();
480

    
481
                /*if (x==0){
482
                   x=100;
483
                   }
484
                   if (y==0){
485
                           y=100;
486
                   }
487
                 */
488
                Rectangle rectAux = new Rectangle();
489

    
490
                // Aqu? hay que mirar m_Size y m_useSize...
491
                float radio_simbolo;
492
                radio_simbolo = theSymbol.getSize() / 2;
493

    
494
                if (!theSymbol.isSizeInPixels()) {
495
                        // Suponemos que m_Size viene en coordenadas de mundo real
496
                        radio_simbolo = (float) (theSymbol.getSize() * mT.getScaleX());
497

    
498
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
499
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
500
                        // if (radio_simbolo < 1) return; // No dibujamos nada
501
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
502
                                radio_simbolo * 2, radio_simbolo * 2);
503
                } else {
504
                        // m_Size viene en pixels
505
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
506
                                theSymbol.getSize(), theSymbol.getSize());
507
                }
508

    
509
                //         continue; //radioSimbolo_en_pixels = 3;
510
                if (theSymbol.getFill() != null) {
511
                        g2.setPaint(theSymbol.getFill());
512
                }
513

    
514
                if (theSymbol.getStroke() != null) {
515
                        g2.setStroke(theSymbol.getStroke());
516
                }
517

    
518
                if (radio_simbolo < 2) {
519
                        g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
520

    
521
                        return;
522
                }
523

    
524
                switch (theSymbol.getStyle()) {
525
                        case FConstant.SYMBOL_STYLE_MARKER_CIRCLE: // Circulito
526

    
527
                                if (theSymbol.getColor() != null) {
528
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
529
                                                rectAux.height);
530
                                }
531

    
532
                                if (theSymbol.isOutlined()) {
533
                                        g2.setColor(theSymbol.getOutlineColor());
534
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
535
                                                rectAux.height);
536
                                }
537

    
538
                                break;
539

    
540
                        case FConstant.SYMBOL_STYLE_MARKER_SQUARE: // Cuadrado
541
                                g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
542

    
543
                                if (theSymbol.isOutlined()) {
544
                                        g2.setColor(theSymbol.getOutlineColor());
545
                                        g2.drawRect(rectAux.x, rectAux.y, rectAux.width,
546
                                                rectAux.height);
547
                                }
548

    
549
                                break;
550

    
551
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
552

    
553
                                // y = r*sin30, x = r*cos30
554
                                GeneralPathX genPath = new GeneralPathX();
555
                                genPath.moveTo(x - (int) (radio_simbolo * 0.866),
556
                                        y + (int) (radio_simbolo * 0.5));
557
                                genPath.lineTo(x + (int) (radio_simbolo * 0.866),
558
                                        y + (int) (radio_simbolo * 0.5));
559
                                genPath.lineTo(x, y - (float) radio_simbolo);
560
                                genPath.closePath();
561

    
562
                                g2.fill(genPath);
563

    
564
                                break;
565

    
566
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // Cruz
567

    
568
                                GeneralPathX genPathCruz = new GeneralPathX();
569
                                genPathCruz.moveTo(x, y - radio_simbolo);
570
                                genPathCruz.lineTo(x, y + radio_simbolo);
571
                                genPathCruz.moveTo(x - radio_simbolo, y);
572
                                genPathCruz.lineTo(x + radio_simbolo, y);
573
                                g2.draw(genPathCruz);
574

    
575
                                break;
576

    
577
                        case 34: // TrueType marker
578

    
579
                        /* lf.lfHeight = -radioSimbolo_en_pixels;
580
                           angulo = pSimbolo->m_Rotation;  // En radianes, de -pi a pi
581
                           angulo = -180.0 * angulo / PI;
582
                        
583
                           lf.lfEscapement = (long) angulo*10;
584
                           lf.lfOrientation = (long) angulo*10;
585
                        
586
                           fuente.CreateFontIndirect(&lf);
587
                           pOldFont = pDC->SelectObject(&fuente);
588
                        
589
                           pDC->TextOut(pAPI.x, pAPI.y+radioSimbolo_en_pixels/2,elChar,1);
590
                        
591
                           pDC->SelectObject(pOldFont);
592
                           fuente.DeleteObject();
593
                        
594
                           break; */
595
                        case FConstant.SYMBOL_STYLE_MARKER_IMAGEN: // Icono
596
                         {
597
                                if (theSymbol.getIcon() != null) {
598
                                        float w;
599
                                        float h;
600

    
601
                                        if (theSymbol.isSizeInPixels()) {
602
                                                // Suponemos que m_Size viene en coordenadas de mundo real
603
                                                // Por ejemplo, nos valemos del ancho para fijar la escala
604
                                                w = (float) (theSymbol.getSize() * mT.getScaleX());
605
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
606
                                                                                                                                                                 .getWidth(null);
607

    
608
                                                rectAux.setRect(x - w, y - h, w * 2, h * 2);
609
                                        } else {
610
                                                // m_Size viene en pixels
611
                                                w = theSymbol.getSize();
612
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
613
                                                                                                                                                                 .getWidth(null);
614
                                                rectAux.setRect(x - w, y - h, w, h);
615
                                        }
616

    
617
                                        g2.drawImage(theSymbol.getIcon(), rectAux.x, rectAux.y,
618
                                                rectAux.width, rectAux.height, null);
619
                                } else {
620
                                        String strImg = "Image"; // Utilities.getMessage(FGraphicUtilities.class,"imagen"); 
621
                                        FontMetrics metrics = g2.getFontMetrics();
622
                                        int width = metrics.stringWidth(strImg);
623
                                        int height = metrics.getMaxAscent();
624

    
625
                                        g2.drawString(strImg, x - (width / 2), y - 2 +
626
                                                (height / 2));
627
                                }
628

    
629
                                break;
630
                        }
631

    
632
                        /* DrawIconEx(pDC->m_hDC, pAPI.x-(pSimbolo->m_widthIco/2), pAPI.y-(pSimbolo->m_heightIco/2),
633
                           pSimbolo->m_hIcon, pSimbolo->m_widthIco, pSimbolo->m_heightIco, 0 , NULL, DI_NORMAL);
634
                           break; */
635
                        case FConstant.SYMBOL_STYLE_POINTZ: // Circulito
636

    
637
                                if (theSymbol.getColor() != null) {
638
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
639
                                                rectAux.height);
640
                                }
641

    
642
                                if (theSymbol.isOutlined()) {
643
                                        g2.setColor(theSymbol.getOutlineColor());
644
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
645
                                                rectAux.height);
646
                                }
647

    
648
                                break;
649
                } // del switch estilo
650
        }
651
}