Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameNorth.java @ 28546

History | View | Annotate | Download (4.55 KB)

1 9392 caballero
/* 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.project.documents.layout.fframes;
42
43
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
44
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameNorthDialog;
45
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
46
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
47
import com.iver.utiles.XMLEntity;
48
49
50
/**
51
 * Class that extends FFramePicture and implements IFFrameViewDependence to be
52
 * able to maintain the same rotation that the view to which associate.
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class FFrameNorth extends FFramePicture implements IFFrameViewDependence {
57
    private FFrameView fframeview;
58
    private int dependenceIndex = -1;
59
60
    /**
61
     * Inserts FFrameView to be able to relate this with the image.
62
     *
63
     * @param fv FFrameView
64
     */
65
    public void setFFrameDependence(IFFrame fv) {
66
        fframeview = (FFrameView) fv;
67
    }
68 11800 caballero
    public void refreshDependence(IFFrame fant, IFFrame fnew) {
69
            if ((fframeview != null) &&
70
                fframeview.equals(fant)) {
71
            fframeview=(FFrameView)fnew;
72
            }
73
    }
74 9392 caballero
    /**
75
     * Returns the FFrameView.
76
     *
77
     * @return FFrameView
78
     */
79 11800 caballero
    public IFFrame[] getFFrameDependence() {
80
        return new IFFrame[]{fframeview};
81 9392 caballero
    }
82
83
    /**
84
     * Returns the rotation of de FFrameView.
85
     *
86
     * @return Rotation.
87
     */
88
    public double getRotation() {
89
        if (fframeview != null) {
90
            return fframeview.getRotation();
91
        }
92
93
        return super.getRotation();
94
    }
95
96
    /**
97
     * Returns a XMLEntity to save de properties.
98
     *
99
     * @return XMLEntity with the properties of FFrameNorth.
100
     *
101
     * @throws SaveException
102
     */
103
    public XMLEntity getXMLEntity() throws SaveException {
104
        XMLEntity xml = super.getXMLEntity();
105
106
        try {
107
//            xml.putProperty("type", Layout.RECTANGLENORTH);
108
109
            if (fframeview != null) {
110
                Layout layout = fframeview.getLayout();
111
112
                if (layout != null) {
113
                    IFFrame[] fframes = layout.getLayoutContext().getAllFFrames();
114
115
                    for (int i = 0; i < fframes.length; i++) {
116
                        if ((fframeview != null) &&
117
                                fframeview.compare(fframes[i])) {
118
                            xml.putProperty("index", i);
119
                        }
120
                    }
121
                }
122
            }
123
        } catch (Exception e) {
124
            throw new SaveException(e, this.getClass().getName());
125
        }
126
127
        return xml;
128
    }
129
130
    /**
131
     * Inserts the properties of FFrameNorth from a XMLEntity and the Layout.
132
     *
133
     * @param xml XMLEntity with the properties.
134
     */
135
    public void setXMLEntity(XMLEntity xml) {
136
        super.setXMLEntity(xml);
137
138
        if (xml.contains("index")) {
139
            dependenceIndex = xml.getIntProperty("index");
140
        }
141
    }
142
143
    /**
144
     * Update the dependences that have this FFrame with the other FFrame.
145
     *
146
     * @param fframes Other FFrames.
147
     */
148
    public void initDependence(IFFrame[] fframes) {
149
        if ((dependenceIndex != -1) &&
150
                fframes[dependenceIndex] instanceof FFrameView) {
151
            fframeview = (FFrameView) fframes[dependenceIndex];
152
        }
153
    }
154
155
        public IFFrameDialog getPropertyDialog() {
156
                return new FFrameNorthDialog(getLayout(),this);
157
        }
158
}