svn-gvsig-desktop / trunk / libraries / libAnimationCommon / src / main / java / com / iver / cit / gvsig / animation / keyFrame / KeyFrameTransparency.java @ 23596
History | View | Annotate | Download (4.55 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 |
package com.iver.cit.gvsig.animation.keyFrame; |
21 |
|
22 |
import java.util.List; |
23 |
|
24 |
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame; |
25 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
26 |
import com.iver.utiles.XMLEntity; |
27 |
|
28 |
|
29 |
/**
|
30 |
*
|
31 |
* @author ?ngel.
|
32 |
*
|
33 |
* Class to create a keyframe used in animation with transparency.
|
34 |
*
|
35 |
*/
|
36 |
|
37 |
public class KeyFrameTransparency implements IKeyFrame { |
38 |
|
39 |
private String name; |
40 |
private double time; |
41 |
private int levelTransparency; |
42 |
private boolean visibility; |
43 |
private FLyrDefault layerDefault;
|
44 |
private String layerName; |
45 |
|
46 |
|
47 |
|
48 |
/**
|
49 |
*
|
50 |
* @see com.iver.cit.gvsig.animation.keyframe.IKeyFrame#CapturesProperties()
|
51 |
* Capturing the property transparency of the layer and the property is selected?.
|
52 |
*/
|
53 |
|
54 |
public void CapturesProperties() { |
55 |
if (layerDefault != null){ |
56 |
levelTransparency = this.layerDefault.getTransparency();
|
57 |
visibility = this.layerDefault.isVisible();//Check box is selected?. |
58 |
} |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Getting the keyframe name.
|
63 |
*/
|
64 |
|
65 |
public String getName() { |
66 |
return this.name; |
67 |
} |
68 |
|
69 |
public List<IKeyFrame> getPropertiesList() { |
70 |
return null; |
71 |
} |
72 |
|
73 |
/**
|
74 |
* @param name: name of the keyframe.
|
75 |
* Setting the keyframe name.
|
76 |
*/
|
77 |
|
78 |
public void setName(String name) { |
79 |
this.name = name;
|
80 |
|
81 |
} |
82 |
|
83 |
public void setPropertiesList(List<IKeyFrame> list) { |
84 |
// TODO Auto-generated method stub
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Information of the keyframe in a String.
|
89 |
*/
|
90 |
|
91 |
public String toString() { |
92 |
String result;
|
93 |
result = " keyframeTransparency:\n";
|
94 |
result += " tiempo: " + this.time; |
95 |
// result= "Name: " + this.getName();
|
96 |
return result;
|
97 |
} |
98 |
|
99 |
/**
|
100 |
*
|
101 |
* @return the Object to animate.(FLyrDefault)
|
102 |
*/
|
103 |
|
104 |
public Object getAnimatedObject() { |
105 |
return layerDefault;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
*
|
110 |
* @param object : Object to animate.
|
111 |
* Setting the object to animate.(FLyrDefault).
|
112 |
*
|
113 |
*/
|
114 |
public void setAnimatedObject(Object object) { |
115 |
this.layerDefault = (FLyrDefault) object;
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* Getting the time of the keyframe.
|
120 |
*/
|
121 |
|
122 |
public double getTime() { |
123 |
return time;
|
124 |
} |
125 |
|
126 |
public double getLevelTransparency() { |
127 |
return levelTransparency;
|
128 |
} |
129 |
|
130 |
public void setLevelTransparency(int levelTransparency) { |
131 |
this.levelTransparency = levelTransparency;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Setting the time of the keyframe.
|
136 |
*/
|
137 |
|
138 |
public void setTime(double time) { |
139 |
this.time = time;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* @return the name of the class.
|
144 |
*/
|
145 |
public String getClassName() { |
146 |
// TODO Auto-generated method stub
|
147 |
return this.getClass().getName(); |
148 |
} |
149 |
|
150 |
/*
|
151 |
* IPersistence methods.
|
152 |
*/
|
153 |
|
154 |
public XMLEntity getXMLEntity() {
|
155 |
|
156 |
XMLEntity xml = new XMLEntity();
|
157 |
|
158 |
xml.putProperty("className", this.getClassName()); |
159 |
xml.putProperty("keyFrameName", name);
|
160 |
xml.putProperty("levelTransparency", levelTransparency);
|
161 |
xml.putProperty("visibility", visibility);
|
162 |
xml.putProperty("time", time);
|
163 |
xml.putProperty("layerName", layerDefault.getClass().getName());
|
164 |
|
165 |
return xml;
|
166 |
} |
167 |
|
168 |
public void setXMLEntity(XMLEntity xml) { |
169 |
|
170 |
// if (xml.contains("className"))
|
171 |
// this.className = xml.getStringProperty("className");
|
172 |
if (xml.contains("keyFrameName")) |
173 |
this.name = xml.getStringProperty("keyFrameName"); |
174 |
if (xml.contains("levelTransparency")) |
175 |
this.levelTransparency = xml.getIntProperty("levelTransparency"); |
176 |
if (xml.contains("visibility")) |
177 |
this.visibility = xml.getBooleanProperty("visibility"); |
178 |
if (xml.contains("time")) |
179 |
this.time = xml.getDoubleProperty("time"); |
180 |
|
181 |
|
182 |
try {
|
183 |
this.layerName = xml.getStringProperty("layerName"); |
184 |
Class<?> classProp = Class.forName(this.layerName); |
185 |
Object obj = classProp.newInstance();
|
186 |
this.layerDefault = (FLyrDefault) obj;
|
187 |
} catch (Exception e) { |
188 |
|
189 |
} |
190 |
} |
191 |
} |