root / branches / piloto3d / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameNorth.java @ 9529
History | View | Annotate | Download (4.18 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.gui.layout.fframes; |
42 |
|
43 |
import com.iver.cit.gvsig.gui.layout.Layout; |
44 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
45 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
46 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameViewDependence; |
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 |
|
69 |
/**
|
70 |
* Returns the FFrameView.
|
71 |
*
|
72 |
* @return FFrameView
|
73 |
*/
|
74 |
public IFFrame getFFrameDependence() {
|
75 |
return fframeview;
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Returns the rotation of de FFrameView.
|
80 |
*
|
81 |
* @return Rotation.
|
82 |
*/
|
83 |
public double getRotation() { |
84 |
if (fframeview != null) { |
85 |
return fframeview.getRotation();
|
86 |
} |
87 |
|
88 |
return super.getRotation(); |
89 |
} |
90 |
|
91 |
/**
|
92 |
* Returns a XMLEntity to save de properties.
|
93 |
*
|
94 |
* @return XMLEntity with the properties of FFrameNorth.
|
95 |
*
|
96 |
* @throws SaveException
|
97 |
*/
|
98 |
public XMLEntity getXMLEntity() throws SaveException { |
99 |
XMLEntity xml = super.getXMLEntity();
|
100 |
|
101 |
try {
|
102 |
xml.putProperty("type", Layout.RECTANGLENORTH);
|
103 |
|
104 |
if (fframeview != null) { |
105 |
Layout layout = fframeview.getLayout(); |
106 |
|
107 |
if (layout != null) { |
108 |
IFFrame[] fframes = layout.getAllFFrames();
|
109 |
|
110 |
for (int i = 0; i < fframes.length; i++) { |
111 |
if ((fframeview != null) && |
112 |
fframeview.compare(fframes[i])) { |
113 |
xml.putProperty("index", i);
|
114 |
} |
115 |
} |
116 |
} |
117 |
} |
118 |
} catch (Exception e) { |
119 |
throw new SaveException(e, this.getClass().getName()); |
120 |
} |
121 |
|
122 |
return xml;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* Inserts the properties of FFrameNorth from a XMLEntity and the Layout.
|
127 |
*
|
128 |
* @param xml XMLEntity with the properties.
|
129 |
*/
|
130 |
public void setXMLEntity(XMLEntity xml) { |
131 |
super.setXMLEntity(xml);
|
132 |
|
133 |
if (xml.contains("index")) { |
134 |
dependenceIndex = xml.getIntProperty("index");
|
135 |
} |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Update the dependences that have this FFrame with the other FFrame.
|
140 |
*
|
141 |
* @param fframes Other FFrames.
|
142 |
*/
|
143 |
public void initDependence(IFFrame[] fframes) { |
144 |
if ((dependenceIndex != -1) && |
145 |
fframes[dependenceIndex] instanceof FFrameView) {
|
146 |
fframeview = (FFrameView) fframes[dependenceIndex]; |
147 |
} |
148 |
} |
149 |
} |