70 |
private boolean updating; |
private boolean updating; |
71 |
private int disabled; |
private int disabled; |
72 |
|
|
|
/** If true, there should be no animation: the end state should just be |
|
|
* shown as fast as possible. |
|
|
* This is appropriate certain kinds of user controls such as |
|
|
* an analog control for zooming. |
|
|
*/ |
|
|
private boolean noanimation; |
|
|
|
|
73 |
/** If true, all windows have incorrect end state, and generateEndState() |
/** If true, all windows have incorrect end state, and generateEndState() |
74 |
* should be called for all of them at appropriate times. |
* should be called for all of them at appropriate times. |
75 |
*/ |
*/ |
171 |
} |
} |
172 |
} |
} |
173 |
|
|
174 |
public static void setNoAnimation() { instance.setNoAnimationImpl(); } |
static public int defaultAnimationTime = 2500; |
175 |
protected void setNoAnimationImpl() { |
private int animationtime = defaultAnimationTime; |
176 |
noanimation = true; |
|
177 |
|
public static void setNoAnimation() { |
178 |
|
instance.setAnimationTimeImpl(0); |
179 |
|
} |
180 |
|
public static void setAnimationTime(int millis) { |
181 |
|
instance.setAnimationTimeImpl(millis); |
182 |
|
} |
183 |
|
protected void setAnimationTimeImpl(int millis) { |
184 |
|
animationtime = millis; |
185 |
} |
} |
186 |
|
|
187 |
/* Called by a space to inform that some cells have been |
/* Called by a space to inform that some cells have been |
231 |
void callRender(long time, Window w); |
void callRender(long time, Window w); |
232 |
} |
} |
233 |
public class SimpleCalculator implements FractCalculator { |
public class SimpleCalculator implements FractCalculator { |
234 |
protected float r = 10, n = 2, seconds = 2.5f; |
protected float r = 10, n = 2; |
235 |
|
int millis = 0; // see defaultAnimationTime |
236 |
protected long startTime = 0; |
protected long startTime = 0; |
237 |
public void eventAt(long time) { |
public void eventAt(long time) { |
238 |
startTime = time; |
startTime = time; |
239 |
} |
} |
240 |
private float fract(long time) { |
private float fract(long time) { |
241 |
float x = (time-startTime)/(seconds*1000.0f); |
float x = (time-startTime)/((float)millis); |
242 |
x = x + x*x; |
x = x + x*x; |
243 |
//x = (float)(1-Math.cos(2*Math.PI*n*x)*Math.pow(1-x, r)); |
//x = (float)(1-Math.cos(2*Math.PI*n*x)*Math.pow(1-x, r)); |
244 |
float y = (float)(1-Math.cos(2*Math.PI*n*x)*Math.exp(-x*r)); |
float y = (float)(1-Math.cos(2*Math.PI*n*x)*Math.exp(-x*r)); |
245 |
return y; |
return y; |
246 |
} |
} |
247 |
public boolean isOver(long time) { |
public boolean isOver(long time) { |
248 |
float x = (time-startTime)/(seconds*1000.0f); |
float x = (time-startTime)/((float)millis); |
249 |
x = x + x*x; |
x = x + x*x; |
250 |
return -x*r < Math.log(0.02); |
return -x*r < Math.log(0.02); |
251 |
} |
} |
255 |
w.renderAnim(f, 1, f >= 0.85); |
w.renderAnim(f, 1, f >= 0.85); |
256 |
} |
} |
257 |
} |
} |
258 |
public FractCalculator fractCalc = new SimpleCalculator(); |
public SimpleCalculator fractCalc = new SimpleCalculator(); |
259 |
|
|
260 |
|
|
261 |
/** For subclasses to override: process incoming events. |
/** For subclasses to override: process incoming events. |
342 |
if(dbg) pa("Couldn't generate end state for window 0!"); |
if(dbg) pa("Couldn't generate end state for window 0!"); |
343 |
} else { |
} else { |
344 |
regenNeeded[0] = false; |
regenNeeded[0] = false; |
345 |
if (!noanimation && wins[0].animUseful()) |
if (animationtime != 0 |
346 |
|
&& wins[0].animUseful()) |
347 |
firstWinAnim = true; |
firstWinAnim = true; |
348 |
noanimation = false; |
fractCalc.millis = animationtime; |
349 |
|
animationtime = defaultAnimationTime; |
350 |
} |
} |
351 |
if(dbg) pa("Finished end state for window 0"); |
if(dbg) pa("Finished end state for window 0"); |
352 |
} |
} |