Statistics
| Revision:

svn-gvsig-desktop / tags / Root_Fmap_GisPlanet / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FGraphicUtilities.java @ 1826

History | View | Annotate | Download (18.2 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
        g2.setColor(theSymbol.getColor());
231

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

    
240
                                break;
241

    
242
                        case FShape.LINE:
243

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

    
250
                                g2.draw(shp);
251

    
252
                                break;
253

    
254
                        case FShape.POLYGON:
255
                            if (theSymbol.getFill() != null)
256
                                g2.setPaint(theSymbol.getFill());
257

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

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

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

    
270
                                        g2.draw(shp);
271
                                }
272

    
273
                                break;
274
                }
275
        }
276

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

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

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

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

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

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

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

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

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

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

    
345
                                break;
346

    
347
                        case FShape.LINE:
348

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

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

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

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

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

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

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

    
381
                        case FShape.POLYGON:
382

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

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

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

    
400
                                break;
401
                }
402

    
403
                AffineTransform ant = g2.getTransform();
404

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

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

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

    
417
                                break;
418

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

    
422
                                break;
423

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

    
427
                                break;
428

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

    
432
                                break;
433

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

    
438
                                break;
439

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

    
444
                                break;
445

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

    
449
                                break;
450

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

    
455
                                break;
456

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

    
460
                                break;
461
                }
462

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

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

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

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

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

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

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

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

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

    
522
                        return;
523
                }
524

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

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

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

    
539
                                break;
540

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

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

    
550
                                break;
551

    
552
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
553

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

    
563
                                g2.fill(genPath);
564

    
565
                                break;
566

    
567
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // cruz
568
                        case FConstant.SYMBOL_STYLE_DGNSPECIAL: // Cruz
569

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

    
577
                                break;
578

    
579
                        case 34: // TrueType marker
580

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

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

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

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

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

    
631
                                break;
632
                        }
633

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

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

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

    
650
                                break;
651
                } // del switch estilo
652
        }
653
}