blob: dfe1acf8f6d2265a0d6b4196651fc42ff55ae756 [file] [log] [blame]
package com.airbnb.lottie.model.content;
import android.graphics.PointF;
import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieDrawable;
import com.airbnb.lottie.animation.content.Content;
import com.airbnb.lottie.animation.content.RectangleContent;
import com.airbnb.lottie.model.animatable.AnimatableFloatValue;
import com.airbnb.lottie.model.animatable.AnimatablePathValue;
import com.airbnb.lottie.model.animatable.AnimatablePointValue;
import com.airbnb.lottie.model.animatable.AnimatableValue;
import com.airbnb.lottie.model.layer.BaseLayer;
import org.json.JSONObject;
public class RectangleShape implements ContentModel {
private final String name;
private final AnimatableValue<PointF, PointF> position;
private final AnimatablePointValue size;
private final AnimatableFloatValue cornerRadius;
private RectangleShape(String name, AnimatableValue<PointF, PointF> position,
AnimatablePointValue size, AnimatableFloatValue cornerRadius) {
this.name = name;
this.position = position;
this.size = size;
this.cornerRadius = cornerRadius;
}
static class Factory {
private Factory() {
}
static RectangleShape newInstance(JSONObject json, LottieComposition composition) {
return new RectangleShape(
json.optString("nm"),
AnimatablePathValue.createAnimatablePathOrSplitDimensionPath(
json.optJSONObject("p"), composition),
AnimatablePointValue.Factory.newInstance(json.optJSONObject("s"), composition),
AnimatableFloatValue.Factory.newInstance(json.optJSONObject("r"), composition));
}
}
public String getName() {
return name;
}
public AnimatableFloatValue getCornerRadius() {
return cornerRadius;
}
public AnimatablePointValue getSize() {
return size;
}
public AnimatableValue<PointF, PointF> getPosition() {
return position;
}
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) {
return new RectangleContent(drawable, layer, this);
}
@Override public String toString() {
return "RectangleShape{position=" + position +
", size=" + size +
'}';
}
}