Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameGraphics.java @ 24759

History | View | Annotate | Download (23 KB)

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

    
47
import java.awt.Color;
48
import java.awt.Graphics2D;
49
import java.awt.geom.AffineTransform;
50
import java.awt.geom.Point2D;
51
import java.awt.geom.Rectangle2D;
52
import java.awt.image.BufferedImage;
53
import java.util.BitSet;
54

    
55
import javax.print.attribute.PrintRequestAttributeSet;
56

    
57
import org.gvsig.fmap.dal.exception.ReadException;
58
import org.gvsig.fmap.geom.Geometry;
59
import org.gvsig.fmap.mapcontext.rendering.symbols.IMarkerSymbol;
60
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
61
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleFillSymbol;
62
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
63

    
64
import com.iver.andami.PluginServices;
65
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
66
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog;
67
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
68
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.CircleAdapter;
69
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.GeometryAdapter;
70
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.PointAdapter;
71
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.PolyLineAdapter;
72
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.PolygonAdapter;
73
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.RectangleAdapter;
74
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
75
import com.iver.utiles.XMLEntity;
76

    
77

    
78
/**
79
 * FFrame para contener un gr?fico.
80
 *
81
 * @author Vicente Caballero Navarro
82
 */
83
public class FFrameGraphics extends FFrame implements IFFrameEditableVertex {
84
    private static double TOL = 0.2;
85
    public static final int POINT = 21;
86
    public static final int LINE = 22;
87
    public static final int POLYLINE = 23;
88
    public static final int RECTANGLE = 24;
89
    public static final int CIRCLE = 25;
90
    public static final int POLYGON = 26;
91
    public static final int RECTANGLEGROUP = 16;
92
    public static final int RECTANGLESYMBOL = 17;
93
    private int m_type = POINT;
94
    private ISymbol m_symbol = null;
95
    private Color m_color = null;
96
    private GeometryAdapter geometry;
97
    private GeometryAdapter geometryEdit;
98
    private boolean editing = false;
99
    private double size = 0.5;
100
    private BitSet index = new BitSet();
101

    
102
    /**
103
     * Crea un nuevo FFrameGraphics.
104
     */
105
    public FFrameGraphics() {
106
    }
107

    
108
    /**
109
     * DOCUMENT ME!
110
     *
111
     * @param geom DOCUMENT ME!
112
     */
113
    public void setGeometryAdapter(GeometryAdapter geom) {
114
        geometry = geom;
115
    }
116

    
117
    /**
118
     * Rellena el color que se utlizar? para dibujar el s?mbolo.
119
     *
120
     * @param color
121
     */
122
    public void setColor(Color color) {
123
        m_color = color;
124
    }
125

    
126
    /**
127
     * Actualiza el Fsymbol a partir del tipo de Gr?fico que se pase como
128
     * par?metro.
129
     *
130
     * @param type tipo de gr?fico.
131
     * @param at Transformada.
132
     */
133
    public void update(int type, AffineTransform at) {
134
        m_type = type;
135

    
136
        //aT = at;
137
        if (m_color == null) {
138
            m_color = Color.black;
139
        }
140
        int shapeType = -1;
141
        /*
142
         * (jaume) moved to ISymbol
143
         * switch (m_type) {
144
            case (POINT):
145

146
                    FSymbol symbolPoint= new FSymbol(FConstant.SHAPE_TYPE_POINT, m_color);
147
                       symbolPoint.setSize((int) FLayoutUtilities.fromSheetDistance(
148
                        size, at));
149
                       m_symbol=symbolPoint;
150
                break;
151

152
            case (RECTANGLE):
153
                    FSymbol symbolRectangle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
154
                symbolRectangle.setColor(null);
155
                m_symbol=symbolRectangle;
156
                break;
157

158
            case (LINE):
159
                    FSymbol symbolLine= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
160
                    m_symbol=symbolLine;
161
                break;
162

163
            case (POLYLINE):
164
                    FSymbol symbolPolyline= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
165
                    m_symbol=symbolPolyline;
166
                break;
167

168
            case (POLYGON):
169
                    FSymbol symbolPolygon= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
170
                symbolPolygon.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
171
                symbolPolygon.setOutlined(true);
172
                symbolPolygon.setOutlineColor(m_color);
173
                symbolPolygon.setColor(null);
174
                m_symbol=symbolPolygon;
175
                break;
176

177
            case (CIRCLE):
178
                    FSymbol symbolCircle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
179
                symbolCircle.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
180
                symbolCircle.setOutlined(true);
181
                symbolCircle.setOutlineColor(m_color);
182
                symbolCircle.setColor(null);
183
                m_symbol=symbolCircle;
184
                break;
185
        }
186
        */
187
        switch (m_type) {
188
        case (POINT):
189
                shapeType = Geometry.TYPES.POINT;
190
            break;
191

    
192
        case (RECTANGLE):
193
        case (POLYGON):
194
        case (CIRCLE):
195
                shapeType = Geometry.TYPES.SURFACE;
196
            break;
197

    
198
        case (LINE):
199
        case (POLYLINE):
200
                shapeType = Geometry.TYPES.CURVE;
201
            break;
202
        }
203

    
204
        m_symbol = SymbologyFactory.createDefaultSymbolByShapeType(shapeType);
205
        if (shapeType==Geometry.TYPES.SURFACE){
206
                ((SimpleFillSymbol)m_symbol).setFillColor(null);
207
        }
208
    }
209

    
210
    /**
211
     * Devuelve el FSymbol que se representa.
212
     *
213
     * @return DOCUMENT ME!
214
     */
215
    public ISymbol getFSymbol() {
216
        return m_symbol;
217
    }
218

    
219
    /**
220
     * Rellena el FSymbol que se representara al dibujar.
221
     *
222
     * @param fs2d
223
     */
224
    public void setSymbol(ISymbol symbol) {
225
        m_symbol = symbol;
226
    }
227

    
228
    /**
229
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
230
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
231
     * de dibujar.
232
     *
233
     * @param g Graphics
234
     * @param at Transformada afin.
235
     * @param rv rect?ngulo sobre el que hacer un clip.
236
     * @param imgBase DOCUMENT ME!
237
     */
238
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
239
        BufferedImage imgBase) throws ReadException {
240
        Rectangle2D.Double rect = getBoundingBox(at);
241
        g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2),
242
            rect.y + (rect.height / 2));
243
        if (intersects(rv, rect)) {
244
            g.setColor(Color.black);
245

    
246
            if (m_type == POINT) {
247
                ((IMarkerSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7));
248
            }
249
//            float stroke=0;
250
//            if (((FSymbol)m_symbol).getStroke() != null) {
251
//                    stroke=((BasicStroke)((FSymbol)m_symbol).getStroke()).getLineWidth();
252
//                BasicStroke basicStroke = new BasicStroke((float)FLayoutUtilities.fromSheetDistance(stroke,at)/100);
253
//                ((FSymbol)m_symbol).setStroke(basicStroke);
254
//            }
255
            geometry.draw(g, at, m_symbol);
256

    
257
//            if (((FSymbol)m_symbol).getStroke() != null) {
258
//                BasicStroke basicStroke = new BasicStroke(stroke);
259
//                ((FSymbol)m_symbol).setStroke(basicStroke);
260
//            }
261

    
262
            if (editing) {
263
                g.setColor(Color.red);
264
                geometry.drawVertex(g, at);
265
            }
266
        }
267

    
268
        g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2),
269
            rect.y + (rect.height / 2));
270
    }
271

    
272
    /**
273
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
274
     */
275
    public XMLEntity getXMLEntity() throws SaveException {
276
        XMLEntity xml = super.getXMLEntity();
277

    
278
        try {
279
//            xml.putProperty("type", Layout.GRAPHICS);
280
            xml.putProperty("m_type", m_type);
281
            xml.addChild(m_symbol.getXMLEntity());
282
            if (geometry!=null) {
283
                xml.addChild(geometry.getXMLEntity());
284
            }
285
           // xml.addChild(geometryEdit.getXMLEntity());
286
        } catch (Exception e) {
287
            throw new SaveException(e, this.getClass().getName());
288
        }
289

    
290
        return xml;
291
    }
292

    
293
    /**
294
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#updateNum()
295
     */
296
    public void updateNum() {
297
    }
298

    
299
    /**
300
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNum()
301
     */
302
    public int getNum() {
303
        return 0;
304
    }
305

    
306
    /**
307
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
308
     *      com.iver.cit.gvsig.project.Project)
309
     */
310
    public void setXMLEntity(XMLEntity xml) {
311
        m_Selected = xml.getIntProperty("m_Selected");
312

    
313
        setRotation(xml.getDoubleProperty("m_rotation"));
314
        // jaume; m_symbol = FSymbol.createFromXML(xml.getChild(0));
315
        m_symbol = SymbologyFactory.createSymbolFromXML(xml.getChild(0), null);
316
        if (xml.contains("m_type")) {
317
            m_type = xml.getIntProperty("m_type");
318
           // return;
319
        }
320
        if (m_type==RECTANGLESYMBOL) {
321
                        return;
322
                }
323
        if (xml.getChildrenCount() ==1) {
324
            Rectangle2D r = (Rectangle2D) getBoundBox().clone();
325

    
326
            if (m_type == LINE) {
327
                geometry = new PolyLineAdapter();
328
            } else if (m_type == RECTANGLE ||
329
                    m_type == RECTANGLEGROUP) {
330
                geometry = new RectangleAdapter();
331
                geometry.addPoint(new Point2D.Double(r.getX(), r.getY()));
332
                geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY()));
333
            } else if (m_type == POLYLINE) {
334
                geometry = new PolyLineAdapter();
335
            } else if (m_type == POLYGON) {
336
                geometry = new PolygonAdapter();
337
            } else if (m_type == CIRCLE) {
338
                geometry = new CircleAdapter();
339
                geometry.addPoint(new Point2D.Double(r.getCenterX(),
340
                        r.getCenterY()));
341

    
342
                if (r.getWidth() < r.getHeight()) {
343
                    geometry.addPoint(new Point2D.Double(r.getMaxX(),
344
                            r.getCenterY()));
345
                } else {
346
                    geometry.addPoint(new Point2D.Double(r.getCenterX(),
347
                            r.getY()));
348
                }
349
            } else if (m_type == POINT) {
350
                geometry = new PointAdapter();
351
                geometry.addPoint(new Point2D.Double(r.getCenterX(),
352
                        r.getCenterY()));
353
            }
354

    
355
            geometry.end();
356
        } else {
357
            geometry = GeometryAdapter.createFromXML(xml.getChild(1));
358
           // geometryEdit = GeometryAdapter.createFromXML(xml.getChild(2));
359
        }
360
    }
361

    
362
    /**
363
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
364
     *      com.iver.cit.gvsig.project.Project)
365
     */
366
    public void setXMLEntity03(XMLEntity xml, Layout p) {
367
        m_Selected = xml.getIntProperty("m_Selected");
368
        m_type = xml.getIntProperty("m_type");
369
        // jaume; m_symbol = FSymbol.createFromXML(xml.getChild(0));
370
        m_symbol = SymbologyFactory.createSymbolFromXML(xml.getChild(0), null);
371

    
372
        Rectangle2D r = (Rectangle2D) getBoundBox().clone();
373

    
374
        if (m_type == LINE) {
375
            geometry = new PolyLineAdapter();
376
        } else if (m_type == RECTANGLE) {
377
            geometry = new RectangleAdapter();
378
            geometry.addPoint(new Point2D.Double(r.getX(), r.getY()));
379
            geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY()));
380
        } else if (m_type == POLYLINE) {
381
            geometry = new PolyLineAdapter();
382
        } else if (m_type == POLYGON) {
383
            geometry = new PolygonAdapter();
384
        } else if (m_type == CIRCLE) {
385
            geometry = new CircleAdapter();
386
            geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY()));
387

    
388
            if (r.getWidth() < r.getHeight()) {
389
                geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getCenterY()));
390
            } else {
391
                geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getY()));
392
            }
393
        } else if (m_type == POINT) {
394
            geometry = new PointAdapter();
395
            geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY()));
396
        }
397

    
398
        geometry.end();
399
    }
400

    
401
    /**
402
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
403
     */
404
    public String getNameFFrame() {
405
        return PluginServices.getText(this, "Graficos")+ num;
406
    }
407

    
408
    /**
409
     * Inserta el tama?o del punto.
410
     *
411
     * @param size entero que representa el tama?o del punto.
412
     */
413
    public void setSize(double size) {
414
        this.size = size;
415
        if (m_type==RECTANGLESYMBOL) {
416
            return;
417
        }
418
        Rectangle2D r = geometry.getBounds2D();
419
        super.setBoundBox(new Rectangle2D.Double(r.getX() - size,
420
                r.getY() - size, size * 2, size * 2));
421
    }
422

    
423
    /**
424
     * Devuelve el tipo de gr?fico que contiene el fframe.
425
     *
426
     * @return tipo de
427
     */
428
    public int getType() {
429
        return m_type;
430
    }
431
    public int getShapeType(){
432
            int shapeType=0;
433
            switch (m_type) {
434
        case (POINT):
435
                shapeType = Geometry.TYPES.POINT;
436
            break;
437

    
438
        case (RECTANGLE):
439
        case (POLYGON):
440
        case (CIRCLE):
441
                shapeType = Geometry.TYPES.SURFACE;
442
            break;
443

    
444
        case (LINE):
445
        case (POLYLINE):
446
                shapeType = Geometry.TYPES.CURVE;
447
            break;
448
        }
449
            return shapeType;
450
    }
451
    public void setType(int type) {
452
        m_type = type;
453
    }
454
    /**
455
     * DOCUMENT ME!
456
     *
457
     * @param r DOCUMENT ME!
458
     */
459
    public void setBoundBox(Rectangle2D r) {
460
        if (m_type==RECTANGLESYMBOL) {
461
            super.setBoundBox(r);
462
            return;
463
        }
464
        AffineTransform aT = new AffineTransform();
465

    
466
        if (getBoundBox().getWidth() != 0) {
467
            double w = r.getWidth() / getBoundBox().getWidth();
468
            double h = r.getHeight() / getBoundBox().getHeight();
469

    
470
            AffineTransform trans2 = AffineTransform.getTranslateInstance(r.getX(),
471
                    r.getY());
472
            aT.concatenate(trans2);
473

    
474
            AffineTransform scale1 = AffineTransform.getScaleInstance(w, h);
475
            aT.concatenate(scale1);
476

    
477
            AffineTransform trans1 = AffineTransform.getTranslateInstance(-getBoundBox()
478
                                                                               .getX(),
479
                    -getBoundBox().getY());
480
            aT.concatenate(trans1);
481
            geometry.applyTransform(aT);
482

    
483
            size = aT.getScaleX() * size;
484
        }
485

    
486
        super.setBoundBox(r);
487
    }
488

    
489
    /**
490
     * DOCUMENT ME!
491
     */
492
    public void startEditing() {
493
        editing = true;
494
    }
495

    
496
    /**
497
     * DOCUMENT ME!
498
     */
499
    public void stopEditing() {
500
        editing = false;
501
    }
502

    
503
    /**
504
     * DOCUMENT ME!
505
     *
506
     * @return DOCUMENT ME!
507
     */
508
    public boolean isEditing() {
509
        return editing;
510
    }
511

    
512
    /**
513
     * DOCUMENT ME!
514
     *
515
     * @param point DOCUMENT ME!
516
     * @param geom DOCUMENT ME!
517
     */
518
    public void pointReleased(Point2D point, GeometryAdapter geom) {
519
        index.clear();
520
        geometry = geom;
521

    
522
        Rectangle2D r = geometry.getBounds2D();
523
        super.setBoundBox(r);
524
    }
525

    
526
    /**
527
     * DOCUMENT ME!
528
     *
529
     * @param point DOCUMENT ME!
530
     */
531
    public void pointPressed(Point2D point) {
532
        Rectangle2D.Double rect = getBoundBox();
533
        Point2D[] points = geometry.getPoints();
534
        geometryEdit = geometry.cloneAdapter();//GeometryAdapter.createFromXML(geometry.getXMLEntity());
535

    
536
        Point2D pAux1 = new Point2D.Double();
537
        index.clear();
538
        for (int i = 0; i < points.length; i++) {
539
            if (getRotation() != 0) {
540
                AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians(
541
                            -getRotation()), rect.x + (rect.width / 2),
542
                        rect.y + (rect.height / 2));
543
                af.transform(point, pAux1);
544

    
545
                if (points[i].distance(pAux1) <= TOL) {
546
                    index.set(i);
547
                }
548
            } else {
549
                if (points[i].distance(point) <= TOL) {
550
                    index.set(i);
551
                }
552
            }
553
        }
554
    }
555

    
556
    /**
557
     * DOCUMENT ME!
558
     *
559
     * @param point DOCUMENT ME!
560
     */
561
    public void pointDragged(Point2D point) {
562
        //Point2D[] points = geometry.getPoints();
563

    
564
        for (int j = index.nextSetBit(0); j >= 0;
565
                j = index.nextSetBit(j + 1)) {
566
            if (getRotation() != 0) {
567
                Rectangle2D.Double rect = getBoundBox();
568
                AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians(
569
                            -getRotation()), rect.x + (rect.width / 2),
570
                        rect.y + (rect.height / 2));
571
                af.transform(point, point);
572
            }
573

    
574
            //points[j] = new Point2D.Double(point.getX(), point.getY());
575
            geometryEdit.changePoint(j,point);
576
        }
577
        //geometryEdit.setPoints(points);
578
        geometryEdit.end();
579
    }
580

    
581
    /**
582
     * DOCUMENT ME!
583
     *
584
     * @param g DOCUMENT ME!
585
     * @param at DOCUMENT ME!
586
     */
587
    public void paint(Graphics2D g, AffineTransform at) {
588
        if (geometryEdit != null) {
589
            Rectangle2D.Double rect = getBoundingBox(at);
590
            if (getRotation()!=0){
591
            g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2),
592
                rect.y + (rect.height / 2));
593
            geometryEdit.paint(g,at,false);
594
          /*  FShape m_shape = null;
595
            GeneralPathX polyLine = new GeneralPathX(geometryEdit.getShape());
596
            polyLine.transform(at);
597
            m_shape = new FPolyline2D(polyLine);
598
            FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
599
*/
600
            g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2),
601
                rect.y + (rect.height / 2));
602
            }else{
603
                 geometryEdit.paint(g,at,false);
604
            }
605
        }
606
    }
607

    
608
    /**
609
     * DOCUMENT ME!
610
     *
611
     * @return DOCUMENT ME!
612
     */
613
    public GeometryAdapter getGeometry() {
614
        return geometryEdit;
615
    }
616

    
617
    public void initialize() {
618
        // TODO Auto-generated method stub
619

    
620
    }
621
     /**
622
     * Devuelve un entero que representa donde esta contenido el punto que se
623
     * pasa como par?metro.
624
     *
625
     * @param p punto a comparar.
626
     *
627
     * @return entero que representa como esta contenido el punto.
628
     */
629
    public int getContains(Point2D p) {
630
        if (geometry instanceof CircleAdapter) {
631
            if (ne.contains(p.getX(), p.getY())) {
632
                return NE;
633
            } else if (se.contains(p.getX(), p.getY())) {
634
                return SE;
635
            } else if (so.contains(p.getX(), p.getY())) {
636
                return SO;
637
            } else if (no.contains(p.getX(), p.getY())) {
638
                return NO;
639
            } else if (getBoundingBox(null).contains(p.getX(), p.getY())) {
640
                return RECT;
641
            }
642
            return NOSELECT;
643
        }
644
            return super.getContains(p);
645
    }
646

    
647
    /**
648
     * Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
649
     * par?metro.
650
     *
651
     * @param g
652
     *            Graphics sobre el que dibujar.
653
     */
654
    public void drawHandlers(Graphics2D g) {
655
        if (geometry instanceof CircleAdapter) {
656
            int size = 10;
657
            Rectangle2D r = getBoundingBox(null);
658
            Point2D p = new Point2D.Double();
659
            g.rotate(Math.toRadians(getRotation()), r.getX()
660
                    + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2));
661

    
662
            AffineTransform atRotate = new AffineTransform();
663
            atRotate.rotate(Math.toRadians(getRotation()), r.getX()
664
                    + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2));
665

    
666
            g.fillRect((int) r.getX() - size, (int) r.getY() - size,
667
                            size, size);
668
            atRotate.transform(new Point2D.Double(r.getX() - size, r.getY()
669
                    - size), p);
670
            no.setRect((int) p.getX(), (int) p.getY(), size, size);
671

    
672
            g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size);
673
            atRotate.transform(
674
                    new Point2D.Double(r.getMaxX(), r.getY() - size), p);
675
            ne.setRect((int) p.getX(), (int) p.getY(), size, size);
676

    
677
            g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size);
678
            atRotate.transform(
679
                    new Point2D.Double(r.getX() - size, r.getMaxY()), p);
680
            so.setRect((int) p.getX(), (int) p.getY(), size, size);
681

    
682
            g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size);
683
            atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()), p);
684
            se.setRect((int) p.getX(), (int) p.getY(), size, size);
685

    
686
            g.rotate(Math.toRadians(-getRotation()), r.getX()
687
                    + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2));
688
        } else {
689
                        super.drawHandlers(g);
690
                }
691
    }
692

    
693
        public void cloneActions(IFFrame frame) {
694
                // TODO Auto-generated method stub
695

    
696
        }
697

    
698
        public IFFrameDialog getPropertyDialog() {
699
                return new FFrameGraphicsDialog(getLayout(),this);
700
        }
701

    
702
        public void print(Graphics2D g, AffineTransform at, Geometry geom, PrintRequestAttributeSet printingProperties) throws ReadException {
703
                Rectangle2D.Double rect = getBoundingBox(at);
704
                g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2),
705
                                rect.y + (rect.height / 2));
706
                g.setColor(Color.black);
707

    
708
//                if (m_type == POINT) {
709
//                        ((IMarkerSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7));
710
//                }
711
                geometry.print(g, at, m_symbol,printingProperties);
712

    
713

    
714
                if (editing) {
715
                        g.setColor(Color.red);
716
                        geometry.drawVertex(g, at);
717
                }
718

    
719
                g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2),
720
                                rect.y + (rect.height / 2));
721
        }
722

    
723

    
724
}