svn-gvsig-desktop / trunk / libraries / libAnimation3D / src / main / java / com / iver / cit / gvsig / animation / animationType / AnimationLayer3DFlat.java @ 23595
History | View | Annotate | Download (5.91 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 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 |
|
20 |
|
21 |
package com.iver.cit.gvsig.animation.animationType; |
22 |
|
23 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
24 |
|
25 |
import com.iver.ai2.gvsig3d.camera.ProjectCamera; |
26 |
import com.iver.andami.PluginServices; |
27 |
import com.iver.andami.ui.mdiManager.IWindow; |
28 |
import com.iver.cit.gvsig.animation.IAnimationType; |
29 |
import com.iver.cit.gvsig.animation.animatedObject.AnimationObject3DFlat; |
30 |
import com.iver.cit.gvsig.animation.animatedObject.IAnimatedObject; |
31 |
import com.iver.cit.gvsig.animation.interpolator.Interpolator3DFlat; |
32 |
import com.iver.cit.gvsig.animation.keyFrame.KeyFrame3DFlat; |
33 |
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
34 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
35 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
36 |
import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
37 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
38 |
import com.iver.utiles.IPersistence; |
39 |
import com.iver.utiles.XMLEntity; |
40 |
|
41 |
public class AnimationLayer3DFlat implements IAnimationTypeKeyFrame { |
42 |
|
43 |
private String className = this.getClass().getName(); |
44 |
private String description = "Animacion basada en encuadres para vista 3D plana"; |
45 |
private String name = "Animacion vista 3D plana"; |
46 |
private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
47 |
private IInterpolator interpolator;
|
48 |
|
49 |
private IAnimatedObject animationObject3DFlat = new AnimationObject3DFlat() ; |
50 |
private String titleWindow; |
51 |
|
52 |
private IViewerContainer m_canvas3d;
|
53 |
|
54 |
public AnimationLayer3DFlat() {
|
55 |
this.interpolator = new Interpolator3DFlat(); |
56 |
} |
57 |
|
58 |
public String getClassName() { |
59 |
return className;
|
60 |
} |
61 |
|
62 |
public String getDescription() { |
63 |
return description;
|
64 |
} |
65 |
|
66 |
public String getName() { |
67 |
return name;
|
68 |
} |
69 |
|
70 |
public void setClassName(String className) { |
71 |
this.className = className;
|
72 |
} |
73 |
|
74 |
public void setDescription(String description) { |
75 |
this.description = description;
|
76 |
} |
77 |
|
78 |
public void setName(String name) { |
79 |
this.name = name;
|
80 |
} |
81 |
|
82 |
public void AppliesToObject(Object animated) { |
83 |
|
84 |
KeyFrame3DFlat keyf = (KeyFrame3DFlat) animated; |
85 |
ProjectCamera projectCamera = (ProjectCamera) keyf.getAnimatedObject(); |
86 |
|
87 |
m_canvas3d = (IViewerContainer) ((AnimationObject3DFlat)animationObject3DFlat).getAnimatedCanvas3D(); |
88 |
m_canvas3d.getOSGViewer().setCamera(projectCamera.getCamera()); |
89 |
|
90 |
m_canvas3d.repaint(); |
91 |
} |
92 |
|
93 |
public int getTypeTrack() { |
94 |
return typeTrack;
|
95 |
} |
96 |
|
97 |
public void setTypeTrack(int typeTrack) { |
98 |
this.typeTrack = typeTrack;
|
99 |
|
100 |
} |
101 |
|
102 |
public IInterpolator getInterpolator() {
|
103 |
return this.interpolator; |
104 |
} |
105 |
|
106 |
public void setInterpolator(IInterpolator interpolator) { |
107 |
this.interpolator = interpolator;
|
108 |
|
109 |
} |
110 |
|
111 |
public Object getAnimatedObject() { |
112 |
// if animated object is null.
|
113 |
if(this.animationObject3DFlat != null){ |
114 |
// getting all objects.
|
115 |
try{
|
116 |
IWindow[] viewArray = PluginServices.getMDIManager().getAllWindows();
|
117 |
for (int i = 0; i < viewArray.length; i++) { |
118 |
IWindow window = viewArray[i]; |
119 |
if(window.getWindowInfo().getTitle().equals(this.titleWindow)){ |
120 |
BaseView newView = (BaseView)window;// Working with base view
|
121 |
((AnimationObject3DFlat) this.animationObject3DFlat).setAnimatedView(newView);
|
122 |
this.setAnimatedObject(this.animationObject3DFlat); |
123 |
IInterpolatorTimeFuntion function = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion");
|
124 |
this.interpolator.setFuntion(function);
|
125 |
} |
126 |
//}
|
127 |
} |
128 |
}catch(Exception e) { |
129 |
e.printStackTrace(); |
130 |
} |
131 |
} |
132 |
return this.animationObject3DFlat; |
133 |
} |
134 |
|
135 |
public void setAnimatedObject(Object object) { |
136 |
if (object instanceof AnimationObject3DFlat) |
137 |
this.animationObject3DFlat = (IAnimatedObject) object;
|
138 |
} |
139 |
|
140 |
public XMLEntity getXMLEntity() {
|
141 |
|
142 |
XMLEntity xml = new XMLEntity();
|
143 |
xml.putProperty("className", this.getClassName()); |
144 |
xml.putProperty("description", description);
|
145 |
xml.putProperty("animationTrackTipe", typeTrack);
|
146 |
|
147 |
BaseView myActualView = (BaseView) animationObject3DFlat.getAnimatedObject("view");
|
148 |
|
149 |
titleWindow = myActualView.getWindowInfo().getTitle(); |
150 |
xml.putProperty("titleWindow", titleWindow);
|
151 |
xml.addChild(((IPersistence)this.interpolator).getXMLEntity());
|
152 |
return xml;
|
153 |
} |
154 |
|
155 |
public void setXMLEntity(XMLEntity xml) { |
156 |
if (xml.contains("className")) |
157 |
this.className= xml.getStringProperty("className"); |
158 |
if (xml.contains("animationTrackTipe")) |
159 |
this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
160 |
if (xml.contains("titleWindow")) |
161 |
this.titleWindow = xml.getStringProperty("titleWindow"); |
162 |
|
163 |
XMLEntity xmlInterpolator = xml.getChild(0);
|
164 |
|
165 |
try {
|
166 |
String class_name = xmlInterpolator.getStringProperty("className"); |
167 |
Class<?> classInterpolator = Class.forName(class_name); |
168 |
Object obj = classInterpolator .newInstance();
|
169 |
IPersistence objPersist = (IPersistence) obj; |
170 |
objPersist.setXMLEntity(xmlInterpolator); |
171 |
this.interpolator = (IInterpolator) obj;
|
172 |
this.setInterpolator(interpolator);
|
173 |
|
174 |
} catch (Exception e) { |
175 |
e.printStackTrace(); |
176 |
} |
177 |
} |
178 |
} |