260 |
} |
} |
261 |
} |
} |
262 |
static public class SimpleCalculator implements FractCalculator { |
static public class SimpleCalculator implements FractCalculator { |
263 |
protected static float r = 2f, n = 0.4f; |
/** |
264 |
|
* Multiplicates x in Math.cos(); determines the amount of |
265 |
|
* 'waves' when interpolating between two view states. |
266 |
|
*/ |
267 |
|
protected static n = 0.4f; |
268 |
|
/** |
269 |
|
* Multiplicates x in Math.exp(); determines how fast animation |
270 |
|
* slows down, how fast it reduces 'waving'. |
271 |
|
*/ |
272 |
|
protected static float r = 2f; |
273 |
|
|
274 |
int millis = 0; // see defaultAnimationTime |
int millis = 0; // see defaultAnimationTime |
275 |
protected long startTime = 0; |
protected long startTime = 0; |
276 |
public void eventAt(long time) { |
public void eventAt(long time) { |
288 |
float x = (time-startTime)/((float)millis); |
float x = (time-startTime)/((float)millis); |
289 |
if (-(x + x*x)*r < Math.log(0.02)) { |
if (-(x + x*x)*r < Math.log(0.02)) { |
290 |
if (Math.abs(time-startTime-millis) > 100) { |
if (Math.abs(time-startTime-millis) > 100) { |
291 |
/** If animation time was either 'too fast' or |
/** XXX: If animation time was either 'too fast' or 'too slow', |
292 |
* 'too slow', we recalibrate r and n. |
* we recalibrate r and n. This is probably irrelevant for now on. |
293 |
|
* Although, current values for n and r are found with this. But |
294 |
|
* if we want to change values of r or n, this will help us to keep |
295 |
|
* the defaultAnimationTime. |
296 |
*/ |
*/ |
297 |
if (dbg) pa("x: " + x + " r: " + r + " n: " + n + |
if (dbg) pa("x: " + x + " r: " + r + " n: " + n + |
298 |
" millis: " + (time - startTime)); |
" millis: " + (time - startTime) + " recalibrating..."); |
299 |
r *= x; n *= x; |
r *= x; n *= x; |
300 |
} |
} |
301 |
return true; |
return true; |