Statistics
| Revision:

root / tags / Root_FMap_piloto_CAD_Layout_version / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / v02 / FGraphicUtilities.java @ 1664

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 java.awt.Color;
50
import java.awt.Font;
51
import java.awt.FontMetrics;
52
import java.awt.Graphics2D;
53
import java.awt.Rectangle;
54
import java.awt.geom.AffineTransform;
55
import java.awt.geom.Point2D;
56

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

    
59
import com.iver.cit.gvsig.fmap.core.FPoint2D;
60
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
61
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
62
import com.iver.cit.gvsig.fmap.core.FShape;
63
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
64
import com.iver.cit.gvsig.fmap.core.Handler;
65
import com.vividsolutions.jts.geom.Geometry;
66
import com.vividsolutions.jts.geom.Point;
67

    
68

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

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

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

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

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

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

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

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

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

    
128
                                break;
129

    
130
                        case FConstant.SYMBOL_TYPE_LINE:
131

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

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

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

    
147
                                break;
148

    
149
                        case FConstant.SYMBOL_TYPE_FILL:
150

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

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

    
158
                                break;
159

    
160
                        case FShape.MULTI:
161

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

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

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

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

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

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

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

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

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

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

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

    
212
                                break;
213
                }
214
        }
215

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

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

    
241
                                break;
242

    
243
                        case FShape.LINE:
244
                        case FShape.ARC:
245
                        case FShape.ELLIPSE:
246
                        case FShape.CIRCLE:
247
                                // Shape theShp = mT.createTransformedShape(shp.m_Polyline);
248
                                // g2.setColor(theSymbol.m_Color);
249
                                if (theSymbol.getStroke() != null) {
250
                                        g2.setStroke(theSymbol.getStroke());
251
                                }
252

    
253
                                g2.draw(shp);
254

    
255
                                break;
256

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

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

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

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

    
273
                                        g2.draw(shp);
274
                                }
275

    
276
                                break;
277
                }
278
        }
279

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

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

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

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

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

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

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

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

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

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

    
348
                                break;
349

    
350
                        case FShape.LINE:
351

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

    
357
                                        // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
358
                                        float midDistance = pathLen.lengthOfPath() / 2;
359
                                        pAux = pathLen.pointAtLength(midDistance);
360
                                        angle = pathLen.angleAtLength(midDistance);
361

    
362
                                        if (angle < 0) {
363
                                                angle = angle + (float) (2 * Math.PI);
364
                                        }
365

    
366
                                        if ((angle > (Math.PI / 2)) &&
367
                                                        (angle < ((3 * Math.PI) / 2))) {
368
                                                angle = angle - (float) Math.PI;
369
                                        }
370

    
371
                                        theLabel.setRotation(Math.toDegrees(angle));
372
                                        theLabel.setOrig(pAux);
373
                                }
374

    
375
                                pAux = mT.transform(theLabel.getOrig(), null);
376

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

    
384
                        case FShape.POLYGON:
385

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

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

    
401
                                pAux = mT.transform(theLabel.getOrig(), null);
402

    
403
                                break;
404
                }
405

    
406
                AffineTransform ant = g2.getTransform();
407

    
408
                x = (float) pAux.getX();
409
                y = (float) pAux.getY();
410

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

    
416
                switch (theLabel.getJustification()) {
417
                        case FLabel.LEFT_BOTTOM:
418
                                g2.drawString(theLabel.getString(), 0, 0 - 3);
419

    
420
                                break;
421

    
422
                        case FLabel.LEFT_CENTER:
423
                                g2.drawString(theLabel.getString(), 0, 0 - (height / 2));
424

    
425
                                break;
426

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

    
430
                                break;
431

    
432
                        case FLabel.CENTER_BOTTOM:
433
                                g2.drawString(theLabel.getString(), 0 - (width / 2), 0 - 3);
434

    
435
                                break;
436

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

    
441
                                break;
442

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

    
447
                                break;
448

    
449
                        case FLabel.RIGHT_BOTTOM:
450
                                g2.drawString(theLabel.getString(), 0 - width, 0 - 3);
451

    
452
                                break;
453

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

    
458
                                break;
459

    
460
                        case FLabel.RIGHT_TOP:
461
                                g2.drawString(theLabel.getString(), 0 - width, 0 - height);
462

    
463
                                break;
464
                }
465

    
466
                // Restauramos
467
                g2.setTransform(ant);
468
        }
469

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

    
485
                /*if (x==0){
486
                   x=100;
487
                   }
488
                   if (y==0){
489
                           y=100;
490
                   }
491
                 */
492
                Rectangle rectAux = new Rectangle();
493

    
494
                // Aqu? hay que mirar m_Size y m_useSize...
495
                float radio_simbolo;
496
                radio_simbolo = theSymbol.getSize() / 2;
497

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

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

    
513
                //         continue; //radioSimbolo_en_pixels = 3;
514
                if (theSymbol.getFill() != null) {
515
                        g2.setPaint(theSymbol.getFill());
516
                }
517

    
518
                if (theSymbol.getStroke() != null) {
519
                        g2.setStroke(theSymbol.getStroke());
520
                }
521

    
522
                if (radio_simbolo < 2) {
523
                        g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
524

    
525
                        return;
526
                }
527

    
528
                switch (theSymbol.getStyle()) {
529
                        case FConstant.SYMBOL_STYLE_MARKER_CIRCLE: // Circulito
530

    
531
                                if (theSymbol.getColor() != null) {
532
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
533
                                                rectAux.height);
534
                                }
535

    
536
                                if (theSymbol.isOutlined()) {
537
                                        g2.setColor(theSymbol.getOutlineColor());
538
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
539
                                                rectAux.height);
540
                                }
541

    
542
                                break;
543

    
544
                        case FConstant.SYMBOL_STYLE_MARKER_SQUARE: // Cuadrado
545
                                g2.fillRect(rectAux.x, rectAux.y, rectAux.width, rectAux.height);
546

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

    
553
                                break;
554

    
555
                        case FConstant.SYMBOL_STYLE_MARKER_TRIANGLE: // Triangulo
556

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

    
566
                                g2.fill(genPath);
567

    
568
                                break;
569

    
570
                        case FConstant.SYMBOL_STYLE_MARKER_CROSS: // cruz
571
                        case FConstant.SYMBOL_STYLE_DGNSPECIAL: // Cruz
572

    
573
                                GeneralPathX genPathCruz = new GeneralPathX();
574
                                genPathCruz.moveTo(x, y - radio_simbolo);
575
                                genPathCruz.lineTo(x, y + radio_simbolo);
576
                                genPathCruz.moveTo(x - radio_simbolo, y);
577
                                genPathCruz.lineTo(x + radio_simbolo, y);
578
                                g2.draw(genPathCruz);
579

    
580
                                break;
581

    
582
                        case 34: // TrueType marker
583

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

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

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

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

    
630
                                        g2.drawString(strImg, x - (width / 2), y - 2 +
631
                                                (height / 2));
632
                                }
633

    
634
                                break;
635
                        }
636

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

    
642
                                if (theSymbol.getColor() != null) {
643
                                        g2.fillOval(rectAux.x, rectAux.y, rectAux.width,
644
                                                rectAux.height);
645
                                }
646

    
647
                                if (theSymbol.isOutlined()) {
648
                                        g2.setColor(theSymbol.getOutlineColor());
649
                                        g2.drawOval(rectAux.x, rectAux.y, rectAux.width,
650
                                                rectAux.height);
651
                                }
652

    
653
                                break;
654
                } // del switch estilo
655
        }
656
        public static void DrawHandlers(Graphics2D g, AffineTransform at,
657
                        Handler[] handlers) {
658

    
659
                        for (int i = 0; i < handlers.length; i++) {
660
                                Point2D point = handlers[i].getPoint();
661
                                at.transform(point, point);
662
                                g.setColor(Color.BLUE);
663
                                g.fillRect((int) (point.getX() - 5), (int) (point.getY() - 5), 10, 10);
664
                                g.setColor(Color.GRAY);
665
                                g.drawRect((int) (point.getX() - 5), (int) (point.getY() - 5), 10, 10);
666
                        }
667
                }
668

    
669
}