Revision 671
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.impl/src/main/java/org/gvsig/animation3d/swing/impl/DefaultAnimation3DSwingLibrary.java | ||
---|---|---|
19 | 19 |
@Override |
20 | 20 |
protected void doInitialize() throws LibraryException { |
21 | 21 |
Animation3DSwingLocator.registerDefaultManager(DefaultAnimation3DSwingManager.class); |
22 |
|
|
23 |
DefaultAnimation3D.registerPersistenceDefinition(); |
|
24 |
DefaultFrame3D.registerPersistenceDefinition(); |
|
22 | 25 |
} |
23 | 26 |
|
24 | 27 |
@Override |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.impl/src/main/java/org/gvsig/animation3d/swing/impl/DefaultAnimation3D.java | ||
---|---|---|
1 |
package org.gvsig.animation3d.swing.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.animation3d.swing.api.Animation3D; |
|
7 |
import org.gvsig.animation3d.swing.api.Frame3D; |
|
8 |
import org.gvsig.tools.ToolsLocator; |
|
9 |
import org.gvsig.tools.dynobject.DynStruct; |
|
10 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
11 |
import org.gvsig.tools.persistence.PersistentState; |
|
12 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
13 |
|
|
14 |
/** |
|
15 |
* Default implementation of Animation 3D. |
|
16 |
* |
|
17 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
18 |
*/ |
|
19 |
public class DefaultAnimation3D implements Animation3D { |
|
20 |
|
|
21 |
private static final String NAME = "defaultAnimation3D"; |
|
22 |
private static final String DESCRIPTION = "Default persistence definition of Animation 3D"; |
|
23 |
|
|
24 |
private static final String NAME_FIELD = "name"; |
|
25 |
private static final String SPHERICAL_FRAMES_FIELD = "sphericalFrames"; |
|
26 |
private static final String FLAT_FRAMES_FIELD = "flatFrames"; |
|
27 |
|
|
28 |
private String name; |
|
29 |
private List<Frame3D> sphericalFrames; |
|
30 |
private List<Frame3D> flatFrames; |
|
31 |
|
|
32 |
/** |
|
33 |
* Empty constructor to load from persistence |
|
34 |
*/ |
|
35 |
public DefaultAnimation3D() { |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* Default constructor |
|
41 |
* |
|
42 |
* @param name |
|
43 |
* Name of animation 3D. |
|
44 |
* @param sphericalFrames |
|
45 |
* @param flatFrames |
|
46 |
* @param frames |
|
47 |
* List with animation frames |
|
48 |
*/ |
|
49 |
public DefaultAnimation3D(String name, List<Frame3D> sphericalFrames, List<Frame3D> flatFrames) { |
|
50 |
this.name = name; |
|
51 |
this.sphericalFrames = sphericalFrames; |
|
52 |
this.flatFrames = flatFrames; |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public String getName() { |
|
57 |
return this.name; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public void setName(String name) { |
|
62 |
this.name = name; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public List<Frame3D> getSphericalFrames() { |
|
67 |
return this.sphericalFrames; |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void setSphericalFrames(List<Frame3D> frames) { |
|
72 |
this.sphericalFrames = frames; |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public List<Frame3D> getFlatFrames() { |
|
77 |
return this.flatFrames; |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public void setFlatFrames(List<Frame3D> frames) { |
|
82 |
this.flatFrames = frames; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Static method to register persistence definition |
|
87 |
*/ |
|
88 |
public static void registerPersistenceDefinition() { |
|
89 |
|
|
90 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
91 |
if (persistenceManager.getDefinition(NAME) == null) { |
|
92 |
|
|
93 |
DynStruct definition = |
|
94 |
persistenceManager.addDefinition(DefaultAnimation3D.class, NAME, DESCRIPTION, null, null); |
|
95 |
|
|
96 |
definition.addDynFieldString(NAME_FIELD); |
|
97 |
definition.addDynFieldList(SPHERICAL_FRAMES_FIELD); |
|
98 |
definition.addDynFieldList(FLAT_FRAMES_FIELD); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
104 |
state.set(NAME_FIELD, this.getName()); |
|
105 |
state.set(SPHERICAL_FRAMES_FIELD, this.getSphericalFrames()); |
|
106 |
state.set(FLAT_FRAMES_FIELD, this.getFlatFrames()); |
|
107 |
} |
|
108 |
|
|
109 |
@SuppressWarnings("unchecked") |
|
110 |
@Override |
|
111 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
112 |
this.setName(state.getString(NAME_FIELD)); |
|
113 |
this.setSphericalFrames(new ArrayList<Frame3D>(state.getList(SPHERICAL_FRAMES_FIELD))); |
|
114 |
this.setFlatFrames(new ArrayList<Frame3D>(state.getList(FLAT_FRAMES_FIELD))); |
|
115 |
} |
|
116 |
} |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.impl/src/main/java/org/gvsig/animation3d/swing/impl/DefaultAnimation3DSwingManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.animation3d.swing.impl; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collection; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.gvsig.animation3d.swing.api.Animation3D; |
|
3 | 8 |
import org.gvsig.animation3d.swing.api.Animation3DSwingManager; |
9 |
import org.gvsig.animation3d.swing.api.Frame3D; |
|
10 |
import org.gvsig.fmap.geom.primitive.Point; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
|
12 |
import org.gvsig.tools.persistence.impl.DelegatedList; |
|
4 | 13 |
|
5 |
|
|
6 | 14 |
/** |
7 | 15 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
8 | 16 |
* |
9 | 17 |
*/ |
10 |
public class DefaultAnimation3DSwingManager implements Animation3DSwingManager{ |
|
18 |
public class DefaultAnimation3DSwingManager implements Animation3DSwingManager {
|
|
11 | 19 |
|
20 |
@SuppressWarnings("unchecked") |
|
21 |
@Override |
|
22 |
public List<Animation3D> getAnimations(ExtendedPropertiesSupport properties) { |
|
23 |
Object animationsList = properties.getProperty("animations"); |
|
24 |
if (animationsList == null) { |
|
25 |
List<Animation3D> animations = new ArrayList<Animation3D>(); |
|
26 |
setAnimations(properties, animations); |
|
27 |
return animations; |
|
28 |
} else { |
|
29 |
if (animationsList instanceof DelegatedList) { |
|
30 |
List<Animation3D> animations = new ArrayList<Animation3D>(); |
|
31 |
animations.addAll((Collection<? extends Animation3D>) animationsList); |
|
32 |
setAnimations(properties, animations); |
|
33 |
return animations; |
|
34 |
} else { |
|
35 |
return (List<Animation3D>) animationsList; |
|
36 |
} |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public void setAnimations(ExtendedPropertiesSupport properties, List<Animation3D> animations) { |
|
42 |
properties.setProperty("animations", animations); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public Frame3D createFrame3D(String name, double heading, double pitch, double elevation, |
|
47 |
Point position, double zoom) { |
|
48 |
return new DefaultFrame3D(name, heading, pitch, elevation, position, zoom); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public Animation3D createAnimation3D(String name, List<Frame3D> sphericalFrames, |
|
53 |
List<Frame3D> flatFrames) { |
|
54 |
return new DefaultAnimation3D(name, sphericalFrames, flatFrames); |
|
55 |
} |
|
56 |
|
|
12 | 57 |
} |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.impl/src/main/java/org/gvsig/animation3d/swing/impl/DefaultFrame3D.java | ||
---|---|---|
1 |
package org.gvsig.animation3d.swing.impl; |
|
2 |
|
|
3 |
import org.gvsig.animation3d.swing.api.Frame3D; |
|
4 |
import org.gvsig.fmap.geom.primitive.Point; |
|
5 |
import org.gvsig.tools.ToolsLocator; |
|
6 |
import org.gvsig.tools.dynobject.DynStruct; |
|
7 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
8 |
import org.gvsig.tools.persistence.PersistentState; |
|
9 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class DefaultFrame3D implements Frame3D { |
|
17 |
|
|
18 |
private static final String NAME = "defaultFrame3D"; |
|
19 |
private static final String DESCRIPTION = "Default persistence definition of Frame 3D"; |
|
20 |
|
|
21 |
private static final String NAME_FIELD = "name"; |
|
22 |
private static final String HEADING_FIELD = "heading"; |
|
23 |
private static final String PITCH_FIELD = "pitch"; |
|
24 |
private static final String ELEVATION_FIELD = "elevation"; |
|
25 |
private static final String POSITION_FIELD = "position"; |
|
26 |
private static final String ZOOM_FIELD = "zoom"; |
|
27 |
|
|
28 |
|
|
29 |
private String name; |
|
30 |
private double heading; |
|
31 |
private double pitch; |
|
32 |
private double elevation; |
|
33 |
private Point position; |
|
34 |
private double zoom; |
|
35 |
|
|
36 |
/** |
|
37 |
* Empty constructor to load from persistence |
|
38 |
*/ |
|
39 |
public DefaultFrame3D() { |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* @param name |
|
45 |
* @param heading |
|
46 |
* @param pitch |
|
47 |
* @param elevation |
|
48 |
* @param position |
|
49 |
* @param zoom |
|
50 |
* |
|
51 |
*/ |
|
52 |
public DefaultFrame3D(String name, double heading, double pitch, double elevation, |
|
53 |
Point position, double zoom) { |
|
54 |
this.name = name; |
|
55 |
this.heading = heading; |
|
56 |
this.pitch = pitch; |
|
57 |
this.position = position; |
|
58 |
this.elevation = elevation; |
|
59 |
this.zoom = zoom; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public double getZoom(){ |
|
64 |
return this.zoom; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public void setZoom(double zoom) { |
|
69 |
this.zoom = zoom; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public double getHeading() { |
|
74 |
return heading; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void setHeading(double heading) { |
|
79 |
this.heading = heading; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public double getPitch() { |
|
84 |
return this.pitch; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public void setPitch(double pitch) { |
|
89 |
this.pitch = pitch; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public Point getPosition() { |
|
94 |
return position; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void setPosition(Point position) { |
|
99 |
this.position = position; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public double getElevation() { |
|
104 |
return this.elevation; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public void setElevation(double elevation) { |
|
109 |
this.elevation = elevation; |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public String getName() { |
|
114 |
return this.name; |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public void setName(String name) { |
|
119 |
this.name = name; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Static method to register persistence definition |
|
124 |
*/ |
|
125 |
public static void registerPersistenceDefinition() { |
|
126 |
|
|
127 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
128 |
if (persistenceManager.getDefinition(NAME) == null) { |
|
129 |
|
|
130 |
DynStruct definition = |
|
131 |
persistenceManager.addDefinition(DefaultFrame3D.class, NAME, DESCRIPTION, null, null); |
|
132 |
|
|
133 |
definition.addDynFieldString(NAME_FIELD); |
|
134 |
definition.addDynFieldDouble(HEADING_FIELD); |
|
135 |
definition.addDynFieldDouble(PITCH_FIELD); |
|
136 |
definition.addDynFieldDouble(ELEVATION_FIELD); |
|
137 |
definition.addDynFieldObject(POSITION_FIELD).setClassOfValue(Point.class); |
|
138 |
definition.addDynFieldDouble(ZOOM_FIELD); |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
144 |
state.set(NAME_FIELD, this.getName()); |
|
145 |
state.set(HEADING_FIELD, this.getHeading()); |
|
146 |
state.set(PITCH_FIELD, this.getPitch()); |
|
147 |
state.set(ELEVATION_FIELD, this.getElevation()); |
|
148 |
state.set(POSITION_FIELD, this.getPosition()); |
|
149 |
state.set(ZOOM_FIELD, this.getZoom()); |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
154 |
this.setName(state.getString(NAME_FIELD)); |
|
155 |
this.setHeading(state.getDouble(HEADING_FIELD)); |
|
156 |
this.setPitch(state.getDouble(PITCH_FIELD)); |
|
157 |
this.setElevation(state.getDouble(ELEVATION_FIELD)); |
|
158 |
this.setPosition((Point) state.get(POSITION_FIELD)); |
|
159 |
this.setZoom(state.getDouble(ZOOM_FIELD)); |
|
160 |
} |
|
161 |
} |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.api/src/main/java/org/gvsig/animation3d/swing/api/Animation3D.java | ||
---|---|---|
1 |
package org.gvsig.animation3d.swing.api; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.tools.persistence.Persistent; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public interface Animation3D extends Persistent { |
|
13 |
|
|
14 |
/** |
|
15 |
* |
|
16 |
* @return Name of animation |
|
17 |
*/ |
|
18 |
public String getName(); |
|
19 |
|
|
20 |
/** |
|
21 |
* |
|
22 |
* @param name |
|
23 |
*/ |
|
24 |
public void setName(String name); |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @return List of spherical animation frames. |
|
29 |
*/ |
|
30 |
public List<Frame3D> getSphericalFrames(); |
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @return List of flat animation frames |
|
35 |
*/ |
|
36 |
public List<Frame3D> getFlatFrames(); |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
* @param frames |
|
41 |
*/ |
|
42 |
public void setSphericalFrames(List<Frame3D> frames); |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
* @param frames |
|
47 |
*/ |
|
48 |
public void setFlatFrames(List<Frame3D> frames); |
|
49 |
|
|
50 |
} |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.api/src/main/java/org/gvsig/animation3d/swing/api/Animation3DSwingManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.animation3d.swing.api; |
2 | 2 |
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.fmap.geom.primitive.Point; |
|
6 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
|
7 |
|
|
3 | 8 |
/** |
4 | 9 |
* |
5 | 10 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
... | ... | |
7 | 12 |
*/ |
8 | 13 |
public interface Animation3DSwingManager { |
9 | 14 |
|
15 |
/** |
|
16 |
* Creates a new {@link Frame3D}. |
|
17 |
* |
|
18 |
* @param name |
|
19 |
* @param heading |
|
20 |
* @param pitch |
|
21 |
* @param elevation |
|
22 |
* @param position |
|
23 |
* @param zoom |
|
24 |
* @return New {@link Frame3D}. |
|
25 |
*/ |
|
26 |
public Frame3D createFrame3D(String name, double heading, double pitch, double elevation, |
|
27 |
Point position, double zoom); |
|
28 |
|
|
29 |
/** |
|
30 |
* Creates new instance of {@link Animation3D} with name and {@link Frame3D} |
|
31 |
* list. |
|
32 |
* |
|
33 |
* @param name |
|
34 |
* Name of animation |
|
35 |
* @param sphericalFrames |
|
36 |
* List of spherical frames |
|
37 |
* @param flatFrames |
|
38 |
* List of flat frames |
|
39 |
* @return New {@link Animation3D}. |
|
40 |
*/ |
|
41 |
public Animation3D createAnimation3D(String name, List<Frame3D> sphericalFrames, |
|
42 |
List<Frame3D> flatFrames); |
|
43 |
|
|
44 |
/** |
|
45 |
* Gets animations associated with the properties. If properties does not |
|
46 |
* have animations, it will be initialized with an empty list. |
|
47 |
* |
|
48 |
* @param properties |
|
49 |
* Properties to get animations. |
|
50 |
* @return Animations of properties. |
|
51 |
*/ |
|
52 |
public List<Animation3D> getAnimations(ExtendedPropertiesSupport properties); |
|
53 |
|
|
54 |
/** |
|
55 |
* Sets list animations to properties. |
|
56 |
* |
|
57 |
* @param properties |
|
58 |
* Properties to link with animations. |
|
59 |
* @param animations |
|
60 |
* Animation list. |
|
61 |
*/ |
|
62 |
public void setAnimations(ExtendedPropertiesSupport properties, List<Animation3D> animations); |
|
63 |
|
|
10 | 64 |
} |
org.gvsig.animation3d/trunk/org.gvsig.animation3d/org.gvsig.animation3d.swing/org.gvsig.animation3d.swing.api/src/main/java/org/gvsig/animation3d/swing/api/Frame3D.java | ||
---|---|---|
1 |
package org.gvsig.animation3d.swing.api; |
|
2 |
|
|
3 |
import org.gvsig.fmap.geom.primitive.Point; |
|
4 |
import org.gvsig.tools.persistence.Persistent; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
9 |
* |
|
10 |
*/ |
|
11 |
public interface Frame3D extends Persistent { |
|
12 |
|
|
13 |
/** |
|
14 |
* @return Returns heading of frame. |
|
15 |
*/ |
|
16 |
public double getHeading(); |
|
17 |
|
|
18 |
/** |
|
19 |
* Sets heading |
|
20 |
* |
|
21 |
* @param heading |
|
22 |
* New heading of frame |
|
23 |
*/ |
|
24 |
public void setHeading(double heading); |
|
25 |
|
|
26 |
/** |
|
27 |
* @return Returns name |
|
28 |
*/ |
|
29 |
public String getName(); |
|
30 |
|
|
31 |
/** |
|
32 |
* @return Returns pitch of frame. |
|
33 |
*/ |
|
34 |
public double getPitch(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Sets pitch |
|
38 |
* |
|
39 |
* @param pitch |
|
40 |
* New pitch of frame |
|
41 |
*/ |
|
42 |
public void setPitch(double pitch); |
|
43 |
|
|
44 |
/** |
|
45 |
* @return Returns position |
|
46 |
*/ |
|
47 |
public Point getPosition(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Sets position |
|
51 |
* |
|
52 |
* @param position |
|
53 |
* New position of frame |
|
54 |
*/ |
|
55 |
public void setPosition(Point position); |
|
56 |
|
|
57 |
/** |
|
58 |
* @return Returns elevation of frame |
|
59 |
*/ |
|
60 |
public double getElevation(); |
|
61 |
|
|
62 |
/** |
|
63 |
* Sets elevation |
|
64 |
* |
|
65 |
* @param elevation |
|
66 |
* New elevation of frame. |
|
67 |
*/ |
|
68 |
public void setElevation(double elevation); |
|
69 |
|
|
70 |
/** |
|
71 |
* Sets name |
|
72 |
* |
|
73 |
* @param name Name of Frame3D |
|
74 |
*/ |
|
75 |
public void setName(String name); |
|
76 |
|
|
77 |
/** |
|
78 |
* |
|
79 |
* @return Returns frame of zoom |
|
80 |
*/ |
|
81 |
public double getZoom(); |
|
82 |
|
|
83 |
/** |
|
84 |
* |
|
85 |
* @param zoom |
|
86 |
*/ |
|
87 |
public void setZoom(double zoom); |
|
88 |
} |
Also available in: Unified diff