Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FGraphicUtilities.java @ 3783

History | View | Annotate | Download (18.9 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 || (!theSymbol.isShapeVisible())) {
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
            case FShape.CIRCLE:
255
                        case FShape.CIRCLE + FShape.Z:
256
                        case FShape.ARC:
257
                        case FShape.ARC + FShape.Z:
258
                        case FShape.ELLIPSE:
259
                        case FShape.ELLIPSE + FShape.Z:
260
                                // Shape theShp = mT.createTransformedShape(shp.m_Polyline);
261
                                // g2.setColor(theSymbol.m_Color);
262
                                if (theSymbol.getStroke() != null) {
263
                                        g2.setStroke(theSymbol.getStroke());
264
                                }
265

    
266
                                g2.draw(shp);
267

    
268
                                break;
269

    
270
                        case FShape.POLYGON:
271
            case FShape.POLYGON + FShape.Z:
272
                            if (theSymbol.getFill() != null)
273
                                g2.setPaint(theSymbol.getFill());
274

    
275
                            if (theSymbol.getColor() != null)
276
                                    if (theSymbol.getStyle() != FConstant.SYMBOL_STYLE_DGNSPECIAL) {
277
                                        g2.fill(shp);
278
                                }
279

    
280
                                if (theSymbol.isOutlined()) {
281
                                        g2.setColor(theSymbol.getOutlineColor());
282

    
283
                                        if (theSymbol.getStroke() != null) {
284
                                                g2.setStroke(theSymbol.getStroke());
285
                                        }
286

    
287
                                        g2.draw(shp);
288
                                }
289

    
290
                                break;
291

    
292
                }
293
        }
294

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

    
311
                // USAR TEXTLAYOUT SI QUEREMOS PERMITIR SELECCIONAR UN TEXTO
312
                // Y/O EDITARLO "IN SITU"
313

    
314
                /* if (m_labelValues[numReg].length() > 0)
315
                   {
316
                           TextLayout layout = new TextLayout(m_labelValues[numReg], font, frc);
317
                           layout.draw(g2, x, y);
318
                   } */
319
                if (shp == null) {
320
                        return;
321
                }
322

    
323
                // Las etiquetas que pongamos a nulo ser? porque no la queremos dibujar.
324
                // ?til para cuando queramos eliminar duplicados.
325
                if (theLabel.getString() == null) {
326
                        return;
327
                }
328

    
329
                FontMetrics metrics = g2.getFontMetrics();
330
                int width = metrics.stringWidth(theLabel.getString());
331
                int height = metrics.getMaxAscent();
332

    
333
                // int height = metrics.getHeight();
334
                g2.setFont(theSymbol.getFont());
335
                g2.setColor(theSymbol.getFontColor());
336

    
337
                // Aqu? hay que mirar m_Size y m_useSize...
338
                if (!theSymbol.isFontSizeInPixels()) {
339
                        // Suponemos que m_Size viene en coordenadas de mundo real
340
                        // Esto habr? que cambiarlo. Probablemente usar Style2d de geotools en lugar
341
                        // de FSymbol.
342
                        // CAMBIO: La altura del texto la miramos en FLabel
343
                        // float alturaPixels = (float) (theSymbol.m_FontSize * mT.getScaleX());
344
                        float alturaPixels = (float) (theLabel.getHeight() * mT.getScaleX());
345

    
346
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
347
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
348
                        if (alturaPixels < 3) {
349
                                return; // No leemos nada
350
                        }
351

    
352
                        Font nuevaFuente = theSymbol.getFont().deriveFont(alturaPixels);
353
                        g2.setFont(nuevaFuente);
354
                        width = g2.getFontMetrics().stringWidth(theLabel.getString());
355
                }
356

    
357
                int type=shp.getShapeType();
358
                if (shp.getShapeType()>=FShape.Z){
359
                        type=shp.getShapeType()-FShape.Z;
360
                }
361
                switch (type) {
362
                        case FShape.POINT: //Tipo punto
363
                                pAux = new Point2D.Double(((FPoint2D) shp).getX(),
364
                                                ((FPoint2D) shp).getY());
365
                                pAux = mT.transform(pAux, null);
366

    
367
                                break;
368

    
369
                        case FShape.LINE:
370

    
371
                                //
372
                                if (theLabel.getOrig() == null) // Calculamos el punto y la orientaci?n solo la primera vez
373
                                 {
374
                                        PathLength pathLen = new PathLength(shp);
375

    
376
                                        // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
377
                                        float midDistance = pathLen.lengthOfPath() / 2;
378
                                        pAux = pathLen.pointAtLength(midDistance);
379
                                        angle = pathLen.angleAtLength(midDistance);
380

    
381
                                        if (angle < 0) {
382
                                                angle = angle + (float) (2 * Math.PI);
383
                                        }
384

    
385
                                        if ((angle > (Math.PI / 2)) &&
386
                                                        (angle < ((3 * Math.PI) / 2))) {
387
                                                angle = angle - (float) Math.PI;
388
                                        }
389

    
390
                                        theLabel.setRotation(Math.toDegrees(angle));
391
                                        theLabel.setOrig(pAux);
392
                                }
393

    
394
                                pAux = mT.transform(theLabel.getOrig(), null);
395

    
396
                                // pAux = theLabel.getOrig();
397
                                // GlyphVector theGlyphs = theSymbol.m_Font.createGlyphVector(g2.getFontRenderContext(), theLabel);
398
                                // Shape txtShp = TextPathLayout.layoutGlyphVector(theGlyphs, shp.m_Polyline,TextPathLayout.ALIGN_MIDDLE);
399
                                // g2.draw(txtShp);
400
                                // System.out.println("Pintando etiqueta " + theLabel );
401
                                break;
402

    
403
                        case FShape.POLYGON:
404

    
405
                                if (theLabel.getOrig() == null) // Calculamos el punto solo la primera vez
406
                                 {
407
                                        Geometry geo = FConverter.java2d_to_jts(shp);
408

    
409
                                        // System.out.println("Area de " + m_labelValues[numReg] + " = "
410
                                        //   + geo.getArea());
411
                                        //   System.out.println(geo.toText());
412
                                        Point pJTS = geo.getInteriorPoint();
413
                                        FShape pLabel = FConverter.jts_to_java2d(pJTS);
414
                                        theLabel.setRotation(0);
415
                                        theLabel.setOrig(new Point2D.Double(
416
                                                        ((FPoint2D) pLabel).getX(),
417
                                                        ((FPoint2D) pLabel).getX()));
418
                                }
419

    
420
                                pAux = mT.transform(theLabel.getOrig(), null);
421

    
422
                                break;
423
                }
424

    
425
                AffineTransform ant = g2.getTransform();
426

    
427
                x = (float) pAux.getX();
428
                y = (float) pAux.getY();
429

    
430
                AffineTransform Tx = (AffineTransform) ant.clone();
431
                Tx.translate(x, y); // S3: final translation
432
                Tx.rotate(Math.toRadians(-theLabel.getRotation())); // S2: rotate around anchor
433
                g2.setTransform(Tx);
434

    
435
                switch (theLabel.getJustification()) {
436
                        case FLabel.LEFT_BOTTOM:
437
                                g2.drawString(theLabel.getString(), 0, 0 - 3);
438

    
439
                                break;
440

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

    
444
                                break;
445

    
446
                        case FLabel.LEFT_TOP:
447
                                g2.drawString(theLabel.getString(), 0, 0 - height);
448

    
449
                                break;
450

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

    
454
                                break;
455

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

    
460
                                break;
461

    
462
                        case FLabel.CENTER_TOP:
463
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 -
464
                                        height);
465

    
466
                                break;
467

    
468
                        case FLabel.RIGHT_BOTTOM:
469
                                g2.drawString(theLabel.getString(), 0 - width, 0 - 3);
470

    
471
                                break;
472

    
473
                        case FLabel.RIGHT_CENTER:
474
                                g2.drawString(theLabel.getString(), 0 - width, 0 -
475
                                        (height / 2));
476

    
477
                                break;
478

    
479
                        case FLabel.RIGHT_TOP:
480
                                g2.drawString(theLabel.getString(), 0 - width, 0 - height);
481

    
482
                                break;
483
                }
484

    
485
                // Restauramos
486
                g2.setTransform(ant);
487
        }
488

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

    
504
                /*if (x==0){
505
                   x=100;
506
                   }
507
                   if (y==0){
508
                           y=100;
509
                   }
510
                 */
511
                Rectangle rectAux = new Rectangle();
512

    
513
                // Aqu? hay que mirar m_Size y m_useSize...
514
                float radio_simbolo;
515
                radio_simbolo = theSymbol.getSize() / 2;
516

    
517
                if (!theSymbol.isSizeInPixels()) {
518
                        // Suponemos que m_Size viene en coordenadas de mundo real
519
                        radio_simbolo = (float) (theSymbol.getSize() * mT.getScaleX());
520

    
521
                        /* System.out.println("m_bUseSize = " + theSymbol.m_bUseSize +
522
                           " Escala: " + mT.getScaleX() + " alturaPixels = " + alturaPixels); */
523
                        // if (radio_simbolo < 1) return; // No dibujamos nada
524
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
525
                                radio_simbolo * 2, radio_simbolo * 2);
526
                } else {
527
                        // m_Size viene en pixels
528
                        rectAux.setRect(x - radio_simbolo, y - radio_simbolo,
529
                                theSymbol.getSize(), theSymbol.getSize());
530
                }
531

    
532
                //         continue; //radioSimbolo_en_pixels = 3;
533
                if (theSymbol.getFill() != null) {
534
                        g2.setPaint(theSymbol.getFill());
535
                }
536

    
537
                if (theSymbol.getStroke() != null) {
538
                        g2.setStroke(theSymbol.getStroke());
539
                }
540

    
541
                if (radio_simbolo < 2) {
542
                        g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
543

    
544
                        return;
545
                }
546

    
547
                switch (theSymbol.getStyle()) {
548
                        case FConstant.SYMBOL_STYLE_MARKER_CIRCLE: // Circulito
549

    
550
                                if (theSymbol.getColor() != null) {
551
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
552
                                                rectAux.height);
553
                                }
554

    
555
                                if (theSymbol.isOutlined()) {
556
                                        g2.setColor(theSymbol.getOutlineColor());
557
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
558
                                                rectAux.height);
559
                                }
560

    
561
                                break;
562

    
563
                        case FConstant.SYMBOL_STYLE_MARKER_SQUARE: // Cuadrado
564
                                g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
565

    
566
                                if (theSymbol.isOutlined()) {
567
                                        g2.setColor(theSymbol.getOutlineColor());
568
                                        g2.drawRect(rectAux.x, rectAux.y, rectAux.width,
569
                                                rectAux.height);
570
                                }
571

    
572
                                break;
573

    
574
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
575

    
576
                                // y = r*sin30, x = r*cos30
577
                                GeneralPathX genPath = new GeneralPathX();
578
                                genPath.moveTo(x - (int) (radio_simbolo * 0.866),
579
                                        y + (int) (radio_simbolo * 0.5));
580
                                genPath.lineTo(x + (int) (radio_simbolo * 0.866),
581
                                        y + (int) (radio_simbolo * 0.5));
582
                                genPath.lineTo(x, y - (float) radio_simbolo);
583
                                genPath.closePath();
584

    
585
                                g2.fill(genPath);
586

    
587
                                break;
588

    
589
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // cruz
590
                        case FConstant.SYMBOL_STYLE_DGNSPECIAL: // Cruz
591

    
592
                                GeneralPathX genPathCruz = new GeneralPathX();
593
                                genPathCruz.moveTo(x, y - radio_simbolo);
594
                                genPathCruz.lineTo(x, y + radio_simbolo);
595
                                genPathCruz.moveTo(x - radio_simbolo, y);
596
                                genPathCruz.lineTo(x + radio_simbolo, y);
597
                                g2.draw(genPathCruz);
598

    
599
                                break;
600

    
601
                        case 34: // TrueType marker
602

    
603
                        /* lf.lfHeight = -radioSimbolo_en_pixels;
604
                           angulo = pSimbolo->m_Rotation;  // En radianes, de -pi a pi
605
                           angulo = -180.0 * angulo / PI;
606

607
                           lf.lfEscapement = (long) angulo*10;
608
                           lf.lfOrientation = (long) angulo*10;
609

610
                           fuente.CreateFontIndirect(&lf);
611
                           pOldFont = pDC->SelectObject(&fuente);
612

613
                           pDC->TextOut(pAPI.x, pAPI.y+radioSimbolo_en_pixels/2,elChar,1);
614

615
                           pDC->SelectObject(pOldFont);
616
                           fuente.DeleteObject();
617

618
                           break; */
619
                        case FConstant.SYMBOL_STYLE_MARKER_IMAGEN: // Icono
620
                         {
621
                                if (theSymbol.getIcon() != null) {
622
                                        float w;
623
                                        float h;
624

    
625
                                        if (!theSymbol.isSizeInPixels()) {
626
                                                // Suponemos que m_Size viene en coordenadas de mundo real
627
                                                // Por ejemplo, nos valemos del ancho para fijar la escala
628
                                                w = (float) (theSymbol.getSize() * mT.getScaleX());
629
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
630
                                                                                                                                                                 .getWidth(null);
631

    
632
                                                rectAux.setRect(x - w, y - h, w * 2, h * 2);
633
                                        } else {
634
                                                // m_Size viene en pixels
635
                                                w = theSymbol.getSize();
636
                                                h = (theSymbol.getIcon().getHeight(null) * w) / theSymbol.getIcon()
637
                                                                                                                                                                 .getWidth(null);
638
                                                rectAux.setRect(x - w/2, y - h/2, w, h);
639
                                        }
640

    
641
                                        g2.drawImage(theSymbol.getIcon(), rectAux.x, rectAux.y,
642
                                                rectAux.width, rectAux.height, null);
643
                                } else {
644
                                        String strImg = "Image"; // Utilities.getMessage(FGraphicUtilities.class,"imagen");
645
                                        FontMetrics metrics = g2.getFontMetrics();
646
                                        int width = metrics.stringWidth(strImg);
647
                                        int height = metrics.getMaxAscent();
648

    
649
                                        g2.drawString(strImg, x - (width / 2), y - 2 +
650
                                                (height / 2));
651
                                }
652

    
653
                                break;
654
                        }
655

    
656
                        /* DrawIconEx(pDC->m_hDC, pAPI.x-(pSimbolo->m_widthIco/2), pAPI.y-(pSimbolo->m_heightIco/2),
657
                           pSimbolo->m_hIcon, pSimbolo->m_widthIco, pSimbolo->m_heightIco, 0 , NULL, DI_NORMAL);
658
                           break; */
659
                        case FConstant.SYMBOL_STYLE_POINTZ: // Circulito
660

    
661
                                if (theSymbol.getColor() != null) {
662
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
663
                                                rectAux.height);
664
                                }
665

    
666
                                if (theSymbol.isOutlined()) {
667
                                        g2.setColor(theSymbol.getOutlineColor());
668
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
669
                                                rectAux.height);
670
                                }
671

    
672
                                break;
673
                } // del switch estilo
674
        }
675

    
676
}