Revision 15443

View differences:

import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/test/AnimationLayer2D.java
1
package com.iver.cit.gvsig.animation.test;
2

  
3
import com.iver.cit.gvsig.animation.IAnimationType;
4
import com.iver.cit.gvsig.animation.keyframe.IAnimationTypeKeyFrame;
5
import com.iver.cit.gvsig.animation.keyframe.IInterpolator;
6
import com.iver.cit.gvsig.project.ProjectExtent;
7
import com.iver.cit.gvsig.project.documents.view.gui.View;
8

  
9
public class AnimationLayer2D implements IAnimationTypeKeyFrame {
10

  
11
	private String className = "AnimationLayer2D";
12
	private String description = "Animacion para zoom de capas";
13
	private String name = "Animacion de zoom capas";
14
	private int typeTrack = IAnimationType.TIME_TYPE_TRACK;
15
	private IInterpolator interpolator;
16
	private View view;
17

  
18
	public AnimationLayer2D() {
19
		this.interpolator = new Interpolator2D();
20
	}
21

  
22
	public String getClassName() {
23
		return className;
24
	}
25

  
26
	public String getDescription() {
27
		return description;
28
	}
29

  
30
	public String getName() {
31
		return name;
32
	}
33

  
34
	public void setClassName(String className) {
35
		this.className = className;
36
	}
37

  
38
	public void setDescription(String description) {
39
		this.description = description;
40
	}
41

  
42
	public void setName(String name) {
43
		this.name = name;
44
	}
45

  
46
	public void AppliesToObject(Object animated) {
47

  
48
		// Casting the animated object
49
		KeyFrame2D keyFrame2D = (KeyFrame2D) animated;
50
		// Applies to object
51
		this.view.getMapControl().getViewPort().setExtent(
52
				((ProjectExtent) keyFrame2D.getAnimatedObject()).getExtent());
53
		// Repainting the object
54
		this.view.getMapControl().drawMap(true);
55
//		this.view.repaintMap();
56
	}
57

  
58
	public int getTypeTrack() {
59
		return typeTrack;
60
	}
61

  
62
	public void setTypeTrack(int typeTrack) {
63
		this.typeTrack = typeTrack;
64

  
65
	}
66

  
67
	public IInterpolator getInterpolator() {
68
		return this.interpolator;
69
	}
70

  
71
	public void setInterpolator(IInterpolator interpolator) {
72
		this.interpolator = interpolator;
73

  
74
	}
75

  
76
	public Object getAnimatedObject() {
77
		// TODO Auto-generated method stub
78
		return this.view;
79
	}
80

  
81
	public void setAnimatedObject(Object object) {
82
		this.view = (View) object;
83

  
84
	}
85

  
86
}
import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/test/Interpolator2D.java
1
package com.iver.cit.gvsig.animation.test;
2

  
3
import java.awt.geom.Rectangle2D;
4
import java.util.List;
5

  
6
import com.iver.cit.gvsig.animation.keyframe.IInterpolator;
7
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame;
8
import com.iver.cit.gvsig.fmap.ViewPort;
9
import com.iver.cit.gvsig.project.ProjectExtent;
10
import com.iver.cit.gvsig.project.documents.view.gui.View;
11

  
12
public class Interpolator2D implements IInterpolator {
13

  
14
	public View view;
15

  
16
	public IKeyFrame interpolate(List kfList, int index, double time) {
17
		KeyFrame2D KF = new KeyFrame2D();
18

  
19
		if (kfList == null)
20
			return null;
21

  
22
		if (this.view == null)
23
			return null;
24

  
25
		switch (kfList.size()) {
26
		// this case when there are only has 2 keyframes
27
		case 2:
28
			// getting the keyframes
29
			KeyFrame2D kf1 = (KeyFrame2D) kfList.get(0);
30
			KeyFrame2D kf2 = (KeyFrame2D) kfList.get(1);
31

  
32
			if (index == 1) {
33
				KeyFrame2D kaux = kf1;
34
				kf1 = kf2;
35
				kf2 = kaux;
36
			}
37

  
38
			ProjectExtent vp1 = (ProjectExtent) kf1.getAnimatedObject();
39
			ProjectExtent vp2 = (ProjectExtent) kf2.getAnimatedObject();
40

  
41
			// ViewPort vp = view.getMapControl().getViewPort();
42

  
43
			double min1 = vp1.getExtent().getMinX();
44
			double time1 = kf1.getTime();
45
			double min2 = vp2.getExtent().getMinX();
46
			double time2 = kf2.getTime();
47
			double left = linearInterpolate(min1, min2, time1, time2, time);
48
			min1 = vp1.getExtent().getMinY();
49
			min2 = vp2.getExtent().getMinY();
50
			double top = linearInterpolate(min1, min2, time1, time2, time);
51
			min1 = vp1.getExtent().getWidth();
52
			min2 = vp2.getExtent().getWidth();
53
			double right = linearInterpolate(min1, min2, time1, time2, time);
54
			min1 = vp1.getExtent().getHeight();
55
			min2 = vp2.getExtent().getHeight();
56
			double bottom = linearInterpolate(min1, min2, time1, time2, time);
57

  
58
			Rectangle2D newExtent = new Rectangle2D.Double(left, top, right,
59
					bottom);
60
			ProjectExtent pe = new ProjectExtent();
61
			pe.setExtent(newExtent);
62
			// pe.setEncuadre("temporal_keyframe");
63
			// vp.setExtent(newExtent);
64
			KF.setAnimatedObject(pe);
65
			break;
66

  
67
		}
68

  
69
		return KF;
70
	}
71

  
72
	private double linearInterpolate(double minX, double minX2, double timePos,
73
			double timePos2, double time) {
74
		// P1 + (P2-P1)*((t-t1)/(t2-t1))
75
		return (minX + (minX2 - minX)
76
				* ((time - timePos) / (timePos2 - timePos)));
77
	}
78

  
79
	public Object getAnimatedObject() {
80

  
81
		return this.view;
82
	}
83

  
84
	public void setAnimatedObject(Object ani) {
85
		this.view = (View) ani;
86

  
87
	}
88
}
import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/test/KeyFrame2D.java
1
package com.iver.cit.gvsig.animation.test;
2

  
3
import java.util.List;
4

  
5
import com.iver.cit.gvsig.animation.keyframe.IKeyFrame;
6
import com.iver.cit.gvsig.project.ProjectExtent;
7
import com.iver.utiles.XMLEntity;
8

  
9
public class KeyFrame2D implements IKeyFrame {
10

  
11
	private String name;
12
	private double time;
13

  
14
	ProjectExtent projectExtent = null;
15
	private Object extend;
16

  
17
	public void Apply(double Tini) {
18
		// TODO Auto-generated method stub
19

  
20
	}
21

  
22
	public void CapturesProperties() {
23
		// TODO Auto-generated method stub
24

  
25
	}
26

  
27
	public void CapturesProperties(ProjectExtent projectExtent) {
28
		this.projectExtent = projectExtent;
29

  
30
	}
31

  
32
	public String getName() {
33
		// TODO Auto-generated method stub
34
		return this.name;
35
	}
36

  
37
	public List getPropertiesList() {
38
		// TODO Auto-generated method stub
39
		return null;
40
	}
41

  
42
	public void setName(String name) {
43
		this.name = name;
44

  
45
	}
46

  
47
	public void setPropertiesList(List list) {
48
		// TODO Auto-generated method stub
49

  
50
	}
51

  
52
	public String toString() {
53
		String result;
54
		result = " keyframe2D:\n";
55
		result += " tiempo: " + this.time;
56
		result += " nombre del extent: " + this.projectExtent.getDescription();
57

  
58
		// result= "Name: " + this.getName();
59
		return result;
60
	}
61

  
62
	public void Interpolate(Object p1, Object p2, double time) {
63
		// TODO Auto-generated method stub
64
	}
65

  
66
	public Object getAnimatedObject() {
67
		// TODO Auto-generated method stub
68
		return projectExtent;
69
	}
70
	public void setAnimatedObject(Object object) {
71
		this.projectExtent = (ProjectExtent) object;
72
	}
73

  
74
	public double getTime() {
75
		return time;
76
	}
77

  
78
	public void setTime(double time) {
79
		this.time = time;
80
	}
81

  
82
	public String getClassName() {
83
		// TODO Auto-generated method stub
84
		return null;
85
	}
86

  
87
	public XMLEntity getXMLEntity() {
88
		// TODO Auto-generated method stub
89
		return null;
90
	}
91

  
92
	public void setXMLEntity(XMLEntity xml) {
93
		// TODO Auto-generated method stub
94
		
95
	}
96

  
97
}
import/ext3D/branches/ext3D_v1.1/libAnimation/src/com/iver/cit/gvsig/animation/test/AnimationTypeFactoryLayer2D.java
1
package com.iver.cit.gvsig.animation.test;
2

  
3
import com.iver.cit.gvsig.animation.AnimationFactory;
4

  
5
public class AnimationTypeFactoryLayer2D extends AnimationFactory {
6

  
7
	public static String registerName = "AnimationLayer2D";
8
	
9
	
10
	public static AnimationLayer2D animationLayer2D;
11
	
12
	static {
13
		if (animationLayer2D == null) {
14
			animationLayer2D = new AnimationLayer2D();
15
			animationLayer2D.setClassName("AnimtionLayer2D");
16
			animationLayer2D.setName("AnimationLayer2D");
17
			animationLayer2D.setDescription("Hola caracola");
18
		}
19
	}
20
	
21

  
22
	
23
	public Object create() {
24
		
25
       return animationLayer2D;
26
	}
27
	
28
	/**
29
	 * Registers in the points of extension the Factory with alias.
30
	 * 
31
	 */
32
	public static void register() {
33
		register(registerName, new AnimationTypeFactoryLayer2D(), "com.iver.cit.gvsig.animation.test.AnimationLayer2D");
34
	}
35

  
36
	public String getRegisterName() {
37
		return registerName;
38
	}
39

  
40
}

Also available in: Unified diff