Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / FFrame.java @ 36648

History | View | Annotate | Download (24.7 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes;
23

    
24
import java.awt.BasicStroke;
25
import java.awt.Color;
26
import java.awt.Font;
27
import java.awt.Graphics2D;
28
import java.awt.Image;
29
import java.awt.Rectangle;
30
import java.awt.event.MouseEvent;
31
import java.awt.geom.AffineTransform;
32
import java.awt.geom.Point2D;
33
import java.awt.geom.Rectangle2D;
34
import java.awt.image.BufferedImage;
35

    
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

    
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.app.project.ProjectManager;
41
import org.gvsig.app.project.documents.layout.Attributes;
42
import org.gvsig.app.project.documents.layout.DefaultLayoutManager;
43
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
44
import org.gvsig.app.project.documents.layout.LayoutContext;
45
import org.gvsig.app.project.documents.layout.LayoutControl;
46
import org.gvsig.app.project.documents.layout.LayoutManager;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.dynobject.DynStruct;
49
import org.gvsig.tools.persistence.PersistenceManager;
50
import org.gvsig.tools.persistence.PersistentState;
51
import org.gvsig.tools.persistence.exception.PersistenceException;
52

    
53
/**
54
 * Clase que implementa la interface IFFrame con los m�todos por defecto de
55
 * todos los FFrames que extenderan de este, dejando uno como m�todo
56
 * abstracto para implementar por todos los FFrames para ser dibujados.
57
 * 
58
 * @author Vicente Caballero Navarro
59
 */
60
public abstract class FFrame implements IFFrame {
61

    
62
    public static final String PERSISTENCE_DEFINITION_NAME = "FFrame";
63

    
64
    private static final String BOUNDINGBOX_FIELD = "boundingBox";
65
    private static final String SELECTED_FIELD = "selected";
66
    private static final String TAG_FIELD = "tag";
67
    private static final String ROTATION_FIELD = "rotation";
68
    private static final String LEVEL_FIELD = "level";
69
    private static final String NUM_FIELD = "num";
70

    
71
    protected static final Logger LOG = LoggerFactory.getLogger(FFrame.class);
72

    
73
    protected Rectangle2D.Double m_BoundBox = new Rectangle2D.Double();
74
    private Rectangle2D.Double m_BoundingBox = new Rectangle2D.Double();
75
    protected int m_Selected = 0;
76
    protected Rectangle n = new Rectangle();
77
    protected Rectangle ne = new Rectangle();
78
    protected Rectangle e = new Rectangle();
79
    protected Rectangle se = new Rectangle();
80
    protected Rectangle s = new Rectangle();
81
    protected Rectangle so = new Rectangle();
82
    protected Rectangle o = new Rectangle();
83
    protected Rectangle no = new Rectangle();
84
    private String tag = null;
85
    protected int num = 0;
86
    private double m_rotation = 0;
87
    private int level = -1;
88
    private Rectangle2D lastMoveRect;
89
    protected FrameFactory frameFactory;
90

    
91
    private static Image iNEResize = null;
92
    private static Image iEResize = null;
93
    private static Image iNResize = null;
94
    private static Image iMove = null;
95
    private static Image iSEResize = null;
96

    
97
    protected LayoutManager layoutManager = null;
98
    protected LayoutContext layoutContext = null;
99
    protected LayoutControl layoutControl = null;
100

    
101
    public FFrame() {
102
        super();
103
        layoutManager =
104
            (LayoutManager) ProjectManager.getInstance().getDocumentManager(
105
                DefaultLayoutManager.TYPENAME);
106
    }
107

    
108
    /**
109
     * Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
110
     * par�metro.
111
     * 
112
     * @param g
113
     *            Graphics sobre el que dibujar.
114
     */
115
    public void drawHandlers(Graphics2D g) {
116
        int size = 10;
117
        Rectangle2D r = getBoundingBox(null);
118
        Point2D p = new Point2D.Double();
119
        g.rotate(Math.toRadians(getRotation()), r.getX() + (r.getWidth() / 2),
120
            r.getY() + (r.getHeight() / 2));
121

    
122
        AffineTransform atRotate = new AffineTransform();
123
        atRotate.rotate(Math.toRadians(getRotation()), r.getX()
124
            + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2));
125

    
126
        g.fillRect((int) r.getX() - size, (int) r.getY() - size, size, size);
127
        atRotate.transform(
128
            new Point2D.Double(r.getX() - size, r.getY() - size), p);
129
        no.setRect((int) p.getX(), (int) p.getY(), size, size);
130

    
131
        g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size);
132
        atRotate.transform(new Point2D.Double(r.getMaxX(), r.getY() - size), p);
133
        ne.setRect((int) p.getX(), (int) p.getY(), size, size);
134

    
135
        g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size);
136
        atRotate.transform(new Point2D.Double(r.getX() - size, r.getMaxY()), p);
137
        so.setRect((int) p.getX(), (int) p.getY(), size, size);
138

    
139
        g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size);
140
        atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()), p);
141
        se.setRect((int) p.getX(), (int) p.getY(), size, size);
142

    
143
        g.fillRect((int) r.getCenterX() - (size / 2), (int) r.getY() - size,
144
            size, size);
145
        atRotate
146
            .transform(new Point2D.Double(r.getCenterX() - (size / 2), r.getY()
147
                - size), p);
148
        n.setRect((int) p.getX(), (int) p.getY(), size, size);
149

    
150
        g.fillRect((int) r.getCenterX() - (size / 2), (int) r.getMaxY(), size,
151
            size);
152
        atRotate.transform(
153
            new Point2D.Double(r.getCenterX() - (size / 2), r.getMaxY()), p);
154
        s.setRect((int) p.getX(), (int) p.getY(), size, size);
155

    
156
        g.fillRect((int) r.getX() - size, (int) r.getCenterY() - (size / 2),
157
            size, size);
158
        atRotate.transform(new Point2D.Double(r.getX() - size, r.getCenterY()
159
            - (size / 2)), p);
160
        o.setRect((int) p.getX(), (int) p.getY(), size, size);
161

    
162
        g.fillRect((int) r.getMaxX(), (int) r.getCenterY() - (size / 2), size,
163
            size);
164
        atRotate.transform(new Point2D.Double(r.getMaxX(), r.getCenterY()
165
            - (size / 2)), p);
166
        e.setRect((int) p.getX(), (int) p.getY(), size, size);
167
        g.rotate(Math.toRadians(-getRotation()), r.getX() + (r.getWidth() / 2),
168
            r.getY() + (r.getHeight() / 2));
169
    }
170

    
171
    /**
172
     * Establece que tipo de selecci�n se realiza sobre el fframe.
173
     * 
174
     * @param p
175
     *            punto sobre el que se debe de establecer si se selecciona o no
176
     *            el fframe.
177
     */
178
    public void setSelected(Point2D p, MouseEvent e) {
179
        m_Selected = getContains(p);
180
    }
181

    
182
    /**
183
     * Actualiza el BoundBox del FFrame a partir de su rect�ngulo en pixels y
184
     * la matriz de transformaci�n.
185
     * 
186
     * @param r
187
     *            Rect�ngulo.
188
     * @param at
189
     *            Matriz de transformaci�n.
190
     */
191
    public void updateRect(Rectangle2D r, AffineTransform at) {
192
        Rectangle2D.Double rec = FLayoutUtilities.toSheetRect(r, at);
193
        rec.setRect((int) rec.getMinX(), (int) rec.getMinY(),
194
            (int) rec.getWidth(), (int) rec.getHeight());
195
        setBoundBox(rec);
196
    }
197

    
198
    /**
199
     * Devuelve el rect�ngulo a partir del desplazamiento en el eje x y el
200
     * desplazamiento en el eje y.
201
     * 
202
     * @param difx
203
     *            desplazamiento sobre el eje x.
204
     * @param dify
205
     *            desplazamiento sobre el eje y.
206
     * 
207
     * @return rect�ngulo modificado en funci�n del desplazamiento
208
     *         realizado.
209
     */
210
    public Rectangle2D getMovieRect(int difx, int dify) {
211
        double x = 0;
212
        double y = 0;
213
        double w = 0;
214
        double h = 0;
215

    
216
        lastMoveRect =
217
            new Rectangle2D.Double(this.getBoundingBox(null).x,
218
                this.getBoundingBox(null).y, this.getBoundingBox(null).width,
219
                this.getBoundingBox(null).height);
220
        Rectangle2D.Double rec = this.getBoundingBox(null);
221
        int difn = 0;
222
        difn = difx;
223
        x = lastMoveRect.getX();
224
        y = lastMoveRect.getY();
225
        w = lastMoveRect.getWidth();
226
        h = lastMoveRect.getHeight();
227

    
228
        switch (this.getSelected()) {
229
        case (RECT):
230
            lastMoveRect.setRect((x + difx), (y + dify), w, h);
231

    
232
            break;
233

    
234
        case (N):
235

    
236
            if ((y + dify) > rec.getMaxY()) {
237
                y = rec.getMaxY();
238
            } else {
239
                y = y + dify;
240
            }
241

    
242
            lastMoveRect.setRect(x, y, w, Math.abs(h - dify));
243

    
244
            break;
245

    
246
        case (O):
247

    
248
            if ((x + difx) > rec.getMaxX()) {
249
                x = rec.getMaxX();
250
            } else {
251
                x = x + difx;
252
            }
253

    
254
            lastMoveRect.setRect(x, y, Math.abs(w - difx), h);
255

    
256
            break;
257

    
258
        case (S):
259

    
260
            if (y > (rec.getMaxY() + dify)) {
261
                y = rec.getMaxY() + dify;
262
            }
263

    
264
            lastMoveRect.setRect(x, y, w, Math.abs(h + dify));
265

    
266
            break;
267

    
268
        case (E):
269

    
270
            if (x > (rec.getMaxX() + difx)) {
271
                x = rec.getMaxX() + difx;
272
            }
273

    
274
            lastMoveRect.setRect(x, y, Math.abs(w + difx), h);
275

    
276
            break;
277

    
278
        case (NE):
279

    
280
            if ((y - difn) > rec.getMaxY()) {
281
                y = rec.getMaxY();
282
                x = rec.getMaxX() + difn;
283
            } else {
284
                y = y - difn;
285
            }
286

    
287
            lastMoveRect.setRect(x, y, Math.abs(w + difn), Math.abs(h + difn));
288

    
289
            break;
290

    
291
        case (NO):
292

    
293
            if ((y + difn) > rec.getMaxY()) {
294
                y = rec.getMaxY();
295
                x = rec.getMaxX();
296
            } else {
297
                x = x + difn;
298
                y = y + difn;
299
            }
300

    
301
            lastMoveRect.setRect(x, y, Math.abs(w - difn), Math.abs(h - difn));
302

    
303
            break;
304

    
305
        case (SE):
306

    
307
            if (y > (rec.getMaxY() + difn)) {
308
                y = rec.getMaxY() + difn;
309
                x = rec.getMaxX() + difn;
310
            }
311

    
312
            lastMoveRect.setRect(x, y, Math.abs(w + difn), Math.abs(h + difn));
313

    
314
            break;
315

    
316
        case (SO):
317

    
318
            if ((x + difn) > rec.getMaxX()) {
319
                x = rec.getMaxX();
320
                y = rec.getMaxY() - difn;
321
            } else {
322
                x = x + difn;
323
            }
324

    
325
            lastMoveRect.setRect(x, y, Math.abs(w - difn), Math.abs(h - difn));
326

    
327
            break;
328

    
329
        default:
330
            lastMoveRect.setRect((x), (y), w, h);
331
        }
332

    
333
        return lastMoveRect;
334
    }
335

    
336
    /**
337
     * Devuelve el rect�ngulo que representa el �ltimo generado al desplazar
338
     * o modificar el tama�o del fframe.
339
     * 
340
     * @return Rectangle2D
341
     * 
342
     */
343
    public Rectangle2D getLastMoveRect() {
344
        return lastMoveRect;
345
    }
346

    
347
    /**
348
     * Devuelve un entero que representa el tipo de selecci�n que se ha
349
     * realizado sobre el fframe.
350
     * 
351
     * @return tipo de selecci�n que se ha realizado.
352
     */
353
    public int getSelected() {
354
        return m_Selected;
355
    }
356

    
357
    /**
358
     * Devuelve true, si el punto que se pasa como par�metro esta contenido
359
     * dentro del boundingbox del fframe.
360
     * 
361
     * @param p
362
     *            punto a comprobar.
363
     * 
364
     * @return true si el punto esta dentro del boundingbox.
365
     */
366
    public boolean contains(Point2D p) {
367
        return getBoundingBox(null).contains(p.getX(), p.getY());
368
    }
369

    
370
    /**
371
     * Devuelve un entero que representa donde esta contenido el punto que se
372
     * pasa como par�metro.
373
     * 
374
     * @param p
375
     *            punto a comparar.
376
     * 
377
     * @return entero que representa como esta contenido el punto.
378
     */
379
    public int getContains(Point2D p) {
380
        if (n.contains(p.getX(), p.getY())) {
381
            return N;
382
        } else
383
            if (ne.contains(p.getX(), p.getY())) {
384
                return NE;
385
            } else
386
                if (e.contains(p.getX(), p.getY())) {
387
                    return E;
388
                } else
389
                    if (se.contains(p.getX(), p.getY())) {
390
                        return SE;
391
                    } else
392
                        if (s.contains(p.getX(), p.getY())) {
393
                            return S;
394
                        } else
395
                            if (so.contains(p.getX(), p.getY())) {
396
                                return SO;
397
                            } else
398
                                if (o.contains(p.getX(), p.getY())) {
399
                                    return O;
400
                                } else
401
                                    if (no.contains(p.getX(), p.getY())) {
402
                                        return NO;
403
                                    } else
404
                                        if (getBoundingBox(null).contains(
405
                                            p.getX(), p.getY())) {
406
                                            return RECT;
407
                                        }
408

    
409
        return NOSELECT;
410
    }
411

    
412
    /**
413
     * Devuelve el Cursor adecuado seg�n como est� contenido el punto, si es
414
     * para desplazamiento, o cambio de tama�o.
415
     * 
416
     * @param p
417
     *            punto a comprobar.
418
     * 
419
     * @return Cursor adecuado a la posici�n.
420
     */
421
    public Image getMapCursor(Point2D p) {
422
        int select = getContains(p);
423

    
424
        switch (select) {
425
        case (N):
426
            return iNResize;
427

    
428
        case (NE):
429
            return iNEResize;
430

    
431
        case (E):
432
            return iEResize;
433

    
434
        case (SE):
435
            return iSEResize;
436

    
437
        case (S):
438
            return iNResize;
439

    
440
        case (SO):
441
            return iNEResize;
442

    
443
        case (O):
444
            return iEResize;
445

    
446
        case (NO):
447
            return iSEResize;
448

    
449
        case (RECT):
450
            return iMove;
451
        }
452

    
453
        return null;
454
    }
455

    
456
    /**
457
     * Este m�todo se implementa en cada una de las fframe, ya que cada una se
458
     * dibuja de una forma diferente sobre el graphics. M�todo que dibuja
459
     * sobre el graphics que se le pasa como par�metro, seg�n la
460
     * transformada
461
     * afin que se debe de aplicar y el rect�ngulo que se debe de dibujar.
462
     * M�todo que dibuja sobre el graphics que se le pasa como par�metro,
463
     * seg�n la transformada afin que se debe de aplicar y el rect�ngulo que
464
     * se debe de dibujar.
465
     * 
466
     * @param g
467
     *            Graphics
468
     * @param at
469
     *            Transformada afin.
470
     * @param r
471
     *            rect�ngulo sobre el que hacer un clip.
472
     * @param imgBase
473
     *            DOCUMENT ME!
474
     */
475
    public abstract void draw(Graphics2D g, AffineTransform at, Rectangle2D r,
476
        BufferedImage imgBase);
477

    
478
    /**
479
     * Devuelve el boundingBox del fframe en funci�n de la transformada af�n
480
     * que se pasa como par�metro. Si se pasa como par�metro null, devuelve
481
     * el
482
     * �ltimo boundingbox que se calcul�.
483
     * 
484
     * @param at
485
     *            Transformada af�n
486
     * 
487
     * @return Rect�ngulo que representa el BoundingBox del fframe.
488
     */
489
    public Rectangle2D.Double getBoundingBox(AffineTransform at) {
490
        if (at == null) {
491
            return m_BoundingBox;
492
        }
493

    
494
        m_BoundingBox = FLayoutUtilities.fromSheetRect(m_BoundBox, at);
495

    
496
        return m_BoundingBox;
497
    }
498

    
499
    /**
500
     * Rellena con el rect�ngulo que se pasa como par�metro el boundBox(en
501
     * cent�metros) del fframe del cual con una transformaci�n se podr�
502
     * calcular el BoundingBox (en pixels).
503
     * 
504
     * @param r
505
     *            Rect�ngulo en cent�metros.
506
     */
507
    public void setBoundBox(Rectangle2D r) {
508
        m_BoundBox.setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
509
    }
510

    
511
    /**
512
     * Devuelve el rect�ngulo que representa el fframe en cent�metros.
513
     * 
514
     * @return Rect�ngulo en centimetros.
515
     */
516
    public Rectangle2D.Double getBoundBox() {
517
        return m_BoundBox;
518
    }
519

    
520
    /**
521
     * Pasando como par�metro true, se toma como que esta seleccionado el
522
     * fframe y si es false como que esta sin seleccionar, de esta forma se
523
     * selecciona un fframe directamente sin comprobar si un punto esta
524
     * contenido en �l.
525
     * 
526
     * @param b
527
     *            true si se quiere seleccionar y false si se quiere
528
     *            deseleccionar.
529
     */
530
    public void setSelected(boolean b) {
531
        if (b) {
532
            m_Selected = RECT;
533
        } else {
534
            m_Selected = IFFrame.NOSELECT;
535
        }
536
    }
537

    
538
    /**
539
     * Dibuja sobre el graphics el rect�ngulo del fframe en modo borrador.
540
     * 
541
     * @param g
542
     *            Graphics so bre el que dibujar.
543
     */
544
    public void drawDraft(Graphics2D g) {
545
        Rectangle2D r = getBoundingBox(null);
546

    
547
        g.setColor(Color.lightGray);
548
        g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(),
549
            (int) r.getHeight());
550
        g.setColor(Color.black);
551
        g.drawRect((int) r.getX(), (int) r.getY(), (int) r.getWidth() - 1,
552
            (int) r.getHeight() - 1);
553
        int scale = (int) (r.getWidth() / 12);
554
        Font f = new Font("SansSerif", Font.PLAIN, scale);
555
        g.setFont(f);
556
        g.drawString(getName(),
557
            (int) (r.getCenterX() - ((getName().length() * scale) / 4)),
558
            (int) (r.getCenterY()));
559
    }
560

    
561
    /**
562
     * Rellena con el n�mero de FFrame.
563
     * 
564
     * @param i
565
     *            n�mero
566
     */
567
    public void setNum(int i) {
568
        num = i;
569
    }
570

    
571
    /**
572
     * Dibuja sobre el graphics el rect�ngulo del fframe pero vacio, mostrando
573
     * el nombre del fframe y vacio.
574
     * 
575
     * @param g
576
     *            Graphics sobre el que dibujar.
577
     */
578
    public void drawEmpty(Graphics2D g) {
579
        Rectangle2D r = getBoundingBox(null);
580
        g.setColor(Color.lightGray);
581
        g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(),
582
            (int) r.getHeight());
583
        g.setColor(Color.darkGray);
584
        g.setStroke(new BasicStroke(2));
585
        g.drawRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(),
586
            (int) r.getHeight());
587
        g.setColor(Color.black);
588

    
589
        int scale = (int) (r.getWidth() / 12);
590
        Font f = new Font("SansSerif", Font.PLAIN, scale);
591
        g.setFont(f);
592

    
593
        String s =
594
            this.getNameFFrame() + " " + PluginServices.getText(this, "vacia");
595

    
596
        g.drawString(s, (int) (r.getCenterX() - ((s.length() * scale) / 4)),
597
            (int) (r.getCenterY()));
598
    }
599

    
600
    /**
601
     * Devuelve true si el rect�ngulo primero es null o si es distinto de null
602
     * e intersecta.
603
     * 
604
     * @param rv
605
     *            Rect�ngulo
606
     * @param r
607
     *            Rect�ngulo
608
     * 
609
     * @return True si intersecta o es null.
610
     */
611
    public boolean intersects(Rectangle2D rv, Rectangle2D r) {
612
        return (((rv != null) && rv.intersects(r)) || (rv == null));
613
    }
614

    
615
    /**
616
     * Rellena el tag del FFrame.
617
     * 
618
     * @param s
619
     *            String que representa el valor a guardar en el tag.
620
     */
621
    public void setTag(String s) {
622
        tag = s;
623
    }
624

    
625
    /**
626
     * Devuelve el tag.
627
     * 
628
     * @return tag.
629
     */
630
    public String getTag() {
631
        return tag;
632
    }
633

    
634
    /**
635
     * Dibuja sobre el graphics que se pasa como par�metro el icono que
636
     * representa que contiene un tag.
637
     * 
638
     * @param g
639
     *            Graphics sobre el que dibujar el icono.
640
     */
641
    public void drawSymbolTag(Graphics2D g) {
642
        Rectangle2D rec = getBoundingBox(null);
643
        g.rotate(Math.toRadians(getRotation()), rec.getX()
644
            + (rec.getWidth() / 2), rec.getY() + (rec.getHeight() / 2));
645

    
646
        try {
647
            Image image =
648
                PluginServices.getIconTheme().get("symboltag-icon").getImage();
649
            g.drawImage(image, (int) rec.getX(), (int) rec.getCenterY(), 30,
650
                30, null);
651
        } catch (NullPointerException npe) {
652
        }
653

    
654
        g.rotate(Math.toRadians(-getRotation()), rec.getX()
655
            + (rec.getWidth() / 2), rec.getY() + (rec.getHeight() / 2));
656
    }
657

    
658
    /**
659
     * Rellenar la rotaci�n para aplicar al FFrame.
660
     * 
661
     * @param rotation
662
     *            rotaci�n que se quiere aplicar.
663
     */
664
    public void setRotation(double rotation) {
665
        m_rotation = rotation;
666
    }
667

    
668
    /**
669
     * Devuelve la rotaci�n del FFrame.
670
     * 
671
     * @return Rotaci�n del FFrame.
672
     */
673
    public double getRotation() {
674
        return m_rotation;
675
    }
676

    
677
    /**
678
     * Devuelve el nivel en el que se encuentra el FFrame.
679
     * 
680
     * @return nivel
681
     */
682
    public int getLevel() {
683
        return level;
684
    }
685

    
686
    /**
687
     * Inserta el nivel al que se encuentra el FFrame.
688
     * 
689
     * @param l
690
     *            entero que refleja el nivel del FFrame.
691
     */
692
    public void setLevel(int l) {
693
        level = l;
694
    }
695

    
696
    @Override
697
    public Object clone() throws CloneNotSupportedException {
698
        IFFrame frame = (IFFrame) super.clone();
699
        return frame;
700
    }
701

    
702
    public void setFrameFactory(FrameFactory flf) {
703
        frameFactory = flf;
704
    }
705

    
706
    public FrameFactory getFrameFactory() {
707
        return frameFactory;
708
    }
709

    
710
    /**
711
     * Initilizes the static icons
712
     */
713
    public static void initializeIcons() {
714
        iNEResize =
715
            PluginServices.getIconTheme().get("neresize-icon").getImage();
716
        iEResize = PluginServices.getIconTheme().get("eresize-icon").getImage();
717
        iNResize = PluginServices.getIconTheme().get("nresize-icon").getImage();
718
        iMove = PluginServices.getIconTheme().get("move-icon").getImage();
719
        iSEResize =
720
            PluginServices.getIconTheme().get("sereresize-icon").getImage();
721
    }
722

    
723
    public static void registerPersistent() {
724
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
725
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
726
            DynStruct definition =
727
                manager.addDefinition(FFrame.class,
728
                    PERSISTENCE_DEFINITION_NAME,
729
                    "FFrame persistence definition", null, null);
730

    
731
            definition.addDynFieldObject(BOUNDINGBOX_FIELD)
732
                .setClassOfValue(Rectangle2D.class).setMandatory(true);
733
            definition.addDynFieldInt(SELECTED_FIELD).setMandatory(true);
734
            definition.addDynFieldString(TAG_FIELD).setMandatory(false);
735
            definition.addDynFieldDouble(ROTATION_FIELD).setMandatory(true);
736
            definition.addDynFieldInt(LEVEL_FIELD).setMandatory(true);
737
            definition.addDynFieldInt(NUM_FIELD).setMandatory(true);
738
        }
739

    
740
        Attributes.registerPersistent();
741
        AbstractFFrameViewDependence.registerPersistent();
742
        FFrameBasic.registerPersistent();
743
        FFrameGraphics.registerPersistent();
744
        FFrameSymbol.registerPersistent();
745
        FFrameGrid.registerPersistent();
746
        FFrameGroup.registerPersistent();
747
        FFrameTable.registerPersistent();
748
        FFrameLegend.registerPersistent();
749
        FFramePicture.registerPersistent();
750
        FFrameNorth.registerPersistent();
751
        FFrameScaleBar.registerPersistent();
752
        FFrameText.registerPersistent();
753
        FFrameView.registerPersistent();
754
        FFrameOverView.registerPersistent();
755
    }
756

    
757
    public void loadFromState(PersistentState state)
758
        throws PersistenceException {
759
        m_BoundBox = (Rectangle2D.Double) state.get(BOUNDINGBOX_FIELD);
760
        m_Selected = state.getInt(SELECTED_FIELD);
761
        tag = state.getString(TAG_FIELD);
762
        m_rotation = state.getDouble(ROTATION_FIELD);
763
        level = state.getInt(LEVEL_FIELD);
764
        num = state.getInt(NUM_FIELD);
765
    }
766

    
767
    public void saveToState(PersistentState state) throws PersistenceException {
768
        state.set(BOUNDINGBOX_FIELD, getBoundBox());
769
        state.set(SELECTED_FIELD, m_Selected);
770
        state.set(TAG_FIELD, getTag());
771
        state.set(ROTATION_FIELD, getRotation());
772
        state.set(LEVEL_FIELD, getLevel());
773
        state.set(NUM_FIELD, num);
774
    }
775

    
776
    public LayoutContext getLayoutContext() {
777
        return layoutContext;
778
    }
779

    
780
    public void setLayoutContext(LayoutContext theLayoutContext) {
781
        this.layoutContext = theLayoutContext;
782
    }
783

    
784
    public LayoutControl getLayoutControl() {
785
        return layoutControl;
786
    }
787

    
788
    public void setLayoutControl(LayoutControl layoutControl) {
789
        this.layoutControl = layoutControl;
790
    }
791

    
792
    // public void setPrintingProperties(PrintRequestAttributeSet properties) {
793
    // printingProperties=properties;
794
    // }
795

    
796
}