Statistics
| Revision:

root / trunk / libraries / libAnimationCommon / src / main / java / com / iver / cit / gvsig / animation / keyFrame / KeyFrameTransparency.java @ 25870

History | View | Annotate | Download (4.6 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
 * @author ?ngel Fraile Gri??n  e-mail: angel.fraile@iver.es
31
 * @since 1.1
32
 * * Class to create a keyframe used in animation with transparency.
33
 */
34

    
35
public class KeyFrameTransparency implements IKeyFrame {
36

    
37
        private String name;
38
        private double time;
39
        private int levelTransparency;
40
        private boolean visibility;
41
        private FLyrDefault layerDefault;
42
        private String layerName;
43
        
44

    
45

    
46
        /**
47
         * 
48
         * @see com.iver.cit.gvsig.animation.keyframe.IKeyFrame#CapturesProperties()
49
         * Capturing the property transparency of the layer and the property is selected?. 
50
         */
51
        
52
        public void CapturesProperties() {
53
                if (layerDefault != null){
54
                        levelTransparency = this.layerDefault.getTransparency();
55
                        visibility = this.layerDefault.isVisible();//Check box is selected?.
56
                }
57
        }
58

    
59
        /**
60
         * Getting the keyframe name.
61
         */
62
        
63
        public String getName() {
64
                return this.name;
65
        }
66

    
67
        public List<IKeyFrame> getPropertiesList() {
68
                return null;
69
        }
70

    
71
        /**
72
         * @param name: name of the keyframe.
73
         * Setting the keyframe name.
74
         */
75
        
76
        public void setName(String name) {
77
                this.name = name;
78

    
79
        }
80

    
81
        public void setPropertiesList(List<IKeyFrame> list) {
82
                // TODO Auto-generated method stub
83
        }
84

    
85
        /**
86
         * Information of the keyframe in a String.
87
         */
88
        
89
        public String toString() {
90
                String result;
91
                result = " keyframeTransparency:\n";
92
                result += " tiempo: " + this.time;
93
                // result= "Name: " + this.getName();
94
                return result;
95
        }
96

    
97
        /**
98
         * 
99
         * @return the Object to animate.(FLyrDefault)
100
         */
101
        
102
        public Object getAnimatedObject() {
103
                return layerDefault;
104
        }
105

    
106
        /**
107
         * 
108
         * @param object : Object to animate.
109
         * Setting the object to animate.(FLyrDefault).
110
         * 
111
         */
112
        public void setAnimatedObject(Object object) {
113
                this.layerDefault = (FLyrDefault) object;
114
        }
115

    
116
        /**
117
         * Getting the time of the keyframe.
118
         */
119
        
120
        public double getTime() {
121
                return time;
122
        }
123
        
124
        public double getLevelTransparency() {
125
                return levelTransparency;
126
        }
127

    
128
        public void setLevelTransparency(int levelTransparency) {
129
                this.levelTransparency = levelTransparency;
130
        }
131

    
132
        /**
133
         * Setting the time of the keyframe.
134
         */
135
        
136
        public void setTime(double time) {
137
                this.time = time;
138
        }
139

    
140
        /**
141
         * @return the name of the class.
142
         */
143
        public String getClassName() {
144
                // TODO Auto-generated method stub
145
                return this.getClass().getName();
146
        }
147

    
148
        /*         
149
         * IPersistence methods.
150
         */
151

    
152
        public XMLEntity getXMLEntity() {
153
                
154
                XMLEntity xml = new XMLEntity();
155
                
156
                xml.putProperty("className", this.getClassName());
157
                xml.putProperty("keyFrameName", name);
158
                xml.putProperty("levelTransparency", levelTransparency);
159
                xml.putProperty("visibility", visibility);
160
                xml.putProperty("time", time);
161
                xml.putProperty("layerName", layerDefault.getClass().getName());
162
                
163
                return xml;
164
        }
165

    
166
        public void setXMLEntity(XMLEntity xml) {
167
                
168
        //        if (xml.contains("className"))
169
        //                this.className = xml.getStringProperty("className");
170
                if (xml.contains("keyFrameName"))
171
                        this.name = xml.getStringProperty("keyFrameName");
172
                if (xml.contains("levelTransparency"))
173
                        this.levelTransparency = xml.getIntProperty("levelTransparency");
174
                if (xml.contains("visibility"))
175
                        this.visibility = xml.getBooleanProperty("visibility");
176
                if (xml.contains("time"))
177
                        this.time = xml.getDoubleProperty("time");
178
                
179

    
180
                try {
181
                        this.layerName = xml.getStringProperty("layerName");
182
                        Class<?> classProp = Class.forName(this.layerName);
183
                        Object obj = classProp.newInstance();
184
                        this.layerDefault = (FLyrDefault) obj;
185
                } catch (Exception e) {
186
                        
187
                }
188
        }
189
}