svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / FFrameNorth.java @ 324
History | View | Annotate | Download (4.03 KB)
1 | 5 | jldominguez | /* 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 org.gvsig.tools.ToolsLocator; |
||
25 | import org.gvsig.tools.dynobject.DynStruct; |
||
26 | import org.gvsig.tools.persistence.PersistenceManager; |
||
27 | import org.gvsig.tools.persistence.PersistentState; |
||
28 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
29 | |||
30 | /**
|
||
31 | * Class that extends FFramePicture and implements IFFrameViewDependence to be
|
||
32 | * able to maintain the same rotation that the view to which associate.
|
||
33 | *
|
||
34 | * @author Vicente Caballero Navarro
|
||
35 | */
|
||
36 | public class FFrameNorth extends FFramePicture implements IFFrameViewDependence { |
||
37 | |||
38 | public static final String PERSISTENCE_DEFINITION_NAME = "FFrameNorth"; |
||
39 | |||
40 | private static final String FFRAMEVIEWDEPENDENCE_FIELD = |
||
41 | "fframeViewDependence";
|
||
42 | |||
43 | private FFrameView fframeViewDependence;
|
||
44 | |||
45 | /**
|
||
46 | * Inserts FFrameView to be able to relate this with the image.
|
||
47 | *
|
||
48 | * @param fv
|
||
49 | * FFrameView
|
||
50 | */
|
||
51 | public void setFFrameDependence(IFFrame fv) { |
||
52 | fframeViewDependence = (FFrameView) fv; |
||
53 | } |
||
54 | |||
55 | public void refreshDependence(IFFrame fant, IFFrame fnew) { |
||
56 | if ((fframeViewDependence != null) && fframeViewDependence.equals(fant)) { |
||
57 | fframeViewDependence = (FFrameView) fnew; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /**
|
||
62 | * Returns the FFrameView.
|
||
63 | *
|
||
64 | * @return FFrameView
|
||
65 | */
|
||
66 | public IFFrame[] getFFrameDependence() { |
||
67 | return new IFFrame[] { fframeViewDependence }; |
||
68 | } |
||
69 | |||
70 | /**
|
||
71 | * Returns the rotation of de FFrameView.
|
||
72 | *
|
||
73 | * @return Rotation.
|
||
74 | */
|
||
75 | public double getRotation() { |
||
76 | if (fframeViewDependence != null) { |
||
77 | 72 | jldominguez | |
78 | return fframeViewDependence.getRotation()
|
||
79 | + fframeViewDependence.getMapRotation(); |
||
80 | 5 | jldominguez | } |
81 | |||
82 | return super.getRotation(); |
||
83 | } |
||
84 | |||
85 | public static void registerPersistent() { |
||
86 | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
||
87 | if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
||
88 | DynStruct definition = |
||
89 | manager.addDefinition(FFrameNorth.class, |
||
90 | PERSISTENCE_DEFINITION_NAME, |
||
91 | "FFrameNorth persistence definition", null, null); |
||
92 | |||
93 | definition.extend(manager |
||
94 | .getDefinition(FFramePicture.PERSISTENCE_DEFINITION_NAME)); |
||
95 | |||
96 | definition.addDynFieldObject(FFRAMEVIEWDEPENDENCE_FIELD). |
||
97 | setClassOfValue(IFFrame.class); |
||
98 | |||
99 | } |
||
100 | } |
||
101 | |||
102 | @Override
|
||
103 | public void loadFromState(PersistentState state) |
||
104 | throws PersistenceException {
|
||
105 | super.loadFromState(state);
|
||
106 | if (state.hasValue(FFRAMEVIEWDEPENDENCE_FIELD)) {
|
||
107 | fframeViewDependence = |
||
108 | (FFrameView) state.get(FFRAMEVIEWDEPENDENCE_FIELD); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | @Override
|
||
113 | public void saveToState(PersistentState state) throws PersistenceException { |
||
114 | super.saveToState(state);
|
||
115 | state.set(FFRAMEVIEWDEPENDENCE_FIELD, fframeViewDependence); |
||
116 | } |
||
117 | |||
118 | public Object clone() throws CloneNotSupportedException { |
||
119 | IFFrame frame = (IFFrame) super.clone();
|
||
120 | return frame;
|
||
121 | } |
||
122 | |||
123 | public String getName() { |
||
124 | return PERSISTENCE_DEFINITION_NAME;
|
||
125 | } |
||
126 | } |