Statistics
| Revision:

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

History | View | Annotate | Download (18.3 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
                int type=shp.getShapeType();
237
                if (shp.getShapeType()>=FShape.Z){
238
                        type=shp.getShapeType()-FShape.Z;
239
                }
240
                switch (type) {
241
                        case FShape.POINT: //Tipo punto
242
                                drawSymbolPoint(g2, mT, (FPoint2D) shp, theSymbol);
243

    
244
                                break;
245

    
246
                        case FShape.LINE:
247

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

    
254
                                g2.draw(shp);
255

    
256
                                break;
257

    
258
                        case FShape.POLYGON:
259
                            if (theSymbol.getFill() != null)
260
                                g2.setPaint(theSymbol.getFill());
261

    
262
                            if (theSymbol.getColor() != null)                                    
263
                                    if (theSymbol.getStyle() != FConstant.SYMBOL_STYLE_DGNSPECIAL) {
264
                                        g2.fill(shp);
265
                                }
266

    
267
                                if (theSymbol.isOutlined()) {
268
                                        g2.setColor(theSymbol.getOutlineColor());
269

    
270
                                        if (theSymbol.getStroke() != null) {
271
                                                g2.setStroke(theSymbol.getStroke());
272
                                        }
273

    
274
                                        g2.draw(shp);
275
                                }
276

    
277
                                break;
278
                }
279
        }
280

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

    
297
                // USAR TEXTLAYOUT SI QUEREMOS PERMITIR SELECCIONAR UN TEXTO
298
                // Y/O EDITARLO "IN SITU"
299

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

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

    
315
                FontMetrics metrics = g2.getFontMetrics();
316
                int width = metrics.stringWidth(theLabel.getString());
317
                int height = metrics.getMaxAscent();
318

    
319
                // int height = metrics.getHeight();
320
                g2.setFont(theSymbol.getFont());
321
                g2.setColor(theSymbol.getFontColor());
322

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

    
332
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
333
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
334
                        if (alturaPixels < 3) {
335
                                return; // No leemos nada
336
                        }
337

    
338
                        Font nuevaFuente = theSymbol.getFont().deriveFont(alturaPixels);
339
                        g2.setFont(nuevaFuente);
340
                        width = g2.getFontMetrics().stringWidth(theLabel.getString());
341
                }
342

    
343
                int type=shp.getShapeType();
344
                if (shp.getShapeType()>=FShape.Z){
345
                        type=shp.getShapeType()-FShape.Z;
346
                }
347
                switch (type) {
348
                        case FShape.POINT: //Tipo punto
349
                                pAux = new Point2D.Double(((FPoint2D) shp).getX(),
350
                                                ((FPoint2D) shp).getY());
351
                                pAux = mT.transform(pAux, null);
352

    
353
                                break;
354

    
355
                        case FShape.LINE:
356

    
357
                                // 
358
                                if (theLabel.getOrig() == null) // Calculamos el punto y la orientaci?n solo la primera vez
359
                                 {
360
                                        PathLength pathLen = new PathLength(shp);
361

    
362
                                        // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
363
                                        float midDistance = pathLen.lengthOfPath() / 2;
364
                                        pAux = pathLen.pointAtLength(midDistance);
365
                                        angle = pathLen.angleAtLength(midDistance);
366

    
367
                                        if (angle < 0) {
368
                                                angle = angle + (float) (2 * Math.PI);
369
                                        }
370

    
371
                                        if ((angle > (Math.PI / 2)) &&
372
                                                        (angle < ((3 * Math.PI) / 2))) {
373
                                                angle = angle - (float) Math.PI;
374
                                        }
375

    
376
                                        theLabel.setRotation(Math.toDegrees(angle));
377
                                        theLabel.setOrig(pAux);
378
                                }
379

    
380
                                pAux = mT.transform(theLabel.getOrig(), null);
381

    
382
                                // pAux = theLabel.getOrig();
383
                                // GlyphVector theGlyphs = theSymbol.m_Font.createGlyphVector(g2.getFontRenderContext(), theLabel);
384
                                // Shape txtShp = TextPathLayout.layoutGlyphVector(theGlyphs, shp.m_Polyline,TextPathLayout.ALIGN_MIDDLE);                                
385
                                // g2.draw(txtShp);
386
                                // System.out.println("Pintando etiqueta " + theLabel );
387
                                break;
388

    
389
                        case FShape.POLYGON:
390

    
391
                                if (theLabel.getOrig() == null) // Calculamos el punto solo la primera vez
392
                                 {
393
                                        Geometry geo = FConverter.java2d_to_jts(shp);
394

    
395
                                        // System.out.println("Area de " + m_labelValues[numReg] + " = "
396
                                        //   + geo.getArea());
397
                                        //   System.out.println(geo.toText()); 
398
                                        Point pJTS = geo.getInteriorPoint();
399
                                        FShape pLabel = FConverter.jts_to_java2d(pJTS);
400
                                        theLabel.setRotation(0);
401
                                        theLabel.setOrig(new Point2D.Double(
402
                                                        ((FPoint2D) pLabel).getX(),
403
                                                        ((FPoint2D) pLabel).getX()));
404
                                }
405

    
406
                                pAux = mT.transform(theLabel.getOrig(), null);
407

    
408
                                break;
409
                }
410

    
411
                AffineTransform ant = g2.getTransform();
412

    
413
                x = (float) pAux.getX();
414
                y = (float) pAux.getY();
415

    
416
                AffineTransform Tx = (AffineTransform) ant.clone();
417
                Tx.translate(x, y); // S3: final translation
418
                Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
419
                g2.setTransform(Tx);
420

    
421
                switch (theLabel.getJustification()) {
422
                        case FLabel.LEFT_BOTTOM:
423
                                g2.drawString(theLabel.getString(), 0, 0 - 3);
424

    
425
                                break;
426

    
427
                        case FLabel.LEFT_CENTER:
428
                                g2.drawString(theLabel.getString(), 0, 0 - (height / 2));
429

    
430
                                break;
431

    
432
                        case FLabel.LEFT_TOP:
433
                                g2.drawString(theLabel.getString(), 0, 0 - height);
434

    
435
                                break;
436

    
437
                        case FLabel.CENTER_BOTTOM:
438
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 - 3);
439

    
440
                                break;
441

    
442
                        case FLabel.CENTER_CENTER:
443
                                g2.drawString(theLabel.getString(), 0 - (width / 2),
444
                                        0 - (height / 2));
445

    
446
                                break;
447

    
448
                        case FLabel.CENTER_TOP:
449
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 -
450
                                        height);
451

    
452
                                break;
453

    
454
                        case FLabel.RIGHT_BOTTOM:
455
                                g2.drawString(theLabel.getString(), 0 - width, 0 - 3);
456

    
457
                                break;
458

    
459
                        case FLabel.RIGHT_CENTER:
460
                                g2.drawString(theLabel.getString(), 0 - width, 0 -
461
                                        (height / 2));
462

    
463
                                break;
464

    
465
                        case FLabel.RIGHT_TOP:
466
                                g2.drawString(theLabel.getString(), 0 - width, 0 - height);
467

    
468
                                break;
469
                }
470

    
471
                // Restauramos
472
                g2.setTransform(ant);
473
        }
474

    
475
        /**
476
         * Dibuja un punto sobre el Graphics2D que se pasa como par?metro.
477
         *
478
         * @param g2 Graphics2D sobre el que dibujar.
479
         * @param mT MAtriz de transformaci?n.
480
         * @param pAux punto a dibujar.
481
         * @param theSymbol S?mbolo a aplicar.
482
         */
483
        private static void drawSymbolPoint(Graphics2D g2, AffineTransform mT,
484
                FPoint2D pAux, FSymbol theSymbol) {
485
                int x;
486
                int y;
487
                x = (int) pAux.getX();
488
                y = (int) pAux.getY();
489

    
490
                /*if (x==0){
491
                   x=100;
492
                   }
493
                   if (y==0){
494
                           y=100;
495
                   }
496
                 */
497
                Rectangle rectAux = new Rectangle();
498

    
499
                // Aqu? hay que mirar m_Size y m_useSize...
500
                float radio_simbolo;
501
                radio_simbolo = theSymbol.getSize() / 2;
502

    
503
                if (!theSymbol.isSizeInPixels()) {
504
                        // Suponemos que m_Size viene en coordenadas de mundo real
505
                        radio_simbolo = (float) (theSymbol.getSize() * mT.getScaleX());
506

    
507
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
508
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
509
                        // if (radio_simbolo < 1) return; // No dibujamos nada
510
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
511
                                radio_simbolo * 2, radio_simbolo * 2);
512
                } else {
513
                        // m_Size viene en pixels
514
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
515
                                theSymbol.getSize(), theSymbol.getSize());
516
                }
517

    
518
                //         continue; //radioSimbolo_en_pixels = 3;
519
                if (theSymbol.getFill() != null) {
520
                        g2.setPaint(theSymbol.getFill());
521
                }
522

    
523
                if (theSymbol.getStroke() != null) {
524
                        g2.setStroke(theSymbol.getStroke());
525
                }
526

    
527
                if (radio_simbolo < 2) {
528
                        g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
529

    
530
                        return;
531
                }
532

    
533
                switch (theSymbol.getStyle()) {
534
                        case FConstant.SYMBOL_STYLE_MARKER_CIRCLE: // Circulito
535

    
536
                                if (theSymbol.getColor() != null) {
537
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
538
                                                rectAux.height);
539
                                }
540

    
541
                                if (theSymbol.isOutlined()) {
542
                                        g2.setColor(theSymbol.getOutlineColor());
543
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
544
                                                rectAux.height);
545
                                }
546

    
547
                                break;
548

    
549
                        case FConstant.SYMBOL_STYLE_MARKER_SQUARE: // Cuadrado
550
                                g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
551

    
552
                                if (theSymbol.isOutlined()) {
553
                                        g2.setColor(theSymbol.getOutlineColor());
554
                                        g2.drawRect(rectAux.x, rectAux.y, rectAux.width,
555
                                                rectAux.height);
556
                                }
557

    
558
                                break;
559

    
560
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
561

    
562
                                // y = r*sin30, x = r*cos30
563
                                GeneralPathX genPath = new GeneralPathX();
564
                                genPath.moveTo(x - (int) (radio_simbolo * 0.866),
565
                                        y + (int) (radio_simbolo * 0.5));
566
                                genPath.lineTo(x + (int) (radio_simbolo * 0.866),
567
                                        y + (int) (radio_simbolo * 0.5));
568
                                genPath.lineTo(x, y - (float) radio_simbolo);
569
                                genPath.closePath();
570

    
571
                                g2.fill(genPath);
572

    
573
                                break;
574

    
575
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // cruz
576
                        case FConstant.SYMBOL_STYLE_DGNSPECIAL: // Cruz
577

    
578
                                GeneralPathX genPathCruz = new GeneralPathX();
579
                                genPathCruz.moveTo(x, y - radio_simbolo);
580
                                genPathCruz.lineTo(x, y + radio_simbolo);
581
                                genPathCruz.moveTo(x - radio_simbolo, y);
582
                                genPathCruz.lineTo(x + radio_simbolo, y);
583
                                g2.draw(genPathCruz);
584

    
585
                                break;
586

    
587
                        case 34: // TrueType marker
588

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

    
611
                                        if (!theSymbol.isSizeInPixels()) {
612
                                                // Suponemos que m_Size viene en coordenadas de mundo real
613
                                                // Por ejemplo, nos valemos del ancho para fijar la escala
614
                                                w = (float) (theSymbol.getSize() * mT.getScaleX());
615
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
616
                                                                                                                                                                 .getWidth(null);
617

    
618
                                                rectAux.setRect(x - w, y - h, w * 2, h * 2);
619
                                        } else {
620
                                                // m_Size viene en pixels
621
                                                w = theSymbol.getSize();
622
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
623
                                                                                                                                                                 .getWidth(null);
624
                                                rectAux.setRect(x - w, y - h, w, h);
625
                                        }
626

    
627
                                        g2.drawImage(theSymbol.getIcon(), rectAux.x, rectAux.y,
628
                                                rectAux.width, rectAux.height, null);
629
                                } else {
630
                                        String strImg = "Image"; // Utilities.getMessage(FGraphicUtilities.class,"imagen"); 
631
                                        FontMetrics metrics = g2.getFontMetrics();
632
                                        int width = metrics.stringWidth(strImg);
633
                                        int height = metrics.getMaxAscent();
634

    
635
                                        g2.drawString(strImg, x - (width / 2), y - 2 +
636
                                                (height / 2));
637
                                }
638

    
639
                                break;
640
                        }
641

    
642
                        /* DrawIconEx(pDC->m_hDC, pAPI.x-(pSimbolo->m_widthIco/2), pAPI.y-(pSimbolo->m_heightIco/2),
643
                           pSimbolo->m_hIcon, pSimbolo->m_widthIco, pSimbolo->m_heightIco, 0 , NULL, DI_NORMAL);
644
                           break; */
645
                        case FConstant.SYMBOL_STYLE_POINTZ: // Circulito
646

    
647
                                if (theSymbol.getColor() != null) {
648
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
649
                                                rectAux.height);
650
                                }
651

    
652
                                if (theSymbol.isOutlined()) {
653
                                        g2.setColor(theSymbol.getOutlineColor());
654
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
655
                                                rectAux.height);
656
                                }
657

    
658
                                break;
659
                } // del switch estilo
660
        }
661
}