Statistics
| Revision:

root / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / rendering / Annotation_Legend.java @ 11536

History | View | Annotate | Download (20.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.rendering;
42

    
43
import java.awt.Color;
44
import java.awt.Font;
45
import java.awt.Graphics2D;
46
import java.awt.Rectangle;
47
import java.awt.Shape;
48
import java.awt.font.FontRenderContext;
49
import java.awt.font.GlyphVector;
50
import java.awt.geom.AffineTransform;
51
import java.awt.geom.Point2D;
52
import java.sql.Types;
53
import java.text.ParseException;
54
import java.util.ArrayList;
55
import java.util.Comparator;
56
import java.util.TreeMap;
57

    
58
import org.cresques.cts.ICoordTrans;
59
import org.geotools.filter.ExpressionBuilder;
60
import org.geotools.filter.Filter;
61
import org.geotools.styling.FeatureTypeStyle;
62
import org.geotools.styling.NamedLayer;
63
import org.geotools.styling.Rule;
64
import org.geotools.styling.SLDTransformer;
65
import org.geotools.styling.Style;
66
import org.geotools.styling.StyleBuilder;
67
import org.geotools.styling.StyleFactory;
68
import org.geotools.styling.StyledLayerDescriptor;
69
import org.geotools.styling.Symbolizer;
70

    
71
import com.hardcode.gdbms.engine.data.DataSource;
72
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
73
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException;
74
import com.hardcode.gdbms.engine.instruction.SemanticException;
75
import com.hardcode.gdbms.engine.values.BooleanValue;
76
import com.hardcode.gdbms.engine.values.NullValue;
77
import com.hardcode.gdbms.engine.values.NumericValue;
78
import com.hardcode.gdbms.engine.values.StringValue;
79
import com.hardcode.gdbms.engine.values.Value;
80
import com.hardcode.gdbms.engine.values.ValueFactory;
81
import com.iver.cit.gvsig.fmap.DriverException;
82
import com.iver.cit.gvsig.fmap.core.FPoint2D;
83
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
84
import com.iver.cit.gvsig.fmap.core.FShape;
85
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
86
import com.iver.cit.gvsig.fmap.core.IFeature;
87
import com.iver.cit.gvsig.fmap.core.IGeometry;
88
import com.iver.cit.gvsig.fmap.core.ISLDCompatible;
89
import com.iver.cit.gvsig.fmap.core.ISymbol;
90
import com.iver.cit.gvsig.fmap.core.SLDTags;
91
import com.iver.cit.gvsig.fmap.core.SLDUtils;
92
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
93
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
94
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
95
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
96
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
97
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer;
98
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping;
99
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
100
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
101
import com.iver.cit.gvsig.fmap.layers.XMLException;
102
import com.iver.utiles.XMLEntity;
103

    
104
/**
105
 * Leyenda vectorial para labels.
106
 *
107
 * @author Vicente Caballero Navarro
108
 */
109
public class Annotation_Legend implements VectorialLegend {
110
        private String fieldName;
111
    protected int fieldId = -1;
112
    private String labelFieldName;
113
    private String labelFieldHeight;
114
    private String labelFieldRotation;
115
    private static final FSymbol defaultSymbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT);
116
    private DataSource dataSource;
117
    private int shapeType;
118
    private String valueType = NullValue.class.getName();
119
    private boolean useDefaultSymbol = false;
120
    private Annotation_Layer layer;
121
    private Annotation_Mapping mapping;
122

    
123
  public Annotation_Legend(Annotation_Layer layer) {
124
          this.layer=layer;
125
          mapping=layer.getMapping();
126
          defaultSymbol.setFontSizeInPixels(layer.isInPixels());
127
          defaultSymbol.setFontColor(Color.black);
128
          defaultSymbol.setRotation(0);
129
          defaultSymbol.setFontSize(10);
130
    }
131

    
132
    /**
133
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
134
     *      ISymbol)
135
     */
136
    public void addSymbol(Object key, ISymbol symbol) {
137
//        Object resul;
138
//        resul = symbols.put(key, symbol);
139
//
140
//        if (resul != null) {
141
//            System.err.println("Error: la clave " + key +
142
//                " ya exist?a. Resul = " + resul);
143
//            System.err.println("symbol nuevo:" + symbol.getDescription() +
144
//                " Sviejo= " + ((ISymbol) resul).getDescription());
145
//        } else {
146
//            keys.add(key);
147
//              if (!key.getClass().equals(NullValue.class)) {
148
//                valueType = key.getClass().getName();
149
//            }
150
//        }
151
    }
152

    
153
    /**
154
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
155
     */
156
    public void clear() {
157
//        keys.clear();
158
//        symbols.clear();
159
    }
160

    
161
    /**
162
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getDescriptions()
163
     */
164
    public String[] getDescriptions() {
165
//        String[] descriptions = new String[symbols.size()];
166
//        ISymbol[] auxSym = getSymbols();
167
//
168
//        for (int i = 0; i < descriptions.length; i++)
169
//            descriptions[i] = auxSym[i].getDescription();
170
//
171
//        return descriptions;
172
            return null;
173
    }
174

    
175
    /**
176
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
177
     */
178
    public ISymbol[] getSymbols() {
179
//            return (ISymbol[]) symbols.values().toArray(new ISymbol[0]);
180
            return null;
181
    }
182

    
183
    /**
184
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getFieldName()
185
     */
186
    public String getFieldName() {
187
        return fieldName;
188
    }
189

    
190
    /**
191
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
192
     */
193
    public void setDefaultSymbol(ISymbol s) {
194
//        defaultSymbol = s;
195
    }
196

    
197
    /* (non-Javadoc)
198
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelField()
199
     */
200
    public String getLabelField() {
201
        return labelFieldName;
202
    }
203

    
204
    /**
205
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
206
     */
207
    public void setLabelField(String fieldName) {
208
        labelFieldName = fieldName;
209
    }
210

    
211
    /**
212
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setField()
213
     */
214
    public void setFieldName(String str) {
215
        fieldName = str;
216
    }
217

    
218
    /**
219
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
220
     */
221
    public ISymbol getSymbol(int recordIndex) throws DriverException {
222
        return getSymbolAnnotation(recordIndex);
223
//            try {
224
//                 Value val = dataSource.getFieldValue(recordIndex, fieldId);
225
//            ISymbol theSymbol = getSymbolByValue(val);
226
//
227
//            //if (theSymbol != null) {
228
//            return theSymbol;
229
//
230
//            //} else {
231
//            //        return getDefaultSymbol();
232
//            //}
233
//        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
234
//            throw new DriverException(e);
235
//        }
236
    }
237

    
238
    /**
239
     * Devuelve un s?mbolo a partir de una IFeature.
240
     * OJO!! Cuando usamos un feature iterator de base de datos
241
     * el ?nico campo que vendr? rellenado es el de fieldID.
242
     * Los dem?s vendr?n a nulos para ahorra tiempo de creaci?n.
243
     * @param feat IFeature
244
     *
245
     * @return S?mbolo.
246
     */
247
    public ISymbol getSymbolByFeature(IFeature feat) {
248
       return null;
249
    }
250

    
251
    /**
252
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
253
     */
254
    public ISymbol getDefaultSymbol() {
255
            return defaultSymbol;
256
    }
257
    /**
258
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getValues()
259
     */
260
    public Object[] getValues() {
261
//        return symbols.keySet().toArray(new Object[0]);
262
            return null;
263
    }
264
        /**
265
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
266
     */
267
    public XMLEntity getXMLEntity() {
268
        XMLEntity xml = new XMLEntity();
269
        xml.putProperty("className", this.getClass().getName());
270
        xml.putProperty("fieldName", fieldName);
271
        xml.putProperty("labelfield", labelFieldName);
272
        xml.putProperty("labelFieldHeight", labelFieldHeight);
273
        xml.putProperty("labelFieldRotation", labelFieldRotation);
274

    
275
        xml.putProperty("useDefaultSymbol", useDefaultSymbol);
276
//        xml.putProperty("sorter",sorter);
277
        xml.addChild(getDefaultSymbol().getXMLEntity());
278
        // xml.putProperty("isBWithHeightText", isBWithHeightText());
279
//        xml.putProperty("numKeys", keys.size());
280

    
281
//        if (keys.size() > 0) {
282
//            xml.putProperty("tipoValueKeys", valueType);
283
//
284
//            String[] sk = new String[keys.size()];
285
//            String[] sv = new String[keys.size()];
286
//            int[] stk = new int[keys.size()];
287
//            int[] stv = new int[keys.size()];
288
//            ISymbol[] fsymbols = getSymbols();
289
//            Object[] values = getValues();
290
//
291
//            for (int i = 0; i < keys.size(); i++) {
292
//                    if (((Value) keys.get(i)).toString().equals("")) {
293
//                            sk[i] =" ";
294
//                    }else {
295
//                            sk[i] = ((Value) keys.get(i)).toString();
296
//                    }
297
//                    if (((Value) values[i]).toString().equals("")) {
298
//                            sv[i] =" ";
299
//                    }else {
300
//                            sv[i] = ((Value) values[i]).toString();
301
//                    }
302
//                    stk[i]= ((Value)keys.get(i)).getSQLType();
303
//                    stv[i]= ((Value)values[i]).getSQLType();
304
//                xml.addChild(fsymbols[i].getXMLEntity());
305
//
306
//                ///System.out.println("get-----------"+sk[i]+"--"+fsymbols[i].getDescription()+"---"+fsymbols[i].getColor());
307
//            }
308
//
309
//            xml.putProperty("keys", sk);
310
//            xml.putProperty("values", sv);
311
//            xml.putProperty("typeKeys",stk);
312
//            xml.putProperty("typeValues",stv);
313
//        }
314

    
315
        return xml;
316
    }
317

    
318
    /**
319
     * Inserta el XMLEntity.
320
     *
321
     * @param xml XMLEntity.
322
     */
323
    public void setXMLEntity03(XMLEntity xml) {
324

    
325
    }
326

    
327
    /**
328
     * Inserta el XMLEntity.
329
     *
330
     * @param xml XMLEntity.
331
     */
332
    public void setXMLEntity(XMLEntity xml) {
333
        clear();
334
        setFieldName(xml.getStringProperty("fieldName"));
335
        setLabelField(xml.getStringProperty("labelfield"));
336

    
337
        if (xml.contains("labelFieldHeight")) {
338
            setLabelHeightField(xml.getStringProperty("labelFieldHeight"));
339
        }
340

    
341
        if (xml.contains("labelFieldRotation")) {
342
            setLabelRotationField(xml.getStringProperty("labelFieldRotation"));
343
        }
344

    
345
        useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol");
346

    
347
    }
348

    
349

    
350
    /**
351
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
352
     */
353
    public Legend cloneLegend() throws XMLException {
354
        return LegendFactory.createFromXML(getXMLEntity());
355
    }
356

    
357
    /* (non-Javadoc)
358
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
359
     */
360
    public void setDataSource(DataSource ds)
361
        throws FieldNotFoundException, DriverException {
362
        try {
363
            dataSource = ds;
364
            ds.start();
365
            fieldId = ds.getFieldIndexByName(fieldName);
366
            ds.stop();
367
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
368
            throw new DriverException(e);
369
        }
370
    }
371

    
372
    /* (non-Javadoc)
373
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getSymbolByValue(com.hardcode.gdbms.engine.values.Value)
374
     */
375
    public ISymbol getSymbolByValue(Value key) {
376
        return null;
377
    }
378

    
379
    /* (non-Javadoc)
380
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType()
381
     */
382
    public int getShapeType() {
383
        return shapeType;
384
    }
385

    
386
    /* (non-Javadoc)
387
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
388
     */
389
    public String getLabelHeightField() {
390
        return labelFieldHeight;
391
    }
392

    
393
    /**
394
     * Inserta el alto de campo.
395
     *
396
     * @param str alto.
397
     */
398
    public void setLabelHeightField(String str) {
399
        labelFieldHeight = str;
400
    }
401

    
402
    /* (non-Javadoc)
403
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
404
     */
405
    public String getLabelRotationField() {
406
        return labelFieldRotation;
407
    }
408

    
409
    /**
410
     * Inserta rotaci?n.
411
     *
412
     * @param str Rotaci?n.
413
     */
414
    public void setLabelRotationField(String str) {
415
        labelFieldRotation = str;
416
    }
417

    
418
    /**
419
     * Introduce si se tiene que representar el resto de valores o no.
420
     *
421
     * @param b True si se utiliza el resto de valores.
422
     */
423
    public void useDefaultSymbol(boolean b) {
424
        useDefaultSymbol = b;
425
    }
426
    /**
427
     * Devuelve si se utiliza o no el resto de valores para representarse.
428
     *
429
     * @return True si se utiliza el resto de valores.
430
     */
431
    public boolean isUseDefaultSymbol() {
432
        return useDefaultSymbol;
433
    }
434
    /**
435
     * Devuelve true si el etiquetado de la capa se ha modificado.
436
     *
437
     * @return True si se ha modificado el etiquetado de la capa.
438
     */
439
    /* public boolean isBWithHeightText() {
440
        return bWithHeightText;
441
    } */
442

    
443
    /**
444
     * Introduce si se ha modificado el etiquetado de la capa.
445
     *
446
     * @param withHeightText True si se ha modificado el etiquetado de la capa.
447
     */
448
    /* public void setBWithHeightText(boolean withHeightText) {
449
        bWithHeightText = withHeightText;
450
    } */
451

    
452
    /**
453
     * Elimina el s?mbolo que tiene como clave el valor que se pasa como par?metro.
454
     *
455
     * @param key clave.
456
     */
457
    public void delSymbol(Object key) {
458
    }
459

    
460
    /* (non-Javadoc)
461
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields()
462
     */
463
    public String[] getUsedFields() {
464
        ArrayList usedFields = new ArrayList();
465
        if (getFieldName() != null)
466
            usedFields.add(getFieldName());
467
        if (getLabelField() != null)
468
            usedFields.add(getLabelField());
469
        if (getLabelHeightField() != null)
470
            usedFields.add(getLabelHeightField());
471
        if (getLabelRotationField() != null)
472
            usedFields.add(getLabelRotationField());
473

    
474
        return (String[]) usedFields.toArray(new String[0]);
475

    
476
    }
477

    
478
        public void setShapeType(int shapeType) {
479
                // TODO Auto-generated method stub
480

    
481
        }
482

    
483
        public String getSLDString(String layerName) {
484
                // TODO Auto-generated method stub
485
                return null;
486
        }
487
        private FSymbol getSymbolAnnotation(int numReg) throws DriverException{
488
                try {
489
//                        ReadableVectorial adapter = layer.getSource();
490
//                        adapter.start();
491
                        if (layer.isJoined()){
492
                                dataSource.start();
493
                        }
494
                        // El mapping[0] es el text
495
                        int fieldId = mapping.getColumnText();
496
                        // El mapping[1] es el ?ngulo
497
                        int idFieldRotationText = mapping.getColumnRotate();
498
                        // El mapping[2] es el color
499
                        int idFieldColorText = mapping.getColumnColor();
500
                        // El mapping[3] es el alto
501
                        int idFieldHeightText = mapping.getColumnHeight();
502
                        // El mapping[4] es el tipo de fuente
503
                        int idFieldTypeFontText = mapping.getColumnTypeFont();
504
                        // El mapping[5] es el estilo de fuente
505
                        int idFieldStyleFontText = mapping.getColumnStyleFont();
506

    
507
//                        sc = (int) ds.getRowCount();
508
//                        m_labels = new ArrayList(sc);
509
//                        DriverAttributes attr = adapter.getDriverAttributes();
510
//                        boolean bMustClone = false;
511
//                        if (attr != null) {
512
//                                if (attr.isLoadedInMemory()) {
513
//                                        bMustClone = attr.isLoadedInMemory();
514
//                                }
515
//                        }
516
//                        ICoordTrans ct = layer.getCoordTrans();
517
//                                IGeometry geom = adapter.getShape(numReg);
518
//
519
//                                if (geom == null) {
520
//                                        return defaultSymbol;
521
//                                }
522
//                                if (ct != null) {
523
//                                        if (bMustClone)
524
//                                                geom = geom.cloneGeometry();
525
//                                        geom.reProject(ct);
526
//                                }
527

    
528
                                String t=new String();
529
                                Value val = dataSource.getFieldValue(numReg, fieldId);
530
                                t=val.toString();
531
                                if (idFieldColorText!=-1){
532
                                        Value valColor=dataSource.getFieldValue(numReg,idFieldColorText);
533
                                        t=t.concat(valColor.toString());
534
                                }
535
                                if (idFieldTypeFontText!=-1){
536
                                        Value valTypeFont=dataSource.getFieldValue(numReg,idFieldTypeFontText);
537
                                        t=t.concat(valTypeFont.toString());
538
                                }
539

    
540
                                if (idFieldStyleFontText!=-1){
541
                                        Value valStyleFont=dataSource.getFieldValue(numReg,idFieldStyleFontText);
542
                                        t=t.concat(valStyleFont.toString());
543
                                }
544
                                if ((val instanceof NullValue) || (val == null)) {
545
                                        return defaultSymbol;
546
                                }
547
//                                FLabel[] lbls = geom.createLabels(0, true);
548
//                                for (int j = 0; j < lbls.length; j++) {
549
//                                        if (lbls[j] != null) {
550
                                                defaultSymbol.setDescription(val.toString());
551
                                                //lbls[j].setString(val.toString());
552
                                                if (idFieldRotationText != -1) {
553
                                                        NumericValue rotation = (NumericValue) dataSource
554
                                                                        .getFieldValue(numReg, idFieldRotationText);
555
                                                        defaultSymbol.setRotation(rotation.intValue());
556
                                                }
557
                                                float height;
558
                                                if (idFieldHeightText != -1) {
559
                                                        NumericValue h = (NumericValue) dataSource
560
                                                                        .getFieldValue(numReg, idFieldHeightText);
561
                                                        height=h.floatValue();
562
                                                        defaultSymbol.setFontSize(height);
563
                                                }else {
564
                                                        height=defaultSymbol.getFontSize();
565
                                                }
566
                                                Color color;
567
                                                if (idFieldColorText != -1) {
568
                                                        NumericValue c = (NumericValue) dataSource.getFieldValue(
569
                                                                        numReg, idFieldColorText);
570
                                                        color=new Color(c.intValue());
571
                                                } else {
572
                                                        color=defaultSymbol.getFontColor();
573
                                                }
574
                                                String typeFont="";
575
                                                if (idFieldTypeFontText != -1) {
576
                                                        StringValue tf = (StringValue) dataSource
577
                                                                        .getFieldValue(numReg, idFieldTypeFontText);
578
                                                        typeFont=tf.getValue();
579
                                                } else {
580
                                                        typeFont=defaultSymbol.getFont().getFontName();
581
                                                }
582
                                                int style;
583
                                                if (idFieldStyleFontText != -1) {
584
                                                        NumericValue sf = (NumericValue) dataSource
585
                                                                        .getFieldValue(numReg, idFieldStyleFontText);
586
                                                        style=sf.intValue();
587
                                                } else {
588
                                                        style=defaultSymbol.getFont().getStyle();
589
                                                }
590
                                                defaultSymbol.setFont(new Font(typeFont,style,(int)height));
591
                                                defaultSymbol.setDescription(val.toString());
592
                                                defaultSymbol.setFontColor(color);
593
//                                        }
594

    
595
//                                }
596
                                if (layer.isJoined()){
597
                                        dataSource.stop();
598
                                }
599
//                                adapter.stop();
600
                                return defaultSymbol;
601

    
602

    
603
                } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
604
                        e.printStackTrace();
605
                        throw new DriverException(e);
606
                }
607
        }
608
        public IGeometry getTextWrappingGeometry(float height, String description,
609
                        double rotation, int numReg) throws DriverIOException {
610
                ReadableVectorial adapter = layer.getSource();
611
                // adapter.start();
612
                ICoordTrans ct = layer.getCoordTrans();
613
                IGeometry geom = adapter.getShape(numReg);
614
                boolean bMustClone = false;
615
                if (geom == null) {
616
                        return null;
617
                }
618
                if (ct != null) {
619
                        if (bMustClone)
620
                                geom = geom.cloneGeometry();
621
                        geom.reProject(ct);
622
                }
623
                // FLabel[] lbls = geom.createLabels(0, true);
624
                FPoint2D p = ((FPoint2D) geom.getInternalShape());
625
                // assuming FShape is a point with the starting position of the text
626
                // Font font = symbol.getFont();
627
                double h = height;
628
                if (layer.isInPixels())
629
                        h=layer.getMapContext().getViewPort().toMapDistance(
630
                                        (int) (height));
631
//                else
632
//                        h=h*FConstant.FONT_HEIGHT_SCALE_FACTOR;
633

    
634
                Font font = new Font("Arial", 0,
635
                                (int) (h* FConstant.FONT_HEIGHT_SCALE_FACTOR));
636
                FontRenderContext frc = new FontRenderContext(new AffineTransform(),
637
                                false, true);// g.getFontRenderContext();
638
                GlyphVector gv = font.createGlyphVector(frc, description);
639

    
640
                /* p.transform(affineTransform); */
641
                Shape shape = gv.getOutline((float) p.getX(), (float) (p.getY() + h));
642

    
643
                IGeometry geomResult = ShapeFactory.createPolygon2D(new GeneralPathX(
644
                                shape.getBounds2D()));
645
//                IGeometry geomResult2 = ShapeFactory.createPolygon2D(new GeneralPathX(
646
//                                shape.getBounds2D()));
647
//                geomResult2.transform(layer.getMapContext().getViewPort().getAffineTransform());
648
//                Rectangle r = geomResult2.getBounds();
649
                if (rotation != 0) {
650
                        geomResult.transform(AffineTransform.getRotateInstance(rotation, p
651
                                        .getX(), p.getY()));
652
                }
653
                //                  adapter.stop();
654
//                geomResult.transform(layer.getMapContext().getViewPort().getAffineTransform());
655
                return geomResult;
656
        }
657
        public void setInPixels(boolean b) {
658
                defaultSymbol.setFontSizeInPixels(b);
659

    
660
        }
661
}