-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathAngleAnimator.java
More file actions
154 lines (140 loc) · 4.13 KB
/
AngleAnimator.java
File metadata and controls
154 lines (140 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwind.animation;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.util.*;
/**
* @author jym
* @version $Id: AngleAnimator.java 1171 2013-02-11 21:45:02Z dcollins $
*/
/**
* Animates angles, via an interpolator. {@link #begin} and {@link #end} values can be reset
* once the animation is already in motion.
*/
public class AngleAnimator extends BasicAnimator
{
/**
* The angle the animation begins at.
*/
protected Angle begin;
/**
* The angle the animation ends at.
*/
protected Angle end;
/**
* The @link gov.nasa.worldwind.util.PropertyAccessor used to modify
* the data value being animated.
*/
protected final PropertyAccessor.AngleAccessor propertyAccessor;
/**
* Construct an AngleAnimator
*
* @param interpolator the {@link gov.nasa.worldwind.animation.Interpolator}
* @param begin angle the animation begins at
* @param end The angle the animation ends at.
* @param propertyAccessor The {@link gov.nasa.worldwind.util.PropertyAccessor} used to modify
* the data value being animated.
*/
public AngleAnimator(Interpolator interpolator,
Angle begin, Angle end,
PropertyAccessor.AngleAccessor propertyAccessor)
{
super(interpolator);
if (interpolator == null)
{
this.interpolator = new ScheduledInterpolator(10000);
}
if (begin == null || end == null)
{
String message = Logging.getMessage("nullValue.AngleIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (propertyAccessor == null)
{
String message = Logging.getMessage("nullValue.ViewPropertyAccessorIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.begin = begin;
this.end = end;
this.propertyAccessor = propertyAccessor;
}
/**
* Set the {@link #begin} value.
*
* @param begin the new {@link #begin} value.
*/
public void setBegin(Angle begin)
{
this.begin = begin;
}
/**
* Set the {@link #end} value.
*
* @param end the new {@link #end} value.
*/
public void setEnd(Angle end)
{
this.end = end;
}
/**
* Get the current {@link #begin} value.
*
* @return the current {@link #begin} value.
*/
public Angle getBegin()
{
return this.begin;
}
/**
* Get the current {@link #end} value.
*
* @return the current {@link #end} value.
*/
public Angle getEnd()
{
return this.end;
}
/**
* Get the {@link gov.nasa.worldwind.util.PropertyAccessor} in use by this animation
*
* @return the {@link gov.nasa.worldwind.util.PropertyAccessor} in use by this animation
*/
public PropertyAccessor.AngleAccessor getPropertyAccessor()
{
return this.propertyAccessor;
}
/**
* Set the value being animated via the {@link gov.nasa.worldwind.util.PropertyAccessor}
* using the passed interpolant. This implementation just does a straight liner interpolation
* between the {@link #begin} and {@link #end} values.
*
* @param interpolant the interpolant used to generate the next value that will be set by the
* {@link gov.nasa.worldwind.util.PropertyAccessor}
*/
protected void setImpl(double interpolant)
{
Angle newValue = this.nextAngle(interpolant);
if (newValue == null)
return;
boolean success = this.propertyAccessor.setAngle(newValue);
if (!success)
{
flagLastStateInvalid();
}
if (interpolant >= 1)
this.stop();
}
@SuppressWarnings({"UnusedDeclaration"})
private Angle nextAngle(double interpolant)
{
return Angle.mix(
interpolant,
this.begin,
this.end);
}
}