root / trunk / libraries / libAnimation2D / src / main / java / com / iver / cit / gvsig / animation / animationType / AnimationLayer2D.java @ 25868
History | View | Annotate | Download (5.88 KB)
1 | 23597 | afraile | /* 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 | 20149 | jcampos | package com.iver.cit.gvsig.animation.animationType; |
21 | |||
22 | import com.iver.andami.PluginServices; |
||
23 | import com.iver.andami.ui.mdiManager.IWindow; |
||
24 | import com.iver.cit.gvsig.animation.IAnimationType; |
||
25 | import com.iver.cit.gvsig.animation.animatedObject.AnimationObject2D; |
||
26 | import com.iver.cit.gvsig.animation.interpolator.Interpolator2D; |
||
27 | import com.iver.cit.gvsig.animation.keyFrame.KeyFrame2D; |
||
28 | import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame; |
||
29 | import com.iver.cit.gvsig.animation.keyframe.interpolator.FuntionFactory; |
||
30 | import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolator; |
||
31 | import com.iver.cit.gvsig.animation.keyframe.interpolator.IInterpolatorTimeFuntion; |
||
32 | import com.iver.cit.gvsig.project.ProjectExtent; |
||
33 | import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
||
34 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
35 | import com.iver.utiles.IPersistence; |
||
36 | import com.iver.utiles.XMLEntity; |
||
37 | |||
38 | 25868 | afraile | |
39 | /**
|
||
40 | * @author ?ngel Fraile Gri??n e-mail: angel.fraile@iver.es
|
||
41 | * @since 1.1
|
||
42 | *
|
||
43 | */
|
||
44 | 20149 | jcampos | public class AnimationLayer2D implements IAnimationTypeKeyFrame { |
45 | |||
46 | private String className = "AnimationLayer2D"; |
||
47 | private String description = "Animacion para zoom de capas"; |
||
48 | private String name = "Animacion de zoom capas"; |
||
49 | private int typeTrack = IAnimationType.TIME_TYPE_TRACK; |
||
50 | private IInterpolator interpolator;
|
||
51 | private View view; |
||
52 | private AnimationObject2D animationObject2D = new AnimationObject2D() ; |
||
53 | private String titleWindow; |
||
54 | |||
55 | public AnimationLayer2D() {
|
||
56 | this.interpolator = new Interpolator2D(); |
||
57 | } |
||
58 | |||
59 | public String getClassName() { |
||
60 | return className;
|
||
61 | } |
||
62 | |||
63 | public String getDescription() { |
||
64 | return description;
|
||
65 | } |
||
66 | |||
67 | public String getName() { |
||
68 | return name;
|
||
69 | } |
||
70 | |||
71 | public void setClassName(String className) { |
||
72 | this.className = className;
|
||
73 | } |
||
74 | |||
75 | public void setDescription(String description) { |
||
76 | this.description = description;
|
||
77 | } |
||
78 | |||
79 | public void setName(String name) { |
||
80 | this.name = name;
|
||
81 | } |
||
82 | |||
83 | 25868 | afraile | |
84 | /**
|
||
85 | * Repainting the view
|
||
86 | */
|
||
87 | |||
88 | 20149 | jcampos | public void AppliesToObject(Object animated) { |
89 | |||
90 | // Casting the animated object
|
||
91 | KeyFrame2D keyFrame2D = (KeyFrame2D) animated; |
||
92 | this.view = (View) this.animationObject2D.getAnimatedView(); |
||
93 | this.view.getMapControl().getViewPort().setExtent(
|
||
94 | ((ProjectExtent) keyFrame2D.getAnimatedObject()).getExtent()); |
||
95 | // Repainting the object
|
||
96 | this.view.getMapControl().drawMap(true); |
||
97 | } |
||
98 | |||
99 | public int getTypeTrack() { |
||
100 | return typeTrack;
|
||
101 | } |
||
102 | |||
103 | public void setTypeTrack(int typeTrack) { |
||
104 | this.typeTrack = typeTrack;
|
||
105 | } |
||
106 | |||
107 | public IInterpolator getInterpolator() {
|
||
108 | return this.interpolator; |
||
109 | } |
||
110 | |||
111 | public void setInterpolator(IInterpolator interpolator) { |
||
112 | this.interpolator = interpolator;
|
||
113 | } |
||
114 | |||
115 | 25868 | afraile | /**
|
116 | * Getting the animated object, in movement track animation; the view
|
||
117 | */
|
||
118 | 20149 | jcampos | public Object getAnimatedObject() { |
119 | 23224 | afraile | if(this.animationObject2D != null) { |
120 | 20149 | jcampos | // getting all views.
|
121 | try{
|
||
122 | IWindow[] viewArray = PluginServices.getMDIManager().getAllWindows();
|
||
123 | for (int i = 0; i < viewArray.length; i++) { |
||
124 | IWindow window = viewArray[i]; |
||
125 | if(window.getWindowInfo().getTitle().equals(this.titleWindow)){ |
||
126 | BaseView newView = (BaseView)window; |
||
127 | this.animationObject2D.setAnimatedView(newView);
|
||
128 | this.setAnimatedObject(this.animationObject2D); |
||
129 | IInterpolatorTimeFuntion funtion = FuntionFactory.createObject("com.iver.cit.gvsig.animation.keyframe.interpolator.LinearFuntion");
|
||
130 | this.interpolator.setFuntion(funtion);
|
||
131 | } |
||
132 | } |
||
133 | }catch(Exception e) { |
||
134 | e.printStackTrace(); |
||
135 | } |
||
136 | } |
||
137 | return this.animationObject2D; |
||
138 | } |
||
139 | |||
140 | |||
141 | public void setAnimatedObject(Object object) { |
||
142 | 23224 | afraile | if (object instanceof AnimationObject2D) |
143 | this.animationObject2D = (AnimationObject2D) object;
|
||
144 | 20149 | jcampos | |
145 | } |
||
146 | public XMLEntity getXMLEntity() {
|
||
147 | |||
148 | View myActualView = null; |
||
149 | |||
150 | XMLEntity xml = new XMLEntity();
|
||
151 | xml.putProperty("className", this.getClassName()); |
||
152 | xml.putProperty("description", description);
|
||
153 | xml.putProperty("animationTrackTipe", typeTrack);
|
||
154 | myActualView = (View) animationObject2D.getAnimatedView();
|
||
155 | titleWindow = myActualView.getWindowInfo().getTitle(); |
||
156 | xml.putProperty("titleWindow", titleWindow);
|
||
157 | xml.addChild(((IPersistence)this.interpolator).getXMLEntity());
|
||
158 | return xml;
|
||
159 | } |
||
160 | |||
161 | public void setXMLEntity(XMLEntity xml) { |
||
162 | 23224 | afraile | if (xml.contains("className")) |
163 | this.className= xml.getStringProperty("className"); |
||
164 | 20149 | jcampos | if (xml.contains("animationTrackTipe")) |
165 | this.typeTrack = xml.getIntProperty("animationTrackTipe"); |
||
166 | if (xml.contains("titleWindow")) |
||
167 | this.titleWindow = xml.getStringProperty("titleWindow"); |
||
168 | |||
169 | XMLEntity xmlInterpolator = xml.getChild(0);
|
||
170 | |||
171 | try {
|
||
172 | String class_name = xmlInterpolator.getStringProperty("className"); |
||
173 | 23597 | afraile | Class<?> classInterpolator = Class.forName(class_name); |
174 | 20149 | jcampos | Object obj = classInterpolator .newInstance();
|
175 | IPersistence objPersist = (IPersistence) obj; |
||
176 | objPersist.setXMLEntity(xmlInterpolator); |
||
177 | this.interpolator = (IInterpolator) obj;
|
||
178 | this.setInterpolator(interpolator);
|
||
179 | |||
180 | } catch (Exception e) { |
||
181 | e.printStackTrace(); |
||
182 | } |
||
183 | } |
||
184 | |||
185 | } |