diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index 8fe06b508f2d0..736b143921a29 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -49,24 +49,24 @@ import java.util.HashMap; import java.util.HashSet; /** - * This lets you create a drawable based on an XML vector graphic - * It can be defined in an XML file with the <vector> element. + * This lets you create a drawable based on an XML vector graphic It can be + * defined in an XML file with the <vector> element. *

* The vector drawable has 6 elements: *

*

*
<vector>
*
The attribute android:trigger defines a state change that - * will drive the animation
+ * will drive the animation *
The attribute android:versionCode defines the version of - * VectorDrawable
+ * VectorDrawable *
<size>
*
Used to defined the intrinsic Width Height size of the drawable using - * android:width and android:height
+ * android:width and android:height *
<viewport>
*
Used to defined the size of the virtual canvas the paths are drawn on. - * The size is defined using the attributes android:viewportHeight - * android:viewportWidth
+ * The size is defined using the attributes android:viewportHeight + * android:viewportWidth *
<group>
*
Defines a "key frame" in the animation if there is only one group the * drawable is static 2D image that has no animation.
@@ -80,7 +80,8 @@ import java.util.HashSet; *
android:fill *
Defines the color to fill the path (none if not present).
*
android:stroke - *
Defines the color to draw the path outline (none if not present).
+ *
Defines the color to draw the path outline (none if not present).
+ * *
android:strokeWidth *
The width a path stroke
*
android:strokeOpacity @@ -98,7 +99,8 @@ import java.util.HashSet; *
android:trimPathEnd *
The fraction of the path to trim from the end from 0 to 1
*
android:trimPathOffset - *
Shift trim region (allows showed region to include the start and end) from 0 to 1
+ *
Shift trim region (allows showed region to include the start and end) + * from 0 to 1
*
android:clipToPath *
Path will set the clip path
*
android:strokeLineCap @@ -135,19 +137,20 @@ import java.util.HashSet; *
android:sequence *
Configures this animation sequence between the named paths.
*
android:limitTo - *
Limits an animation to only interpolate the selected variable - * unlimited, path, rotation, trimPathStart, trimPathEnd, trimPathOffset
+ *
Limits an animation to only interpolate the selected variable unlimited, + * path, rotation, trimPathStart, trimPathEnd, trimPathOffset
*
android:repeatCount *
Number of times to loop this aspect of the animation
*
android:durations - *
The duration of each step in the animation in milliseconds - * Must contain the number of named paths - 1
+ *
The duration of each step in the animation in milliseconds Must contain + * the number of named paths - 1
*
android:startDelay *
*
android:repeatStyle - *
when repeating how does it repeat back and forth or a to b: forward, inAndOut
+ *
when repeating how does it repeat back and forth or a to b: forward, + * inAndOut
*
android:animate - *
linear, accelerate, decelerate, easing
+ *
linear, accelerate, decelerate, easing
*
* */ @@ -193,8 +196,10 @@ public class VectorDrawable extends Drawable { } long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration(); - if (duration == -1) { // if it set to infinite set to 1 hour - duration = DEFAULT_INFINITE_DURATION; // TODO define correct approach for infinite + if (duration == -1) { + // If duration is infinite, set to 1 hour. + // TODO: Define correct approach for infinite. + duration = DEFAULT_INFINITE_DURATION; mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000); mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator()); } @@ -219,7 +224,7 @@ public class VectorDrawable extends Drawable { } /** - * Stops the animation. + * Stops the animation and moves to the end state. */ public void stop() { mVectorState.mBasicAnimator.end(); @@ -255,11 +260,11 @@ public class VectorDrawable extends Drawable { /** * Defines what this animation should do when it reaches the end. This - * setting is applied only when the repeat count is either greater than - * 0 or {@link ValueAnimator#INFINITE}. + * setting is applied only when the repeat count is either greater than 0 or + * {@link ValueAnimator#INFINITE}. * - * @param mode the animation mode, either {@link ValueAnimator#RESTART} - * or {@link ValueAnimator#REVERSE} + * @param mode the animation mode, either {@link ValueAnimator#RESTART} or + * {@link ValueAnimator#REVERSE} */ public void setRepeatMode(int mode) { mVectorState.mBasicAnimator.setRepeatMode(mode); @@ -304,16 +309,16 @@ public class VectorDrawable extends Drawable { return true; } - private void animateForward(){ + private void animateForward() { if (!mVectorState.mBasicAnimator.isStarted()) { - mVectorState.mBasicAnimator.setFloatValues(0,1); + mVectorState.mBasicAnimator.setFloatValues(0, 1); start(); } } - private void animateBackward(){ + private void animateBackward() { if (!mVectorState.mBasicAnimator.isStarted()) { - mVectorState.mBasicAnimator.setFloatValues(.99f,0); + mVectorState.mBasicAnimator.setFloatValues(.99f, 0); start(); } } @@ -347,8 +352,8 @@ public class VectorDrawable extends Drawable { } /** - * Sets padding for this shape, defined by a Rect object. Define the padding in the Rect object - * as: left, top, right, bottom. + * Sets padding for this shape, defined by a Rect object. Define the padding + * in the Rect object as: left, top, right, bottom. */ public void setPadding(Rect padding) { setPadding(padding.left, padding.top, padding.right, padding.bottom); @@ -472,13 +477,14 @@ public class VectorDrawable extends Drawable { currentGroup = new VGroup(); animatedPath.mGroupList.add(currentGroup); noGroupTag = false; - } else if (SHAPE_VECTOR.equals(tagName)) { + } else if (SHAPE_VECTOR.equals(tagName)) { final TypedArray a = res.obtainAttributes(attrs, R.styleable.VectorDrawable); animatedPath.setTrigger(a.getInteger(R.styleable.VectorDrawable_trigger, 0)); // Parsing the version information. // Right now, we only support version "1". - // If the xml didn't specify the version number, the default version is "1". + // If the xml didn't specify the version number, the default + // version is "1". final int versionCode = a.getInt(R.styleable.VectorDrawable_versionCode, 1); if (versionCode != 1) { throw new IllegalArgumentException( @@ -499,22 +505,22 @@ public class VectorDrawable extends Drawable { tag.append(SHAPE_SIZE); } - if (noViewportTag){ - if (tag.length()>0) { + if (noViewportTag) { + if (tag.length() > 0) { tag.append(" & "); } tag.append(SHAPE_SIZE); } - if (noGroupTag){ - if (tag.length()>0) { + if (noGroupTag) { + if (tag.length() > 0) { tag.append(" & "); } tag.append(SHAPE_GROUP); } - if (noPathTag){ - if (tag.length()>0) { + if (noPathTag) { + if (tag.length() > 0) { tag.append(" or "); } tag.append(SHAPE_PATH); @@ -533,7 +539,8 @@ public class VectorDrawable extends Drawable { long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration(); if (duration == -1) { // if it set to infinite set to 1 hour - duration = DEFAULT_INFINITE_DURATION; // TODO define correct approach for infinite + duration = DEFAULT_INFINITE_DURATION; // TODO define correct + // approach for infinite mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000); mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator()); }