Added javadoc
This commit is contained in:
@@ -102,16 +102,18 @@ public class AnimationPath extends ArrayList<KeyFrame> {
|
||||
case LINEAR -> switch (nextMethod) {
|
||||
case LINEAR -> CombinedPathMethod.LINEAR;
|
||||
case EASE_IN -> CombinedPathMethod.LINEAR_EASE_IN;
|
||||
case EASE_OUT -> CombinedPathMethod.LINEAR_EASE_OUT;
|
||||
// Removed this case, as ease-out doesn't make sense right before a keyframe
|
||||
// case EASE_OUT -> CombinedPathMethod.LINEAR_EASE_OUT;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + nextMethod);
|
||||
};
|
||||
|
||||
case EASE_IN -> switch (nextMethod) {
|
||||
case LINEAR -> CombinedPathMethod.EASE_IN_LINEAR;
|
||||
case EASE_IN -> CombinedPathMethod.EASE_IN;
|
||||
case EASE_OUT -> CombinedPathMethod.EASE_OUT_LINEAR;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + nextMethod);
|
||||
};
|
||||
// Removed this case, as ease-in doesn't make sense right after a keyframe
|
||||
// case EASE_IN -> switch (nextMethod) {
|
||||
// case LINEAR -> CombinedPathMethod.EASE_IN_LINEAR;
|
||||
// case EASE_IN -> CombinedPathMethod.EASE_IN;
|
||||
// case EASE_OUT -> CombinedPathMethod.EASE_OUT_LINEAR;
|
||||
// default -> throw new IllegalStateException("Unexpected value: " + nextMethod);
|
||||
// };
|
||||
|
||||
case EASE_OUT -> switch (nextMethod) {
|
||||
case LINEAR -> CombinedPathMethod.EASE_OUT_LINEAR;
|
||||
@@ -122,57 +124,37 @@ public class AnimationPath extends ArrayList<KeyFrame> {
|
||||
default -> throw new IllegalStateException("Unexpected value: " + currentMethod);
|
||||
};
|
||||
|
||||
boolean overHalf = transition > 0.5;
|
||||
double threshold = Math.min(current.transition(), next.transition());
|
||||
|
||||
if(overHalf)
|
||||
boolean thresholdReached;
|
||||
|
||||
if(current.transition() < next.transition())
|
||||
thresholdReached = transition > threshold;
|
||||
else
|
||||
thresholdReached = transition <= next.transition();
|
||||
|
||||
if(thresholdReached)
|
||||
transition = 2 * transition - 1;
|
||||
|
||||
transition = switch (method) {
|
||||
case LINEAR -> transition;
|
||||
|
||||
case LINEAR_EASE_IN -> overHalf ? easeIn(subIterator) : transition;
|
||||
case LINEAR_EASE_IN -> thresholdReached ? easeIn(subIterator) : transition;
|
||||
|
||||
case EASE_IN -> easeIn(subIterator);
|
||||
|
||||
case EASE_IN_LINEAR -> overHalf ? transition : easeIn(subIterator);
|
||||
|
||||
case LINEAR_EASE_OUT -> overHalf ? easeOut(subIterator) : transition;
|
||||
// case EASE_IN -> easeIn(subIterator);
|
||||
|
||||
case EASE_OUT -> easeOut(subIterator);
|
||||
|
||||
case EASE_OUT_LINEAR -> overHalf ? transition : easeOut(subIterator);
|
||||
case EASE_OUT_LINEAR -> thresholdReached ? transition : easeOut(subIterator);
|
||||
|
||||
case EASE_OUT_AND_IN -> overHalf ? easeOut(subIterator) : easeIn(subIterator);
|
||||
case EASE_OUT_AND_IN -> thresholdReached ? easeOut(subIterator) : easeIn(subIterator);
|
||||
|
||||
};
|
||||
|
||||
System.out.println(method + " " + transition + " - linear: " + linear(subIterator));
|
||||
|
||||
return inBetween(current, next, transition, overHalf);
|
||||
return inBetween(current, next, transition, thresholdReached);
|
||||
|
||||
|
||||
// KeyFrame.PathMethod method;
|
||||
//
|
||||
// // Translate EASE_IN_AND_OUT to its respective currently relevant counterpart
|
||||
//
|
||||
// //TODO: non-linear keyframes can't behandled this way. This just makes it bug around
|
||||
//
|
||||
// if(transition < 0.5)
|
||||
// method = current.pathMethod().equals(KeyFrame.PathMethod.EASE_IN_AND_OUT) ?
|
||||
// KeyFrame.PathMethod.EASE_OUT : current.pathMethod();
|
||||
// else
|
||||
// method = next.pathMethod().equals(KeyFrame.PathMethod.EASE_IN_AND_OUT) ?
|
||||
// KeyFrame.PathMethod.EASE_OUT : next.pathMethod();
|
||||
//
|
||||
// // Else-case would be linear, which doesn't change anything
|
||||
//
|
||||
// if(method.equals(KeyFrame.PathMethod.EASE_IN))
|
||||
// transition = this.easeIn(subIterator);
|
||||
//
|
||||
// else if(method.equals(KeyFrame.PathMethod.EASE_OUT))
|
||||
// transition = this.easeOut(subIterator);
|
||||
//
|
||||
// return inBetween(current, next, transition, method);
|
||||
}
|
||||
|
||||
|
||||
@@ -324,9 +306,7 @@ public class AnimationPath extends ArrayList<KeyFrame> {
|
||||
private enum CombinedPathMethod {
|
||||
LINEAR,
|
||||
LINEAR_EASE_IN,
|
||||
EASE_IN,
|
||||
EASE_IN_LINEAR,
|
||||
LINEAR_EASE_OUT,
|
||||
// EASE_IN,
|
||||
EASE_OUT,
|
||||
EASE_OUT_LINEAR,
|
||||
EASE_OUT_AND_IN;
|
||||
|
||||
Reference in New Issue
Block a user