| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.github.weisj.jsvg.nodes.animation; |
| 23 |
|
| 24 |
|
| 25 |
import org.jetbrains.annotations.NotNull; |
| 26 |
import org.jetbrains.annotations.Nullable; |
| 27 |
|
| 28 |
import com.github.weisj.jsvg.animation.value.AnimatedTransform; |
| 29 |
import com.github.weisj.jsvg.attributes.transform.TransformPart; |
| 30 |
import com.github.weisj.jsvg.attributes.value.TransformValue; |
| 31 |
import com.github.weisj.jsvg.nodes.prototype.spec.Category; |
| 32 |
import com.github.weisj.jsvg.nodes.prototype.spec.ElementCategories; |
| 33 |
import com.github.weisj.jsvg.nodes.prototype.spec.PermittedContent; |
| 34 |
import com.github.weisj.jsvg.parser.impl.AttributeNode; |
| 35 |
|
| 36 |
@ElementCategories(Category.Animation) |
| 37 |
@PermittedContent(categories = {Category.Descriptive}) |
| 38 |
public final class AnimateTransform extends BaseAnimationNode { |
| 39 |
public static final String TAG = "animatetransform"; |
| 40 |
|
| 41 |
private TransformPart.TransformType type; |
| 42 |
|
| 43 |
@Override |
| 44 |
public @NotNull String tagName() { |
| 45 |
return TAG; |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public void build(@NotNull AttributeNode attributeNode) { |
| 50 |
super.build(attributeNode); |
| 51 |
type = attributeNode.getEnum("type", TransformPart.TransformType.TRANSLATE); |
| 52 |
} |
| 53 |
|
| 54 |
public @Nullable AnimatedTransform animatedTransform(@NotNull TransformValue initial, |
| 55 |
@NotNull AttributeNode attributeNode) { |
| 56 |
if (track == null) return null; |
| 57 |
|
| 58 |
TransformPart[] transforms = new TransformPart[values.length]; |
| 59 |
TransformPart identity = TransformPart.identityOfType(type); |
| 60 |
for (int i = 0; i < values.length; i++) { |
| 61 |
if (isPlaceholder(values[i])) { |
| 62 |
transforms[i] = identity; |
| 63 |
} else { |
| 64 |
TransformPart part = attributeNode.parser().parseTransformPart(type, values[i]); |
| 65 |
if (part == null) return null; |
| 66 |
transforms[i] = part; |
| 67 |
} |
| 68 |
} |
| 69 |
return new AnimatedTransform(track, initial, transforms); |
| 70 |
} |
| 71 |
} |