Statistics
| Revision:

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

History | View | Annotate | Download (18.7 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.Coordinate;
56
import com.vividsolutions.jts.geom.CoordinateArrays;
57
import com.vividsolutions.jts.geom.Geometry;
58
import com.vividsolutions.jts.geom.GeometryFactory;
59
import com.vividsolutions.jts.geom.Point;
60

    
61
import org.apache.batik.ext.awt.geom.PathLength;
62

    
63
import java.awt.Font;
64
import java.awt.FontMetrics;
65
import java.awt.Graphics2D;
66
import java.awt.Rectangle;
67
import java.awt.geom.AffineTransform;
68
import java.awt.geom.PathIterator;
69
import java.awt.geom.Point2D;
70
import java.util.ArrayList;
71

    
72

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

    
92
                AffineTransform mT = new AffineTransform();
93
                mT.setToIdentity();
94

    
95
                Rectangle r2 = new Rectangle(r.x + 2 + (r.width / 3), r.y, r.width / 3,
96
                                r.height);
97
                Rectangle r3 = new Rectangle(r.x + 2 + ((2 * r.width) / 3), r.y,
98
                                r.width / 3, r.height);
99

    
100
                // g2.clearRect(r.x, r.y, r.width, r.height);
101
                // System.out.println("r = " + r.toString() + " Color preview:" + symbol.m_Color.toString());
102
                // System.out.println("symbol.m_symbolType= "+symbol.m_symbolType);
103
                switch (symbol.getSymbolType()) {
104
                        case FConstant.SYMBOL_TYPE_POINT:
105
                                shp = new FPoint2D(r.x + (r.width / 2), r.y + (r.height / 2));
106

    
107
                                //  Para no tener que clonarlo si viene en unidades de mapa
108
                                boolean bAux2 = symbol.isSizeInPixels();
109
                                int alturaMetros = symbol.getSize(); // Nota: Cambiar m_Size a float
110

    
111
                                if (!bAux2) {
112
                                        symbol.setSizeInPixels(true);
113
                                        symbol.setSize(8); // tama?o fijo
114
                                }
115

    
116
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
117

    
118
                                if (!bAux2) {
119
                                        symbol.setSize(alturaMetros);
120
                                        symbol.setSizeInPixels(bAux2);
121
                                }
122

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

    
132
                                break;
133

    
134
                        case FConstant.SYMBOL_TYPE_LINE:
135

    
136
                                Rectangle rect = mT2.createTransformedShape(r).getBounds();
137
                                GeneralPathX line = new GeneralPathX();
138
                                line.moveTo(rect.x, rect.y + (rect.height / 2));
139

    
140
                                // line.lineTo(rect.x + rect.width/3, rect.y + rect.height);                                                                
141
                                // line.lineTo(rect.x + 2*rect.width/3, rect.y);                                
142
                                // line.lineTo(rect.x + rect.width, rect.y + rect.height/2);
143
                                line.curveTo(rect.x + (rect.width / 3),
144
                                        rect.y + (2 * rect.height),
145
                                        rect.x + ((2 * rect.width) / 3), rect.y - rect.height,
146
                                        rect.x + rect.width, rect.y + (rect.height / 2));
147

    
148
                                shp = new FPolyline2D(line);
149
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
150

    
151
                                break;
152

    
153
                        case FConstant.SYMBOL_TYPE_FILL:
154

    
155
                                GeneralPathX rectAux = new GeneralPathX(r);
156
                                rectAux.transform(mT2);
157
                                shp = new FPolygon2D(rectAux);
158

    
159
                                // System.out.println("rect = "+rectAux.getBounds());
160
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
161

    
162
                                break;
163

    
164
                        case FShape.MULTI:
165

    
166
                                // Pol?gono
167
                                r.resize(r.width / 3, r.height);
168

    
169
                                GeneralPathX rectAux2 = new GeneralPathX(r);
170
                                rectAux2.transform(mT2);
171
                                shp = new FPolygon2D(rectAux2);
172
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
173

    
174
                                // L?nea
175
                                rect = mT2.createTransformedShape(r2).getBounds();
176
                                line = new GeneralPathX();
177
                                line.moveTo(rect.x, rect.y + (rect.height / 2));
178

    
179
                                line.curveTo(rect.x + (rect.width / 3),
180
                                        rect.y + (2 * rect.height),
181
                                        rect.x + ((2 * rect.width) / 3), rect.y - rect.height,
182
                                        rect.x + rect.width, rect.y + (rect.height / 2));
183

    
184
                                shp = new FPolyline2D(line);
185
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
186

    
187
                                // Punto:
188
                                shp = new FPoint2D(r3.x + (r3.width / 2), r3.y +
189
                                                (r3.height / 2));
190

    
191
                                //  Para no tener que clonarlo si viene en unidades de mapa
192
                                bAux2 = symbol.isSizeInPixels();
193
                                alturaMetros = symbol.getSize(); // Nota: Cambiar m_Size a float
194

    
195
                                if (!bAux2) {
196
                                        symbol.setSizeInPixels(true);
197
                                        symbol.setSize(4); // tama?o fijo
198
                                }
199

    
200
                                FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
201

    
202
                                if (!bAux2) {
203
                                        symbol.setSize(alturaMetros);
204
                                        symbol.setSizeInPixels(bAux2);
205
                                }
206

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

    
216
                                break;
217
                }
218
        }
219

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

    
237
                /* if (shp instanceof FPolygon2D)
238
                   {
239
                           System.out.println("Entra pol?gono");
240
                   } */
241
                int type=shp.getShapeType();
242
                /* if (shp.getShapeType()>=FShape.Z){
243
                        type=shp.getShapeType()-FShape.Z;
244
                } */
245
                switch (type) {
246
                        case FShape.POINT: //Tipo punto
247
            case FShape.POINT + FShape.Z:
248
                                drawSymbolPoint(g2, mT, (FPoint2D) shp, theSymbol);
249

    
250
                                break;
251

    
252
                        case FShape.LINE:
253
            case FShape.LINE + FShape.Z:
254
                                // Shape theShp = mT.createTransformedShape(shp.m_Polyline);
255
                                // g2.setColor(theSymbol.m_Color);
256
                                if (theSymbol.getStroke() != null) {
257
                                        g2.setStroke(theSymbol.getStroke());
258
                                }
259

    
260
                                g2.draw(shp);
261

    
262
                                break;
263

    
264
                        case FShape.POLYGON:
265
            case FShape.POLYGON + FShape.Z:
266
                            if (theSymbol.getFill() != null)
267
                                g2.setPaint(theSymbol.getFill());
268

    
269
                            if (theSymbol.getColor() != null)                                    
270
                                    if (theSymbol.getStyle() != FConstant.SYMBOL_STYLE_DGNSPECIAL) {
271
                                        g2.fill(shp);
272
                                } 
273

    
274
                                if (theSymbol.isOutlined()) {
275
                                        g2.setColor(theSymbol.getOutlineColor());
276

    
277
                                        if (theSymbol.getStroke() != null) {
278
                                                g2.setStroke(theSymbol.getStroke());
279
                                        }
280

    
281
                                        g2.draw(shp);
282
                                }
283

    
284
                                break;
285
                }
286
        }
287

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

    
304
                // USAR TEXTLAYOUT SI QUEREMOS PERMITIR SELECCIONAR UN TEXTO
305
                // Y/O EDITARLO "IN SITU"
306

    
307
                /* if (m_labelValues[numReg].length() > 0)
308
                   {
309
                           TextLayout layout = new TextLayout(m_labelValues[numReg], font, frc);
310
                           layout.draw(g2, x, y);
311
                   } */
312
                if (shp == null) {
313
                        return;
314
                }
315

    
316
                // Las etiquetas que pongamos a nulo ser? porque no la queremos dibujar.
317
                // ?til para cuando queramos eliminar duplicados.
318
                if (theLabel.getString() == null) {
319
                        return;
320
                }
321

    
322
                FontMetrics metrics = g2.getFontMetrics();
323
                int width = metrics.stringWidth(theLabel.getString());
324
                int height = metrics.getMaxAscent();
325

    
326
                // int height = metrics.getHeight();
327
                g2.setFont(theSymbol.getFont());
328
                g2.setColor(theSymbol.getFontColor());
329

    
330
                // Aqu? hay que mirar m_Size y m_useSize...
331
                if (!theSymbol.isFontSizeInPixels()) {
332
                        // Suponemos que m_Size viene en coordenadas de mundo real
333
                        // Esto habr? que cambiarlo. Probablemente usar Style2d de geotools en lugar
334
                        // de FSymbol.
335
                        // CAMBIO: La altura del texto la miramos en FLabel
336
                        // float alturaPixels = (float) (theSymbol.m_FontSize * mT.getScaleX());
337
                        float alturaPixels = (float) (theLabel.getHeight() * mT.getScaleX());
338

    
339
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
340
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
341
                        if (alturaPixels < 3) {
342
                                return; // No leemos nada
343
                        }
344

    
345
                        Font nuevaFuente = theSymbol.getFont().deriveFont(alturaPixels);
346
                        g2.setFont(nuevaFuente);
347
                        width = g2.getFontMetrics().stringWidth(theLabel.getString());
348
                }
349

    
350
                int type=shp.getShapeType();
351
                if (shp.getShapeType()>=FShape.Z){
352
                        type=shp.getShapeType()-FShape.Z;
353
                }
354
                switch (type) {
355
                        case FShape.POINT: //Tipo punto
356
                                pAux = new Point2D.Double(((FPoint2D) shp).getX(),
357
                                                ((FPoint2D) shp).getY());
358
                                pAux = mT.transform(pAux, null);
359

    
360
                                break;
361

    
362
                        case FShape.LINE:
363

    
364
                                // 
365
                                if (theLabel.getOrig() == null) // Calculamos el punto y la orientaci?n solo la primera vez
366
                                 {
367
                                        PathLength pathLen = new PathLength(shp);
368

    
369
                                        // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
370
                                        float midDistance = pathLen.lengthOfPath() / 2;
371
                                        pAux = pathLen.pointAtLength(midDistance);
372
                                        angle = pathLen.angleAtLength(midDistance);
373

    
374
                                        if (angle < 0) {
375
                                                angle = angle + (float) (2 * Math.PI);
376
                                        }
377

    
378
                                        if ((angle > (Math.PI / 2)) &&
379
                                                        (angle < ((3 * Math.PI) / 2))) {
380
                                                angle = angle - (float) Math.PI;
381
                                        }
382

    
383
                                        theLabel.setRotation(Math.toDegrees(angle));
384
                                        theLabel.setOrig(pAux);
385
                                }
386

    
387
                                pAux = mT.transform(theLabel.getOrig(), null);
388

    
389
                                // pAux = theLabel.getOrig();
390
                                // GlyphVector theGlyphs = theSymbol.m_Font.createGlyphVector(g2.getFontRenderContext(), theLabel);
391
                                // Shape txtShp = TextPathLayout.layoutGlyphVector(theGlyphs, shp.m_Polyline,TextPathLayout.ALIGN_MIDDLE);                                
392
                                // g2.draw(txtShp);
393
                                // System.out.println("Pintando etiqueta " + theLabel );
394
                                break;
395

    
396
                        case FShape.POLYGON:
397

    
398
                                if (theLabel.getOrig() == null) // Calculamos el punto solo la primera vez
399
                                 {
400
                                        Geometry geo = FConverter.java2d_to_jts(shp);
401

    
402
                                        // System.out.println("Area de " + m_labelValues[numReg] + " = "
403
                                        //   + geo.getArea());
404
                                        //   System.out.println(geo.toText()); 
405
                                        Point pJTS = geo.getInteriorPoint();
406
                                        FShape pLabel = FConverter.jts_to_java2d(pJTS);
407
                                        theLabel.setRotation(0);
408
                                        theLabel.setOrig(new Point2D.Double(
409
                                                        ((FPoint2D) pLabel).getX(),
410
                                                        ((FPoint2D) pLabel).getX()));
411
                                }
412

    
413
                                pAux = mT.transform(theLabel.getOrig(), null);
414

    
415
                                break;
416
                }
417

    
418
                AffineTransform ant = g2.getTransform();
419

    
420
                x = (float) pAux.getX();
421
                y = (float) pAux.getY();
422

    
423
                AffineTransform Tx = (AffineTransform) ant.clone();
424
                Tx.translate(x, y); // S3: final translation
425
                Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
426
                g2.setTransform(Tx);
427

    
428
                switch (theLabel.getJustification()) {
429
                        case FLabel.LEFT_BOTTOM:
430
                                g2.drawString(theLabel.getString(), 0, 0 - 3);
431

    
432
                                break;
433

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

    
437
                                break;
438

    
439
                        case FLabel.LEFT_TOP:
440
                                g2.drawString(theLabel.getString(), 0, 0 - height);
441

    
442
                                break;
443

    
444
                        case FLabel.CENTER_BOTTOM:
445
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 - 3);
446

    
447
                                break;
448

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

    
453
                                break;
454

    
455
                        case FLabel.CENTER_TOP:
456
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 -
457
                                        height);
458

    
459
                                break;
460

    
461
                        case FLabel.RIGHT_BOTTOM:
462
                                g2.drawString(theLabel.getString(), 0 - width, 0 - 3);
463

    
464
                                break;
465

    
466
                        case FLabel.RIGHT_CENTER:
467
                                g2.drawString(theLabel.getString(), 0 - width, 0 -
468
                                        (height / 2));
469

    
470
                                break;
471

    
472
                        case FLabel.RIGHT_TOP:
473
                                g2.drawString(theLabel.getString(), 0 - width, 0 - height);
474

    
475
                                break;
476
                }
477

    
478
                // Restauramos
479
                g2.setTransform(ant);
480
        }
481

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

    
497
                /*if (x==0){
498
                   x=100;
499
                   }
500
                   if (y==0){
501
                           y=100;
502
                   }
503
                 */
504
                Rectangle rectAux = new Rectangle();
505

    
506
                // Aqu? hay que mirar m_Size y m_useSize...
507
                float radio_simbolo;
508
                radio_simbolo = theSymbol.getSize() / 2;
509

    
510
                if (!theSymbol.isSizeInPixels()) {
511
                        // Suponemos que m_Size viene en coordenadas de mundo real
512
                        radio_simbolo = (float) (theSymbol.getSize() * mT.getScaleX());
513

    
514
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
515
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
516
                        // if (radio_simbolo < 1) return; // No dibujamos nada
517
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
518
                                radio_simbolo * 2, radio_simbolo * 2);
519
                } else {
520
                        // m_Size viene en pixels
521
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
522
                                theSymbol.getSize(), theSymbol.getSize());
523
                }
524

    
525
                //         continue; //radioSimbolo_en_pixels = 3;
526
                if (theSymbol.getFill() != null) {
527
                        g2.setPaint(theSymbol.getFill());
528
                }
529

    
530
                if (theSymbol.getStroke() != null) {
531
                        g2.setStroke(theSymbol.getStroke());
532
                }
533

    
534
                if (radio_simbolo < 2) {
535
                        g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
536

    
537
                        return;
538
                }
539

    
540
                switch (theSymbol.getStyle()) {
541
                        case FConstant.SYMBOL_STYLE_MARKER_CIRCLE: // Circulito
542

    
543
                                if (theSymbol.getColor() != null) {
544
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
545
                                                rectAux.height);
546
                                }
547

    
548
                                if (theSymbol.isOutlined()) {
549
                                        g2.setColor(theSymbol.getOutlineColor());
550
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
551
                                                rectAux.height);
552
                                }
553

    
554
                                break;
555

    
556
                        case FConstant.SYMBOL_STYLE_MARKER_SQUARE: // Cuadrado
557
                                g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
558

    
559
                                if (theSymbol.isOutlined()) {
560
                                        g2.setColor(theSymbol.getOutlineColor());
561
                                        g2.drawRect(rectAux.x, rectAux.y, rectAux.width,
562
                                                rectAux.height);
563
                                }
564

    
565
                                break;
566

    
567
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
568

    
569
                                // y = r*sin30, x = r*cos30
570
                                GeneralPathX genPath = new GeneralPathX();
571
                                genPath.moveTo(x - (int) (radio_simbolo * 0.866),
572
                                        y + (int) (radio_simbolo * 0.5));
573
                                genPath.lineTo(x + (int) (radio_simbolo * 0.866),
574
                                        y + (int) (radio_simbolo * 0.5));
575
                                genPath.lineTo(x, y - (float) radio_simbolo);
576
                                genPath.closePath();
577

    
578
                                g2.fill(genPath);
579

    
580
                                break;
581

    
582
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // cruz
583
                        case FConstant.SYMBOL_STYLE_DGNSPECIAL: // Cruz
584

    
585
                                GeneralPathX genPathCruz = new GeneralPathX();
586
                                genPathCruz.moveTo(x, y - radio_simbolo);
587
                                genPathCruz.lineTo(x, y + radio_simbolo);
588
                                genPathCruz.moveTo(x - radio_simbolo, y);
589
                                genPathCruz.lineTo(x + radio_simbolo, y);
590
                                g2.draw(genPathCruz);
591

    
592
                                break;
593

    
594
                        case 34: // TrueType marker
595

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

    
618
                                        if (!theSymbol.isSizeInPixels()) {
619
                                                // Suponemos que m_Size viene en coordenadas de mundo real
620
                                                // Por ejemplo, nos valemos del ancho para fijar la escala
621
                                                w = (float) (theSymbol.getSize() * mT.getScaleX());
622
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
623
                                                                                                                                                                 .getWidth(null);
624

    
625
                                                rectAux.setRect(x - w, y - h, w * 2, h * 2);
626
                                        } else {
627
                                                // m_Size viene en pixels
628
                                                w = theSymbol.getSize();
629
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
630
                                                                                                                                                                 .getWidth(null);
631
                                                rectAux.setRect(x - w, y - h, w, h);
632
                                        }
633

    
634
                                        g2.drawImage(theSymbol.getIcon(), rectAux.x, rectAux.y,
635
                                                rectAux.width, rectAux.height, null);
636
                                } else {
637
                                        String strImg = "Image"; // Utilities.getMessage(FGraphicUtilities.class,"imagen"); 
638
                                        FontMetrics metrics = g2.getFontMetrics();
639
                                        int width = metrics.stringWidth(strImg);
640
                                        int height = metrics.getMaxAscent();
641

    
642
                                        g2.drawString(strImg, x - (width / 2), y - 2 +
643
                                                (height / 2));
644
                                }
645

    
646
                                break;
647
                        }
648

    
649
                        /* DrawIconEx(pDC->m_hDC, pAPI.x-(pSimbolo->m_widthIco/2), pAPI.y-(pSimbolo->m_heightIco/2),
650
                           pSimbolo->m_hIcon, pSimbolo->m_widthIco, pSimbolo->m_heightIco, 0 , NULL, DI_NORMAL);
651
                           break; */
652
                        case FConstant.SYMBOL_STYLE_POINTZ: // Circulito
653

    
654
                                if (theSymbol.getColor() != null) {
655
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
656
                                                rectAux.height);
657
                                }
658

    
659
                                if (theSymbol.isOutlined()) {
660
                                        g2.setColor(theSymbol.getOutlineColor());
661
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
662
                                                rectAux.height);
663
                                }
664

    
665
                                break;
666
                } // del switch estilo
667
        }
668
    
669
}