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