Package com.airbnb.lottie.model
Class KeyPath
- java.lang.Object
-
- com.airbnb.lottie.model.KeyPath
-
public class KeyPath extends java.lang.ObjectDefines which content to target. The keypath can contain wildcards ('*') with match exactly 1 item. or globstars ('**') which match 0 or more items. or KeyPath.COMPOSITION to represent the root composition layer. For example, if your content were arranged like this: Gabriel (Shape Layer) Body (Shape Group) Left Hand (Shape) Fill (Fill) Transform (Transform) ... Brandon (Shape Layer) Body (Shape Group) Left Hand (Shape) Fill (Fill) Transform (Transform) ... You could: Match Gabriel left hand fill: new KeyPath("Gabriel", "Body", "Left Hand", "Fill"); Match Gabriel and Brandon's left hand fill: new KeyPath("*", "Body", Left Hand", "Fill"); Match anything with the name Fill: new KeyPath("**", "Fill"); Target the the root composition layer: KeyPath.COMPOSITION NOTE: Content that are part of merge paths or repeaters cannot currently be resolved with aKeyPath. This may be fixed in the future.
-
-
Field Summary
Fields Modifier and Type Field Description static KeyPathCOMPOSITIONA singleton KeyPath that targets on the root composition layer.
-
Constructor Summary
Constructors Constructor Description KeyPath(java.lang.String... keys)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyPathaddKey(java.lang.String key)Returns a new KeyPath with the key added.booleanfullyResolvesTo(java.lang.String key, int depth)Returns whether the key at specified depth is fully specific enough to match the full set of keys in this keypath.KeyPathElementgetResolvedElement()Returns aKeyPathElementthat this has been resolved to.intincrementDepthBy(java.lang.String key, int depth)For a given key and depth, returns how much the depth should be incremented by when resolving a keypath to children.java.lang.StringkeysToString()booleanmatches(java.lang.String key, int depth)Returns whether they key matches at the specified depth.booleanpropagateToChildren(java.lang.String key, int depth)Returns whether the keypath resolution should propagate to children.KeyPathresolve(KeyPathElement element)Return a new KeyPath with the element resolved to the specifiedKeyPathElement.java.lang.StringtoString()
-
-
-
Field Detail
-
COMPOSITION
public static final KeyPath COMPOSITION
A singleton KeyPath that targets on the root composition layer. This is useful if you want to apply transformer to the animation as a whole.
-
-
Method Detail
-
addKey
@CheckResult public KeyPath addKey(java.lang.String key)
Returns a new KeyPath with the key added. This is used during keypath resolution. Children normally don't know about all of their parent elements so this is used to keep track of the fully qualified keypath. This returns a key keypath because during resolution, the full keypath element tree is walked and if this modified the original copy, it would remain after popping back up the element tree.
-
resolve
public KeyPath resolve(KeyPathElement element)
Return a new KeyPath with the element resolved to the specifiedKeyPathElement.
-
getResolvedElement
@Nullable public KeyPathElement getResolvedElement()
Returns aKeyPathElementthat this has been resolved to. KeyPaths get resolved with resolveKeyPath on LottieDrawable or LottieAnimationView.
-
matches
public boolean matches(java.lang.String key, int depth)Returns whether they key matches at the specified depth.
-
incrementDepthBy
public int incrementDepthBy(java.lang.String key, int depth)For a given key and depth, returns how much the depth should be incremented by when resolving a keypath to children. This can be 0 or 2 when there is a globstar and the next key either matches or doesn't match the current key.
-
fullyResolvesTo
public boolean fullyResolvesTo(java.lang.String key, int depth)Returns whether the key at specified depth is fully specific enough to match the full set of keys in this keypath.
-
propagateToChildren
public boolean propagateToChildren(java.lang.String key, int depth)Returns whether the keypath resolution should propagate to children. Some keypaths resolve to content other than leaf contents (such as a layer or content group transform) so sometimes this will return false.
-
keysToString
public java.lang.String keysToString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-