text:
package androidx.constraintlayout.motion.widget;

import static androidx.constraintlayout.motion.widget.Key.UNSET;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;

import androidx.constraintlayout.core.motion.utils.CurveFit;
import androidx.constraintlayout.core.motion.utils.Easing;
import androidx.constraintlayout.core.motion.utils.KeyCache;
import androidx.constraintlayout.core.motion.utils.SplineSet;
import androidx.constraintlayout.core.motion.utils.VelocityMatrix;
import androidx.constraintlayout.motion.utils.CustomSupport;
import androidx.constraintlayout.motion.utils.ViewOscillator;
import androidx.constraintlayout.motion.utils.ViewSpline;
import androidx.constraintlayout.motion.utils.ViewState;
import androidx.constraintlayout.motion.utils.ViewTimeCycle;
import androidx.constraintlayout.widget.ConstraintAttribute;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;

/**
 * This contains the picture of a view through the a transition and is used to interpolate it
 * During an transition every view has a MotionController which drives its position.
 * <p>
 * All parameter which affect a views motion are added to MotionController and then setup()
 * builds out the splines that control the view.
 *
 *
 */
public class MotionController {
    public static final int PATH_PERCENT = 0;
    public static final int PATH_PERPENDICULAR = 1;
    public static final int HORIZONTAL_PATH_X = 2;
    public static final int HORIZONTAL_PATH_Y = 3;
    public static final int VERTICAL_PATH_X = 4;
    public static final int VERTICAL_PATH_Y = 5;
    public static final int DRAW_PATH_NONE = 0;
    public static final int DRAW_PATH_BASIC = 1;
    public static final int DRAW_PATH_RELATIVE = 2;
    public static final int DRAW_PATH_CARTESIAN = 3;
    public static final int DRAW_PATH_AS_CONFIGURED = 4;
    public static final int DRAW_PATH_RECTANGLE = 5;
    public static final int DRAW_PATH_SCREEN = 6;

    public static final int ROTATION_RIGHT = 1;
    public static final int ROTATION_LEFT = 2;
    Rect mTempRect = new Rect(); // for efficiency

    private static final String TAG = "MotionController";
    private static final boolean DEBUG = false;
    private static final boolean FAVOR_FIXED_SIZE_VIEWS = false;
    View mView;
    int mId;
    boolean mForceMeasure = false;
    String mConstraintTag;
    private int mCurveFitType = KeyFrames.UNSET;
    private MotionPaths mStartMotionPath = new MotionPaths();
    private MotionPaths mEndMotionPath = new MotionPaths();

    private MotionConstrainedPoint mStartPoint = new MotionConstrainedPoint();
    private MotionConstrainedPoint mEndPoint = new MotionConstrainedPoint();

    private CurveFit[] mSpline; // spline 0 is the one that process all the standard attributes
    private CurveFit mArcSpline;
    float mMotionStagger = Float.NaN;
    float mStaggerOffset = 0;
    float mStaggerScale = 1.0f;
    float mCurrentCenterX, mCurrentCenterY;
    private int[] mInterpolateVariables;
    private double[] mInterpolateData; // scratch data created during setup
    private double[] mInterpolateVelocity; // scratch data created during setup

    private String[] mAttributeNames;  // the names of the custom attributes
    private int[] mAttributeInterpolatorCount; // how many interpolators for each custom attribute
    private int mMaxDimension = 4;
    private float []mValuesBuff = new float[mMaxDimension];
    private ArrayList<MotionPaths> mMotionPaths = new ArrayList<>();
    private float[] mVelocity = new float[1]; // used as a temp buffer to return values

    private ArrayList<Key> mKeyList = new ArrayList<>(); // List of key frame items
    private HashMap<String, ViewTimeCycle> mTimeCycleAttributesMap; // splines for use TimeCycles
    private HashMap<String, ViewSpline> mAttributesMap; // splines to calculate values of attributes
    private HashMap<String, ViewOscillator> mCycleMap; // splines to calculate values of attributes
    private KeyTrigger[] mKeyTriggers; // splines to calculate values of attributes
    private int mPathMotionArc = UNSET;
    private int mTransformPivotTarget = UNSET; // if set, pivot point is set to the other object
    private View mTransformPivotView = null; // if set, pivot point is set to the other object
    private int mQuantizeMotionSteps = UNSET;
    private float mQuantizeMotionPhase = Float.NaN;
    private Interpolator mQuantizeMotionInterpolator = null;
    private boolean mNoMovement = false;

    /**
     * Get the view to pivot around
     *
     * @return id of view or UNSET if not set
     */
    public int getTransformPivotTarget() {
        return mTransformPivotTarget;
    }

    /**
     * Set a view to pivot around
     *
     * @param transformPivotTarget id of view
     */
    public void setTransformPivotTarget(int transformPivotTarget) {
        mTransformPivotTarget = transformPivotTarget;
        mTransformPivotView = null;
    }

    MotionPaths getKeyFrame(int i) {
        return mMotionPaths.get(i);
    }

    MotionController(View view) {
        setView(view);
    }

    /**
     * get the left most position of the widget at the start of the movement.
     *
     * @return the left most position
     */
    public float getStartX() {
        return mStartMotionPath.mX;
    }

    /**
     * get the top most position of the widget at the start of the movement.
     * Positive is down.
     *
     * @return the top most position
     */
    public float getStartY() {
        return mStartMotionPath.mY;
    }

    /**
     * get the left most position of the widget at the end of the movement.
     *
     * @return the left most position
     */
    public float getFinalX() {
        return mEndMotionPath.mX;
    }

    /**
     * get the top most position of the widget at the end of the movement.
     * Positive is down.
     *
     * @return the top most position
     */
    public float getFinalY() {
        return mEndMotionPath.mY;
    }

    /**
     * get the width of the widget at the start of the movement.
     *
     * @return the width at the start
     */
    public float getStartWidth() {
        return mStartMotionPath.mWidth;
    }

    /**
     * get the width of the widget at the start of the movement.
     *
     * @return the height at the start
     */
    public float getStartHeight() {
        return mStartMotionPath.mHeight;
    }

    /**
     * get the width of the widget at the end of the movement.
     *
     * @return the width at the end
     */
    public float getFinalWidth() {
        return mEndMotionPath.mWidth;
    }

    /**
     * get the width of the widget at the end of the movement.
     *
     * @return the height at the end
     */
    public float getFinalHeight() {
        return mEndMotionPath.mHeight;
    }

    /**
     * Will return the id of the view to move relative to
     * The position at the start and then end will be viewed relative to this view
     * -1 is the return value if NOT in polar mode
     *
     * @return the view id of the view this is in polar mode to or -1 if not in polar
     */
    public int getAnimateRelativeTo() {
        return mStartMotionPath.mAnimateRelativeTo;
    }

    /**
     * This ties one motionController to another to allow relative pathes
     * @param motionController
     */
    public void setupRelative(MotionController motionController) {
        mStartMotionPath.setupRelative(motionController, motionController.mStartMotionPath);
        mEndMotionPath.setupRelative(motionController, motionController.mEndMotionPath);
    }

    /**
     * Get the center X of the motion at the current progress
     * @return
     */
    public float getCenterX() {
        return mCurrentCenterX;
    }

    /**
     * Get the center Y of the motion at the current progress
     * @return
     */
    public float getCenterY() {
        return mCurrentCenterY;
    }

    /**
     * Get a center and velocities at the position p
     * @param p
     * @param pos
     * @param vel
     */
    public void getCenter(double p, float[] pos, float[] vel) {
        double[] position = new double[4];
        double[] velocity = new double[4];
        @SuppressWarnings("unused") int[] temp = new int[4];
        mSpline[0].getPos(p, position);
        mSpline[0].getSlope(p, velocity);
        Arrays.fill(vel, 0);
        mStartMotionPath.getCenter(p, mInterpolateVariables, position, pos, velocity, vel);
    }

    /**
     * During the next layout call measure then layout
     */
    public void remeasure() {
        mForceMeasure = true;
    }

    /**
     * fill the array point with the center coordinates point[0] is filled with the
     * x coordinate of "time" 0.0 mPoints[point.length-1] is filled with the y coordinate of "time"
     * 1.0
     *
     * @param points     array to fill (should be 2x the number of mPoints
     * @param pointCount
     * @return number of key frames
     */
    void buildPath(float[] points, int pointCount) {
        float mils = 1.0f / (pointCount - 1);
        SplineSet trans_x = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_X);
        SplineSet trans_y = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_Y);
        ViewOscillator osc_x = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_X);
        ViewOscillator osc_y = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_Y);

        for (int i = 0; i < pointCount; i++) {
            float position = i * mils;
            if (mStaggerScale != 1.0f) {
                if (position < mStaggerOffset) {
                    position = 0;
                }
                if (position > mStaggerOffset && position < 1.0) {
                    position -= mStaggerOffset;
                    position *= mStaggerScale;
                    position = Math.min(position, 1.0f);
                }
            }
            double p = position;

            Easing easing = mStartMotionPath.mKeyFrameEasing;
            float start = 0;
            float end = Float.NaN;
            for (MotionPaths frame : mMotionPaths) {
                if (frame.mKeyFrameEasing != null) { // this frame has an easing
                    if (frame.mTime < position) {  // frame with easing is before the current pos
                        easing = frame.mKeyFrameEasing; // this is the candidate
                        start = frame.mTime; // this is also the starting time
                    } else { // frame with easing is past the pos
                        if (Float.isNaN(end)) { // we never ended the time line
                            end = frame.mTime;
                        }
                    }
                }
            }

            if (easing != null) {
                if (Float.isNaN(end)) {
                    end = 1.0f;
                }
                float offset = (position - start) / (end - start);
                offset = (float) easing.get(offset);
                p = offset * (end - start) + start;

            }

            mSpline[0].getPos(p, mInterpolateData);
            if (mArcSpline != null) {
                if (mInterpolateData.length > 0) {
                    mArcSpline.getPos(p, mInterpolateData);
                }
            }
            mStartMotionPath.getCenter(p, mInterpolateVariables, mInterpolateData,
                    points, i * 2);

            if (osc_x != null) {
                points[i * 2] += osc_x.get(position);
            } else if (trans_x != null) {
                points[i * 2] += trans_x.get(position);
            }
            if (osc_y != null) {
                points[i * 2 + 1] += osc_y.get(position);
            } else if (trans_y != null) {
                points[i * 2 + 1] += trans_y.get(position);
            }
        }
    }

    double[] getPos(double position) {
        mSpline[0].getPos(position, mInterpolateData);
        if (mArcSpline != null) {
            if (mInterpolateData.length > 0) {
                mArcSpline.getPos(position, mInterpolateData);
            }
        }
        return mInterpolateData;
    }

    /**
     * fill the array point with the center coordinates point[0] is filled with the
     * x coordinate of "time" 0.0 mPoints[point.length-1] is filled with the y coordinate of "time"
     * 1.0
     *
     * @param bounds     array to fill (should be 2x the number of mPoints
     * @param pointCount
     * @return number of key frames
     */
    void buildBounds(float[] bounds, int pointCount) {
        float mils = 1.0f / (pointCount - 1);
        @SuppressWarnings("unused")
        SplineSet trans_x = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_X);
        @SuppressWarnings("unused")
        SplineSet trans_y = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_Y);
        @SuppressWarnings("unused")
        ViewOscillator osc_x = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_X);
        @SuppressWarnings("unused")
        ViewOscillator osc_y = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_Y);

        for (int i = 0; i < pointCount; i++) {
            float position = i * mils;
            if (mStaggerScale != 1.0f) {
                if (position < mStaggerOffset) {
                    position = 0;
                }
                if (position > mStaggerOffset && position < 1.0) {
                    position -= mStaggerOffset;
                    position *= mStaggerScale;
                    position = Math.min(position, 1.0f);
                }
            }
            double p = position;

            Easing easing = mStartMotionPath.mKeyFrameEasing;
            float start = 0;
            float end = Float.NaN;
            for (MotionPaths frame : mMotionPaths) {
                if (frame.mKeyFrameEasing != null) { // this frame has an easing
                    if (frame.mTime < position) {  // frame with easing is before the current pos
                        easing = frame.mKeyFrameEasing; // this is the candidate
                        start = frame.mTime; // this is also the starting time
                    } else { // frame with easing is past the pos
                        if (Float.isNaN(end)) { // we never ended the time line
                            end = frame.mTime;
                        }
                    }
                }
            }

            if (easing != null) {
                if (Float.isNaN(end)) {
                    end = 1.0f;
                }
                float offset = (position - start) / (end - start);
                offset = (float) easing.get(offset);
                p = offset * (end - start) + start;

            }

            mSpline[0].getPos(p, mInterpolateData);
            if (mArcSpline != null) {
                if (mInterpolateData.length > 0) {
                    mArcSpline.getPos(p, mInterpolateData);
                }
            }
            mStartMotionPath.getBounds(mInterpolateVariables, mInterpolateData, bounds, i * 2);
        }
    }

    private float getPreCycleDistance() {
        int pointCount = 100;
        float[] points = new float[2];
        float sum = 0;
        float mils = 1.0f / (pointCount - 1);
        double x = 0, y = 0;
        for (int i = 0; i < pointCount; i++) {
            float position = i * mils;

            double p = position;

            Easing easing = mStartMotionPath.mKeyFrameEasing;
            float start = 0;
            float end = Float.NaN;
            for (MotionPaths frame : mMotionPaths) {
                if (frame.mKeyFrameEasing != null) { // this frame has an easing
                    if (frame.mTime < position) {  // frame with easing is before the current pos
                        easing = frame.mKeyFrameEasing; // this is the candidate
                        start = frame.mTime; // this is also the starting time
                    } else { // frame with easing is past the pos
                        if (Float.isNaN(end)) { // we never ended the time line
                            end = frame.mTime;
                        }
                    }
                }
            }

            if (easing != null) {
                if (Float.isNaN(end)) {
                    end = 1.0f;
                }
                float offset = (position - start) / (end - start);
                offset = (float) easing.get(offset);
                p = offset * (end - start) + start;

            }

            mSpline[0].getPos(p, mInterpolateData);
            mStartMotionPath.getCenter(p, mInterpolateVariables, mInterpolateData, points, 0);
            if (i > 0) {
                sum += (float) Math.hypot(y - points[1], x - points[0]);
            }
            x = points[0];
            y = points[1];
        }
        return sum;
    }

    KeyPositionBase getPositionKeyframe(int layoutWidth, int layoutHeight, float x, float y) {
        RectF start = new RectF();
        start.left = mStartMotionPath.mX;
        start.top = mStartMotionPath.mY;
        start.right = start.left + mStartMotionPath.mWidth;
        start.bottom = start.top + mStartMotionPath.mHeight;
        RectF end = new RectF();
        end.left = mEndMotionPath.mX;
        end.top = mEndMotionPath.mY;
        end.right = end.left + mEndMotionPath.mWidth;
        end.bottom = end.top + mEndMotionPath.mHeight;
        for (Key key : mKeyList) {
            if (key instanceof KeyPositionBase) {
                if (((KeyPositionBase) key).intersects(layoutWidth, layoutHeight,
                        start, end, x, y)) {
                    return (KeyPositionBase) key;
                }
            }
        }
        return null;
    }

    int buildKeyFrames(float[] keyFrames, int[] mode) {
        if (keyFrames != null) {
            int count = 0;
            double[] time = mSpline[0].getTimePoints();
            if (mode != null) {
                for (MotionPaths keyFrame : mMotionPaths) {
                    mode[count++] = keyFrame.mMode;
                }
                count = 0;
            }

            for (int i = 0; i < time.length; i++) {
                mSpline[0].getPos(time[i], mInterpolateData);
                mStartMotionPath.getCenter(time[i], mInterpolateVariables, mInterpolateData,
                        keyFrames, count);
                count += 2;
            }
            return count / 2;
        }
        return 0;
    }

    int buildKeyBounds(float[] keyBounds, int[] mode) {
        if (keyBounds != null) {
            int count = 0;
            double[] time = mSpline[0].getTimePoints();
            if (mode != null) {
                for (MotionPaths keyFrame : mMotionPaths) {
                    mode[count++] = keyFrame.mMode;
                }
                count = 0;
            }

            for (int i = 0; i < time.length; i++) {
                mSpline[0].getPos(time[i], mInterpolateData);
                mStartMotionPath.getBounds(mInterpolateVariables, mInterpolateData,
                        keyBounds, count);
                count += 2;
            }
            return count / 2;
        }
        return 0;
    }

    String[] mAttributeTable;

    int getAttributeValues(String attributeType, float[] points, int pointCount) {
        @SuppressWarnings("unused") float mils = 1.0f / (pointCount - 1);
        SplineSet spline = mAttributesMap.get(attributeType);
        if (spline == null) {
            return -1;
        }
        for (int j = 0; j < points.length; j++) {
            points[j] = spline.get(j / (points.length - 1));
        }
        return points.length;
    }

    void buildRect(float p, float[] path, int offset) {
        p = getAdjustedPosition(p, null);
        mSpline[0].getPos(p, mInterpolateData);
        mStartMotionPath.getRect(mInterpolateVariables, mInterpolateData, path, offset);
    }

    void buildRectangles(float[] path, int pointCount) {
        float mils = 1.0f / (pointCount - 1);
        for (int i = 0; i < pointCount; i++) {
            float position = i * mils;
            position = getAdjustedPosition(position, null);
            mSpline[0].getPos(position, mInterpolateData);
            mStartMotionPath.getRect(mInterpolateVariables, mInterpolateData, path, i * 8);
        }
    }

    float getKeyFrameParameter(int type, float x, float y) {

        float dx = mEndMotionPath.mX - mStartMotionPath.mX;
        float dy = mEndMotionPath.mY - mStartMotionPath.mY;
        float startCenterX = mStartMotionPath.mX + mStartMotionPath.mWidth / 2;
        float startCenterY = mStartMotionPath.mY + mStartMotionPath.mHeight / 2;
        float hypotenuse = (float) Math.hypot(dx, dy);
        if (hypotenuse < 0.0000001) {
            return Float.NaN;
        }

        float vx = x - startCenterX;
        float vy = y - startCenterY;
        float distFromStart = (float) Math.hypot(vx, vy);
        if (distFromStart == 0) {
            return 0;
        }
        float pathDistance = (vx * dx + vy * dy);

        switch (type) {
            case PATH_PERCENT:
                return pathDistance / hypotenuse;
            case PATH_PERPENDICULAR:
                return (float) Math.sqrt(hypotenuse * hypotenuse - pathDistance * pathDistance);
            case HORIZONTAL_PATH_X:
                return vx / dx;
            case HORIZONTAL_PATH_Y:
                return vy / dx;
            case VERTICAL_PATH_X:
                return vx / dy;
            case VERTICAL_PATH_Y:
                return vy / dy;
        }
        return 0;
    }

    private void insertKey(MotionPaths point) {
        int pos = Collections.binarySearch(mMotionPaths, point);
        if (pos == 0) {
            Log.e(TAG, " KeyPath position \"" + point.mPosition + "\" outside of range");
        }
        mMotionPaths.add(-pos - 1, point);
    }

    void addKeys(ArrayList<Key> list) {
        mKeyList.addAll(list);
        if (DEBUG) {
            for (Key key : mKeyList) {
                Log.v(TAG, " ################ set = " + key.getClass().getSimpleName());
            }
        }
    }

    /**
     * Add a key to the MotionController
     * @param key
     */
    public void addKey(Key key) {
        mKeyList.add(key);
        if (DEBUG) {
            Log.v(TAG, " ################ addKey = " + key.getClass().getSimpleName());
        }
    }

    public void setPathMotionArc(int arc) {
        mPathMotionArc = arc;
    }

    /**
     * Called after all TimePoints & Cycles have been added;
     * Spines are evaluated
     */
    public void setup(int parentWidth,
                      int parentHeight,
                      float transitionDuration,
                      long currentTime) {
        HashSet<String> springAttributes = new HashSet<>(); // attributes we need to interpolate
        HashSet<String> timeCycleAttributes = new HashSet<>(); // attributes we need to interpolate
        HashSet<String> splineAttributes = new HashSet<>(); // attributes we need to interpolate
        HashSet<String> cycleAttributes = new HashSet<>(); // attributes we need to oscillate
        HashMap<String, Integer> interpolation = new HashMap<>();
        ArrayList<KeyTrigger> triggerList = null;
        if (DEBUG) {
            if (mKeyList == null) {
                Log.v(TAG, ">>>>>>>>>>>>>>> mKeyList==null");

            } else {
                Log.v(TAG, ">>>>>>>>>>>>>>> mKeyList for " + Debug.getName(mView));

            }
        }

        if (mPathMotionArc != UNSET) {
            mStartMotionPath.mPathMotionArc = mPathMotionArc;
        }

        mStartPoint.different(mEndPoint, splineAttributes);
        if (DEBUG) {
            HashSet<String> attr = new HashSet<>();
            mStartPoint.different(mEndPoint, attr);
            Log.v(TAG, ">>>>>>>>>>>>>>> MotionConstrainedPoint found "
                    + Arrays.toString(attr.toArray()));
        }
        if (mKeyList != null) {
            for (Key key : mKeyList) {
                if (key instanceof KeyPosition) {
                    KeyPosition keyPath = (KeyPosition) key;
                    insertKey(new MotionPaths(parentWidth, parentHeight, keyPath,
                            mStartMotionPath, mEndMotionPath));
                    if (keyPath.mCurveFit != UNSET) {
                        mCurveFitType = keyPath.mCurveFit;
                    }
                } else if (key instanceof KeyCycle) {
                    key.getAttributeNames(cycleAttributes);
                } else if (key instanceof KeyTimeCycle) {
                    key.getAttributeNames(timeCycleAttributes);
                } else if (key instanceof KeyTrigger) {
                    if (triggerList == null) {
                        triggerList = new ArrayList<>();
                    }
                    triggerList.add((KeyTrigger) key);
                } else {
                    key.setInterpolation(interpolation);
                    key.getAttributeNames(splineAttributes);
                }
            }
        }

        //--------------------------- trigger support --------------------

        if (triggerList != null) {
            mKeyTriggers = triggerList.toArray(new KeyTrigger[0]);
        }

        if (DEBUG) {
            if (!cycleAttributes.isEmpty()) {
                Log.v(TAG, ">>>>>>>>>>>>>>>>  found cycleA"
                        + Debug.getName(mView) + " cycles     "
                        + Arrays.toString(cycleAttributes.toArray()));
            }
            if (!splineAttributes.isEmpty()) {
                Log.v(TAG, ">>>>>>>>>>>>>>>>  found spline "
                        + Debug.getName(mView) + " attrs      "
                        + Arrays.toString(splineAttributes.toArray()));
            }
            if (!timeCycleAttributes.isEmpty()) {
                Log.v(TAG, ">>>>>>>>>>>>>>>>  found timeCycle "
                        + Debug.getName(mView) + " attrs      "
                        + Arrays.toString(timeCycleAttributes.toArray()));
            }
            if (!springAttributes.isEmpty()) {
                Log.v(TAG, ">>>>>>>>>>>>>>>>  found springs "
                        + Debug.getName(mView) + " attrs      "
                        + Arrays.toString(springAttributes.toArray()));
            }

        }

        //--------------------------- splines support --------------------
        if (!splineAttributes.isEmpty()) {
            mAttributesMap = new HashMap<>();
            for (String attribute : splineAttributes) {
                ViewSpline splineSets;
                if (attribute.startsWith("CUSTOM,")) {
                    SparseArray<ConstraintAttribute> attrList = new SparseArray<>();
                    String customAttributeName = attribute.split(",")[1];
                    for (Key key : mKeyList) {
                        if (key.mCustomConstraints == null) {
                            continue;
                        }
                        ConstraintAttribute customAttribute =
                                key.mCustomConstraints.get(customAttributeName);
                        if (customAttribute != null) {
                            attrList.append(key.mFramePosition, customAttribute);
                        }
                    }
                    splineSets = ViewSpline.makeCustomSpline(attribute, attrList);
                } else {
                    splineSets = ViewSpline.makeSpline(attribute);
                }
                if (splineSets == null) {
                    continue;
                }
                splineSets.setType(attribute);
                mAttributesMap.put(attribute, splineSets);
            }
            if (mKeyList != null) {
                for (Key key : mKeyList) {
                    if ((key instanceof KeyAttributes)) {
                        key.addValues(mAttributesMap);
                    }
                }
            }
            mStartPoint.addValues(mAttributesMap, 0);
            mEndPoint.addValues(mAttributesMap, 100);

            for (String spline : mAttributesMap.keySet()) {
                int curve = CurveFit.SPLINE; // default is SPLINE
                if (interpolation.containsKey(spline)) {
                    Integer boxedCurve = interpolation.get(spline);
                    if (boxedCurve != null) {
                        curve = boxedCurve;
                    }
                }
                SplineSet splineSet = mAttributesMap.get(spline);
                if (splineSet != null) {
                    splineSet.setup(curve);
                }
            }
        }

        //--------------------------- timeCycle support --------------------
        if (!timeCycleAttributes.isEmpty()) {
            if (mTimeCycleAttributesMap == null) {
                mTimeCycleAttributesMap = new HashMap<>();
            }
            for (String attribute : timeCycleAttributes) {
                if (mTimeCycleAttributesMap.containsKey(attribute)) {
                    continue;
                }

                ViewTimeCycle splineSets = null;
                if (attribute.startsWith("CUSTOM,")) {
                    SparseArray<ConstraintAttribute> attrList = new SparseArray<>();
                    String customAttributeName = attribute.split(",")[1];
                    for (Key key : mKeyList) {
                        if (key.mCustomConstraints == null) {
                            continue;
                        }
                        ConstraintAttribute customAttribute =
                                key.mCustomConstraints.get(customAttributeName);
                        if (customAttribute != null) {
                            attrList.append(key.mFramePosition, customAttribute);
                        }
                    }
                    splineSets = ViewTimeCycle.makeCustomSpline(attribute, attrList);
                } else {
                    splineSets = ViewTimeCycle.makeSpline(attribute, currentTime);

                }
                if (splineSets == null) {
                    continue;
                }
                splineSets.setType(attribute);
                mTimeCycleAttributesMap.put(attribute, splineSets);
            }

            if (mKeyList != null) {
                for (Key key : mKeyList) {
                    if (key instanceof KeyTimeCycle) {
                        ((KeyTimeCycle) key).addTimeValues(mTimeCycleAttributesMap);
                    }
                }
            }

            for (String spline : mTimeCycleAttributesMap.keySet()) {
                int curve = CurveFit.SPLINE; // default is SPLINE
                if (interpolation.containsKey(spline)) {
                    curve = interpolation.get(spline);
                }
                mTimeCycleAttributesMap.get(spline).setup(curve);
            }
        }

        //--------------------------------- end new key frame 2

        MotionPaths[] points = new MotionPaths[2 + mMotionPaths.size()];
        int count = 1;
        points[0] = mStartMotionPath;
        points[points.length - 1] = mEndMotionPath;
        if (mMotionPaths.size() > 0 && mCurveFitType == KeyFrames.UNSET) {
            mCurveFitType = CurveFit.SPLINE;
        }
        for (MotionPaths point : mMotionPaths) {
            points[count++] = point;
        }

        // -----  setup custom attributes which must be in the start and end constraint sets
        int variables = 18;
        HashSet<String> attributeNameSet = new HashSet<>();
        for (String s : mEndMotionPath.mAttributes.keySet()) {
            if (mStartMotionPath.mAttributes.containsKey(s)) {
                if (!splineAttributes.contains("CUSTOM," + s)) {
                    attributeNameSet.add(s);
                }
            }
        }

        mAttributeNames = attributeNameSet.toArray(new String[0]);
        mAttributeInterpolatorCount = new int[mAttributeNames.length];
        for (int i = 0; i < mAttributeNames.length; i++) {
            String attributeName = mAttributeNames[i];
            mAttributeInterpolatorCount[i] = 0;
            for (int j = 0; j < points.length; j++) {
                if (points[j].mAttributes.containsKey(attributeName)) {
                    ConstraintAttribute attribute = points[j].mAttributes.get(attributeName);
                    if (attribute != null) {
                        mAttributeInterpolatorCount[i] += attribute.numberOfInterpolatedValues();
                        break;
                    }
                }
            }
        }
        boolean arcMode = points[0].mPathMotionArc != UNSET;
        boolean[] mask = new boolean[variables + mAttributeNames.length]; // defaults to false
        for (int i = 1; i < points.length; i++) {
            points[i].different(points[i - 1], mask, mAttributeNames, arcMode);
        }

        count = 0;
        for (int i = 1; i < mask.length; i++) {
            if (mask[i]) {
                count++;
            }
        }

        mInterpolateVariables = new int[count];
        int varLen = Math.max(2, count);
        mInterpolateData = new double[varLen];
        mInterpolateVelocity = new double[varLen];

        count = 0;
        for (int i = 1; i < mask.length; i++) {
            if (mask[i]) {
                mInterpolateVariables[count++] = i;
            }
        }

        double[][] splineData = new double[points.length][mInterpolateVariables.length];
        double[] timePoint = new double[points.length];

        for (int i = 0; i < points.length; i++) {
            points[i].fillStandard(splineData[i], mInterpolateVariables);
            timePoint[i] = points[i].mTime;
        }

        for (int j = 0; j < mInterpolateVariables.length; j++) {
            int interpolateVariable = mInterpolateVariables[j];
            if (interpolateVariable < MotionPaths.sNames.length) {
                @SuppressWarnings("unused")
                String s = MotionPaths.sNames[mInterpolateVariables[j]] + " [";
                for (int i = 0; i < points.length; i++) {
                    s += splineData[i][j];
                }
            }
        }
        mSpline = new CurveFit[1 + mAttributeNames.length];

        for (int i = 0; i < mAttributeNames.length; i++) {
            int pointCount = 0;
            double[][] splinePoints = null;
            double[] timePoints = null;
            String name = mAttributeNames[i];

            for (int j = 0; j < points.length; j++) {
                if (points[j].hasCustomData(name)) {
                    if (splinePoints == null) {
                        timePoints = new double[points.length];
                        splinePoints =
                                new double[points.length][points[j].getCustomDataCount(name)];
                    }
                    timePoints[pointCount] = points[j].mTime;
                    points[j].getCustomData(name, splinePoints[pointCount], 0);
                    pointCount++;
                }
            }
            timePoints = Arrays.copyOf(timePoints, pointCount);
            splinePoints = Arrays.copyOf(splinePoints, pointCount);
            mSpline[i + 1] = CurveFit.get(mCurveFitType, timePoints, splinePoints);
        }

        mSpline[0] = CurveFit.get(mCurveFitType, timePoint, splineData);
        // --------------------------- SUPPORT ARC MODE --------------
        if (points[0].mPathMotionArc != UNSET) {
            int size = points.length;
            int[] mode = new int[size];
            double[] time = new double[size];
            double[][] values = new double[size][2];
            for (int i = 0; i < size; i++) {
                mode[i] = points[i].mPathMotionArc;
                time[i] = points[i].mTime;
                values[i][0] = points[i].mX;
                values[i][1] = points[i].mY;
            }

            mArcSpline = CurveFit.getArc(mode, time, values);
        }

        //--------------------------- Cycle support --------------------
        float distance = Float.NaN;
        mCycleMap = new HashMap<>();
        if (mKeyList != null) {
            for (String attribute : cycleAttributes) {
                ViewOscillator cycle = ViewOscillator.makeSpline(attribute);
                if (cycle == null) {
                    continue;
                }

                if (cycle.variesByPath()) {
                    if (Float.isNaN(distance)) {
                        distance = getPreCycleDistance();
                    }
                }
                cycle.setType(attribute);
                mCycleMap.put(attribute, cycle);
            }
            for (Key key : mKeyList) {
                if (key instanceof KeyCycle) {
                    ((KeyCycle) key).addCycleValues(mCycleMap);
                }
            }
            for (ViewOscillator cycle : mCycleMap.values()) {
                cycle.setup(distance);
            }
        }

        if (DEBUG) {
            Log.v(TAG, "Animation of splineAttributes "
                    + Arrays.toString(splineAttributes.toArray()));
            Log.v(TAG, "Animation of cycle " + Arrays.toString(mCycleMap.keySet().toArray()));
            if (mAttributesMap != null) {
                Log.v(TAG, " splines = "
                        + Arrays.toString(mAttributesMap.keySet().toArray()));
                for (String s : mAttributesMap.keySet()) {
                    Log.v(TAG, s + " = " + mAttributesMap.get(s));
                }
            }
            Log.v(TAG, " ---------------------------------------- ");
        }

        //--------------------------- end cycle support ----------------
    }

    /**
     * Debug string
     *
     * @return
     */
    @Override
    public String toString() {
        return " start: x: " + mStartMotionPath.mX + " y: " + mStartMotionPath.mY
                + " end: x: " + mEndMotionPath.mX + " y: " + mEndMotionPath.mY;
    }

    private void readView(MotionPaths motionPaths) {
        motionPaths.setBounds((int) mView.getX(), (int) mView.getY(),
                mView.getWidth(), mView.getHeight());
    }

    // @TODO: add description

    /**
     *
     * @param view
     */
    public void setView(View view) {
        mView = view;
        mId = view.getId();
        ViewGroup.LayoutParams lp = view.getLayoutParams();
        if (lp instanceof ConstraintLayout.LayoutParams) {
            mConstraintTag = ((ConstraintLayout.LayoutParams) lp).getConstraintTag();
        }
    }

    /**
     * Get the view that is being controlled
     * @return
     */
    public View getView() {
        return mView;
    }

    void setStartCurrentState(View v) {
        mStartMotionPath.mTime = 0;
        mStartMotionPath.mPosition = 0;
        mStartMotionPath.setBounds(v.getX(), v.getY(), v.getWidth(), v.getHeight());
        mStartPoint.setState(v);
    }

    /**
     * configure the position of the view
     * @param rect
     * @param v
     * @param rotation
     * @param preWidth
     * @param preHeight
     */
    public void setStartState(ViewState rect, View v, int rotation, int preWidth, int preHeight) {
        mStartMotionPath.mTime = 0;
        mStartMotionPath.mPosition = 0;
        int cx, cy;
        Rect r = new Rect();
        switch (rotation) {
            case 2:
                cx = rect.left + rect.right;
                cy = rect.top + rect.bottom;
                r.left = preHeight - (cy + rect.width()) / 2;
                r.top = (cx - rect.height()) / 2;
                r.right = r.left + rect.width();
                r.bottom = r.top + rect.height();
                break;
            case 1:
                cx = rect.left + rect.right;
                cy = rect.top + rect.bottom;
                r.left = (cy - rect.width()) / 2;
                r.top = preWidth - (cx + rect.height()) / 2;
                r.right = r.left + rect.width();
                r.bottom = r.top + rect.height();
                break;
        }
        mStartMotionPath.setBounds(r.left, r.top, r.width(), r.height());
        mStartPoint.setState(r, v, rotation, rect.rotation);
    }

    void rotate(Rect rect, Rect out, int rotation, int preHeight, int preWidth) {
        int cx, cy;
        switch (rotation) {

            case ConstraintSet.ROTATE_PORTRATE_OF_LEFT:
                cx = rect.left + rect.right;
                cy = rect.top + rect.bottom;
                out.left = preHeight - (cy + rect.width()) / 2;
                out.top = (cx - rect.height()) / 2;
                out.right = out.left + rect.width();
                out.bottom = out.top + rect.height();
                break;
            case ConstraintSet.ROTATE_PORTRATE_OF_RIGHT:
                cx = rect.left + rect.right;
                cy = rect.top + rect.bottom;
                out.left = (cy - rect.width()) / 2;
                out.top = preWidth - (cx + rect.height()) / 2;
                out.right = out.left + rect.width();
                out.bottom = out.top + rect.height();
                break;
            case ConstraintSet.ROTATE_LEFT_OF_PORTRATE:
                cx = rect.left + rect.right;
                cy = rect.bottom + rect.top;
                out.left = preHeight - (cy + rect.width()) / 2;
                out.top = (cx - rect.height()) / 2;
                out.right = out.left + rect.width();
                out.bottom = out.top + rect.height();
                break;
            case ConstraintSet.ROTATE_RIGHT_OF_PORTRATE:
                cx = rect.left + rect.right;
                cy = rect.top + rect.bottom;
                out.left = rect.height() / 2 + rect.top - cx / 2;
                out.top = preWidth - (cx + rect.height()) / 2;
                out.right = out.left + rect.width();
                out.bottom = out.top + rect.height();
                break;
        }
    }

    void setStartState(Rect cw, ConstraintSet constraintSet, int parentWidth, int parentHeight) {
        int rotate = constraintSet.mRotate; // for rotated frames
        if (rotate != 0) {
            rotate(cw, mTempRect, rotate, parentWidth, parentHeight);
        }
        mStartMotionPath.mTime = 0;
        mStartMotionPath.mPosition = 0;
        readView(mStartMotionPath);
        mStartMotionPath.setBounds(cw.left, cw.top, cw.width(), cw.height());
        ConstraintSet.Constraint constraint = constraintSet.getParameters(mId);
        mStartMotionPath.applyParameters(constraint);
        mMotionStagger = constraint.motion.mMotionStagger;
        mStartPoint.setState(cw, constraintSet, rotate, mId);
        mTransformPivotTarget = constraint.transform.transformPivotTarget;
        mQuantizeMotionSteps = constraint.motion.mQuantizeMotionSteps;
        mQuantizeMotionPhase = constraint.motion.mQuantizeMotionPhase;
        mQuantizeMotionInterpolator = getInterpolator(mView.getContext(),
                constraint.motion.mQuantizeInterpolatorType,
                constraint.motion.mQuantizeInterpolatorString,
                constraint.motion.mQuantizeInterpolatorID
        );
    }

    static final int EASE_IN_OUT = 0;
    static final int EASE_IN = 1;
    static final int EASE_OUT = 2;
    static final int LINEAR = 3;
    static final int BOUNCE = 4;
    static final int OVERSHOOT = 5;
    private static final int SPLINE_STRING = -1;
    private static final int INTERPOLATOR_REFERENCE_ID = -2;
    private static final int INTERPOLATOR_UNDEFINED = -3;

    private static Interpolator getInterpolator(Context context,
                                                int type,
                                                String interpolatorString,
                                                int id) {
        switch (type) {
            case SPLINE_STRING:
                final Easing easing = Easing.getInterpolator(interpolatorString);
                return new Interpolator() {
                    @Override
                    public float getInterpolation(float v) {
                        return (float) easing.get(v);
                    }
                };
            case INTERPOLATOR_REFERENCE_ID:
                return AnimationUtils.loadInterpolator(context, id);
            case EASE_IN_OUT:
                return new AccelerateDecelerateInterpolator();
            case EASE_IN:
                return new AccelerateInterpolator();
            case EASE_OUT:
                return new DecelerateInterpolator();
            case LINEAR:
                return null;
            case BOUNCE:
                return new BounceInterpolator();
            case OVERSHOOT:
                return new OvershootInterpolator();
            case INTERPOLATOR_UNDEFINED:
                return null;
        }
        return null;
    }

    void setEndState(Rect cw, ConstraintSet constraintSet, int parentWidth, int parentHeight) {
        int rotate = constraintSet.mRotate; // for rotated frames
        if (rotate != 0) {
            rotate(cw, mTempRect, rotate, parentWidth, parentHeight);
            cw = mTempRect;
        }
        mEndMotionPath.mTime = 1;
        mEndMotionPath.mPosition = 1;
        readView(mEndMotionPath);
        mEndMotionPath.setBounds(cw.left, cw.top, cw.width(), cw.height());
        mEndMotionPath.applyParameters(constraintSet.getParameters(mId));
        mEndPoint.setState(cw, constraintSet, rotate, mId);
    }

    void setBothStates(View v) {
        mStartMotionPath.mTime = 0;
        mStartMotionPath.mPosition = 0;
        mNoMovement = true;
        mStartMotionPath.setBounds(v.getX(), v.getY(), v.getWidth(), v.getHeight());
        mEndMotionPath.setBounds(v.getX(), v.getY(), v.getWidth(), v.getHeight());
        mStartPoint.setState(v);
        mEndPoint.setState(v);
    }

    /**
     * Calculates the adjusted (and optional velocity)
     * Note if requesting velocity staggering is not considered
     *
     * @param position position pre stagger
     * @param velocity return velocity
     * @return actual position accounting for easing and staggering
     */
    private float getAdjustedPosition(float position, float[] velocity) {
        if (velocity != null) {
            velocity[0] = 1;
        } else if (mStaggerScale != 1.0) {
            if (position < mStaggerOffset) {
                position = 0;
            }
            if (position > mStaggerOffset && position < 1.0) {
                position -= mStaggerOffset;
                position *= mStaggerScale;
                position = Math.min(position, 1.0f);
            }
        }

        // adjust the position based on the easing curve
        float adjusted = position;
        Easing easing = mStartMotionPath.mKeyFrameEasing;
        float start = 0;
        float end = Float.NaN;
        for (MotionPaths frame : mMotionPaths) {
            if (frame.mKeyFrameEasing != null) { // this frame has an easing
                if (frame.mTime < position) {  // frame with easing is before the current pos
                    easing = frame.mKeyFrameEasing; // this is the candidate
                    start = frame.mTime; // this is also the starting time
                } else { // frame with easing is past the pos
                    if (Float.isNaN(end)) { // we never ended the time line
                        end = frame.mTime;
                    }
                }
            }
        }

        if (easing != null) {
            if (Float.isNaN(end)) {
                end = 1.0f;
            }
            float offset = (position - start) / (end - start);
            float new_offset = (float) easing.get(offset);
            adjusted = new_offset * (end - start) + start;
            if (velocity != null) {
                velocity[0] = (float) easing.getDiff(offset);
            }
        }
        return adjusted;
    }

    void endTrigger(boolean start) {
        if ("button".equals(Debug.getName(mView))) {
            if (mKeyTriggers != null) {
                for (int i = 0; i < mKeyTriggers.length; i++) {
                    mKeyTriggers[i].conditionallyFire(start ? -100 : 100, mView);
                }
            }
        }
    }

    /**
     * The main driver of interpolation
     *
     * @param child
     * @param globalPosition
     * @param time
     * @param keyCache
     * @return do you need to keep animating
     */
    boolean interpolate(View child, float globalPosition, long time, KeyCache keyCache) {
        boolean timeAnimation = false;
        float position = getAdjustedPosition(globalPosition, null);
        // This quantize the position into steps e.g. 4 steps = 0-0.25,0.25-0.50 etc
        if (mQuantizeMotionSteps != UNSET) {
            float steps = 1.0f / mQuantizeMotionSteps; // the length of a step
            float jump = (float) Math.floor(position / steps) * steps; // step jumps
            float section = (position % steps) / steps; // float from 0 to 1 in a step

            if (!Float.isNaN(mQuantizeMotionPhase)) {
                section = (section + mQuantizeMotionPhase) % 1;
            }
            if (mQuantizeMotionInterpolator != null) {
                section = mQuantizeMotionInterpolator.getInterpolation(section);
            } else {
                section = section > 0.5 ? 1 : 0;
            }
            position = section * steps + jump;
        }
        ViewTimeCycle.PathRotate timePathRotate = null;
        if (mAttributesMap != null) {
            for (ViewSpline aSpline : mAttributesMap.values()) {
                aSpline.setProperty(child, position);
            }
        }

        if (mTimeCycleAttributesMap != null) {
            for (ViewTimeCycle aSpline : mTimeCycleAttributesMap.values()) {
                if (aSpline instanceof ViewTimeCycle.PathRotate) {
                    timePathRotate = (ViewTimeCycle.PathRotate) aSpline;
                    continue;
                }
                timeAnimation |= aSpline.setProperty(child, position, time, keyCache);
            }
        }

        if (mSpline != null) {
            mSpline[0].getPos(position, mInterpolateData);
            mSpline[0].getSlope(position, mInterpolateVelocity);
            if (mArcSpline != null) {
                if (mInterpolateData.length > 0) {
                    mArcSpline.getPos(position, mInterpolateData);
                    mArcSpline.getSlope(position, mInterpolateVelocity);
                }
            }

            if (!mNoMovement) {
                mStartMotionPath.setView(position, child,
                        mInterpolateVariables, mInterpolateData, mInterpolateVelocity,
                        null, mForceMeasure);
                mForceMeasure = false;
            }
            if (mTransformPivotTarget != UNSET) {
                if (mTransformPivotView == null) {
                    View layout = (View) child.getParent();
                    mTransformPivotView = layout.findViewById(mTransformPivotTarget);
                }
                if (mTransformPivotView != null) {
                    float cy = (mTransformPivotView.getTop()
                            + mTransformPivotView.getBottom()) / 2.0f;
                    float cx = (mTransformPivotView.getLeft()
                            + mTransformPivotView.getRight()) / 2.0f;
                    if (child.getRight() - child.getLeft() > 0
                            && child.getBottom() - child.getTop() > 0) {
                        float px = (cx - child.getLeft());
                        float py = (cy - child.getTop());
                        child.setPivotX(px);
                        child.setPivotY(py);
                    }
                }
            }

            if (mAttributesMap != null) {
                for (SplineSet aSpline : mAttributesMap.values()) {
                    if (aSpline instanceof ViewSpline.PathRotate
                            && mInterpolateVelocity.length > 1) {
                        ((ViewSpline.PathRotate) aSpline).setPathRotate(child, position,
                                mInterpolateVelocity[0], mInterpolateVelocity[1]);
                    }
                }

            }
            if (timePathRotate != null) {
                timeAnimation |= timePathRotate.setPathRotate(child, keyCache, position, time,
                        mInterpolateVelocity[0], mInterpolateVelocity[1]);
            }

            for (int i = 1; i < mSpline.length; i++) {
                CurveFit spline = mSpline[i];
                spline.getPos(position, mValuesBuff);
                CustomSupport.setInterpolatedValue(mStartMotionPath
                        .mAttributes.get(mAttributeNames[i - 1]), child, mValuesBuff);

            }
            if (mStartPoint.mVisibilityMode == ConstraintSet.VISIBILITY_MODE_NORMAL) {
                if (position <= 0.0f) {
                    child.setVisibility(mStartPoint.mVisibility);
                } else if (position >= 1.0f) {
                    child.setVisibility(mEndPoint.mVisibility);
                } else if (mEndPoint.mVisibility != mStartPoint.mVisibility) {
                    child.setVisibility(View.VISIBLE);
                }
            }

            if (mKeyTriggers != null) {
                for (int i = 0; i < mKeyTriggers.length; i++) {
                    mKeyTriggers[i].conditionallyFire(position, child);
                }
            }
        } else {
            // do the interpolation

            float float_l = (mStartMotionPath.mX
                    + (mEndMotionPath.mX - mStartMotionPath.mX) * position);
            float float_t = (mStartMotionPath.mY
                    + (mEndMotionPath.mY - mStartMotionPath.mY) * position);
            float float_width = (mStartMotionPath.mWidth
                    + (mEndMotionPath.mWidth - mStartMotionPath.mWidth) * position);
            float float_height = (mStartMotionPath.mHeight
                    + (mEndMotionPath.mHeight - mStartMotionPath.mHeight) * position);
            int l = (int) (0.5f + float_l);
            int t = (int) (0.5f + float_t);
            int r = (int) (0.5f + float_l + float_width);
            int b = (int) (0.5f + float_t + float_height);
            int width = r - l;
            int height = b - t;

            if (FAVOR_FIXED_SIZE_VIEWS) {
                l = (int) (mStartMotionPath.mX
                        + (mEndMotionPath.mX - mStartMotionPath.mX) * position);
                t = (int) (mStartMotionPath.mY
                        + (mEndMotionPath.mY - mStartMotionPath.mY) * position);
                width = (int) (mStartMotionPath.mWidth
                        + (mEndMotionPath.mWidth - mStartMotionPath.mWidth) * position);
                height = (int) (mStartMotionPath.mHeight
                        + (mEndMotionPath.mHeight - mStartMotionPath.mHeight) * position);
                r = l + width;
                b = t + height;
            }
            if (mEndMotionPath.mWidth != mStartMotionPath.mWidth
                    || mEndMotionPath.mHeight != mStartMotionPath.mHeight || mForceMeasure) {
                int widthMeasureSpec =
                        View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
                int heightMeasureSpec =
                        View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
                child.measure(widthMeasureSpec, heightMeasureSpec);
                mForceMeasure = false;
            }
            child.layout(l, t, r, b);
        }

        if (mCycleMap != null) {
            for (ViewOscillator osc : mCycleMap.values()) {
                if (osc instanceof ViewOscillator.PathRotateSet) {
                    ((ViewOscillator.PathRotateSet) osc).setPathRotate(child, position,
                            mInterpolateVelocity[0], mInterpolateVelocity[1]);
                } else {
                    osc.setProperty(child, position);
                }
            }
        }
        return timeAnimation;
    }

    /**
     * This returns the differential with respect to the animation layout position (Progress)
     * of a point on the view (post layout effects are not computed)
     *
     * @param position    position in time
     * @param locationX   the x location on the view (0 = left edge, 1 = right edge)
     * @param locationY   the y location on the view (0 = top, 1 = bottom)
     * @param mAnchorDpDt returns the differential of the motion with respect to the position
     */
    void getDpDt(float position, float locationX, float locationY, float[] mAnchorDpDt) {
        position = getAdjustedPosition(position, mVelocity);

        if (mSpline != null) {
            mSpline[0].getSlope(position, mInterpolateVelocity);
            mSpline[0].getPos(position, mInterpolateData);
            float v = mVelocity[0];
            for (int i = 0; i < mInterpolateVelocity.length; i++) {
                mInterpolateVelocity[i] *= v;
            }

            if (mArcSpline != null) {
                if (mInterpolateData.length > 0) {
                    mArcSpline.getPos(position, mInterpolateData);
                    mArcSpline.getSlope(position, mInterpolateVelocity);
                    mStartMotionPath.setDpDt(locationX, locationY, mAnchorDpDt,
                            mInterpolateVariables, mInterpolateVelocity, mInterpolateData);
                }
                return;
            }
            mStartMotionPath.setDpDt(locationX, locationY, mAnchorDpDt,
                    mInterpolateVariables, mInterpolateVelocity, mInterpolateData);
            return;
        }
        // do the interpolation
        float dleft = (mEndMotionPath.mX - mStartMotionPath.mX);
        float dTop = (mEndMotionPath.mY - mStartMotionPath.mY);
        float dWidth = (mEndMotionPath.mWidth - mStartMotionPath.mWidth);
        float dHeight = (mEndMotionPath.mHeight - mStartMotionPath.mHeight);
        float dRight = dleft + dWidth;
        float dBottom = dTop + dHeight;
        mAnchorDpDt[0] = dleft * (1 - locationX) + dRight * locationX;
        mAnchorDpDt[1] = dTop * (1 - locationY) + dBottom * locationY;
    }

    /**
     * This returns the differential with respect to the animation post layout transform
     * of a point on the view
     *
     * @param position    position in time
     * @param width       width of the view
     * @param height      height of the view
     * @param locationX   the x location on the view (0 = left edge, 1 = right edge)
     * @param locationY   the y location on the view (0 = top, 1 = bottom)
     * @param mAnchorDpDt returns the differential of the motion with respect to the position
     */
    void getPostLayoutDvDp(float position,
                           int width,
                           int height,
                           float locationX,
                           float locationY,
                           float[] mAnchorDpDt) {
        if (DEBUG) {
            Log.v(TAG, " position= " + position + " location= "
                    + locationX + " , " + locationY);
        }
        position = getAdjustedPosition(position, mVelocity);

        SplineSet trans_x = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_X);
        SplineSet trans_y = (mAttributesMap == null) ? null : mAttributesMap.get(Key.TRANSLATION_Y);
        SplineSet rotation = (mAttributesMap == null) ? null : mAttributesMap.get(Key.ROTATION);
        SplineSet scale_x = (mAttributesMap == null) ? null : mAttributesMap.get(Key.SCALE_X);
        SplineSet scale_y = (mAttributesMap == null) ? null : mAttributesMap.get(Key.SCALE_Y);

        ViewOscillator osc_x = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_X);
        ViewOscillator osc_y = (mCycleMap == null) ? null : mCycleMap.get(Key.TRANSLATION_Y);
        ViewOscillator osc_r = (mCycleMap == null) ? null : mCycleMap.get(Key.ROTATION);
        ViewOscillator osc_sx = (mCycleMap == null) ? null : mCycleMap.get(Key.SCALE_X);
        ViewOscillator osc_sy = (mCycleMap == null) ? null : mCycleMap.get(Key.SCALE_Y);

        VelocityMatrix vmat = new VelocityMatrix();
        vmat.clear();
        vmat.setRotationVelocity(rotation, position);
        vmat.setTranslationVelocity(trans_x, trans_y, position);
        vmat.setScaleVelocity(scale_x, scale_y, position);
        vmat.setRotationVelocity(osc_r, position);
        vmat.setTranslationVelocity(osc_x, osc_y, position);
        vmat.setScaleVelocity(osc_sx, osc_sy, position);
        if (mArcSpline != null) {
            if (mInterpolateData.length > 0) {
                mArcSpline.getPos(position, mInterpolateData);
                mArcSpline.getSlope(position, mInterpolateVelocity);
                mStartMotionPath.setDpDt(locationX, locationY, mAnchorDpDt,
                        mInterpolateVariables, mInterpolateVelocity, mInterpolateData);
            }
            vmat.applyTransform(locationX, locationY, width, height, mAnchorDpDt);
            return;
        }
        if (mSpline != null) {
            position = getAdjustedPosition(position, mVelocity);
            mSpline[0].getSlope(position, mInterpolateVelocity);
            mSpline[0].getPos(position, mInterpolateData);
            float v = mVelocity[0];
            for (int i = 0; i < mInterpolateVelocity.length; i++) {
                mInterpolateVelocity[i] *= v;
            }
            mStartMotionPath.setDpDt(locationX, locationY, mAnchorDpDt,
                    mInterpolateVariables, mInterpolateVelocity, mInterpolateData);
            vmat.applyTransform(locationX, locationY, width, height, mAnchorDpDt);
            return;
        }

        // do the interpolation
        float dleft = (mEndMotionPath.mX - mStartMotionPath.mX);
        float dTop = (mEndMotionPath.mY - mStartMotionPath.mY);
        float dWidth = (mEndMotionPath.mWidth - mStartMotionPath.mWidth);
        float dHeight = (mEndMotionPath.mHeight - mStartMotionPath.mHeight);
        float dRight = dleft + dWidth;
        float dBottom = dTop + dHeight;
        mAnchorDpDt[0] = dleft * (1 - locationX) + dRight * locationX;
        mAnchorDpDt[1] = dTop * (1 - locationY) + dBottom * locationY;

        vmat.clear();
        vmat.setRotationVelocity(rotation, position);
        vmat.setTranslationVelocity(trans_x, trans_y, position);
        vmat.setScaleVelocity(scale_x, scale_y, position);
        vmat.setRotationVelocity(osc_r, position);
        vmat.setTranslationVelocity(osc_x, osc_y, position);
        vmat.setScaleVelocity(osc_sx, osc_sy, position);
        vmat.applyTransform(locationX, locationY, width, height, mAnchorDpDt);
        return;
    }

    /**
     * returns the draw path mode
     * @return
     */
    public int getDrawPath() {
        int mode = mStartMotionPath.mDrawPath;
        for (MotionPaths keyFrame : mMotionPaths) {
            mode = Math.max(mode, keyFrame.mDrawPath);
        }
        mode = Math.max(mode, mEndMotionPath.mDrawPath);
        return mode;
    }

    public void setDrawPath(int debugMode) {
        mStartMotionPath.mDrawPath = debugMode;
    }

    String name() {
        Context context = mView.getContext();
        return context.getResources().getResourceEntryName(mView.getId());
    }

    void positionKeyframe(View view,
                          KeyPositionBase key,
                          float x,
                          float y,
                          String[] attribute,
                          float[] value) {
        RectF start = new RectF();
        start.left = mStartMotionPath.mX;
        start.top = mStartMotionPath.mY;
        start.right = start.left + mStartMotionPath.mWidth;
        start.bottom = start.top + mStartMotionPath.mHeight;
        RectF end = new RectF();
        end.left = mEndMotionPath.mX;
        end.top = mEndMotionPath.mY;
        end.right = end.left + mEndMotionPath.mWidth;
        end.bottom = end.top + mEndMotionPath.mHeight;
        key.positionAttributes(view, start, end, x, y, attribute, value);
    }

    /**
     * Get the keyFrames for the view controlled by this MotionController
     *
     * @param type is position(0-100) + 1000*mType(1=Attr, 2=Pos, 3=TimeCycle 4=Cycle 5=Trigger
     * @param pos  the x&y position of the keyFrame along the path
     * @return Number of keyFrames found
     */
    public int getKeyFramePositions(int[] type, float[] pos) {
        int i = 0;
        int count = 0;
        for (Key key : mKeyList) {
            type[i++] = key.mFramePosition + 1000 * key.mType;
            float time = key.mFramePosition / 100.0f;
            mSpline[0].getPos(time, mInterpolateData);
            mStartMotionPath.getCenter(time, mInterpolateVariables, mInterpolateData, pos, count);
            count += 2;
        }

        return i;
    }

    /**
     * Get the keyFrames for the view controlled by this MotionController
     * the info data structure is of the form
     * 0 length if your are at index i the [i+len+1] is the next entry
     * 1 type  1=Attributes, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger
     * 2 position
     * 3 x location
     * 4 y location
     * 5
     * ...
     * length
     *
     * @param info is a data structure array of int that holds info on each keyframe
     * @return Number of keyFrames found
     */
    public int getKeyFrameInfo(int type, int[] info) {
        int count = 0;
        int cursor = 0;
        float[] pos = new float[2];
        int len;
        for (Key key : mKeyList) {
            if (key.mType != type && type == -1) {
                continue;
            }
            len = cursor;
            info[cursor] = 0;

            info[++cursor] = key.mType;
            info[++cursor] = key.mFramePosition;

            float time = key.mFramePosition / 100.0f;
            mSpline[0].getPos(time, mInterpolateData);
            mStartMotionPath.getCenter(time, mInterpolateVariables, mInterpolateData, pos, 0);
            info[++cursor] = Float.floatToIntBits(pos[0]);
            info[++cursor] = Float.floatToIntBits(pos[1]);
            if (key instanceof KeyPosition) {
                KeyPosition kp = (KeyPosition) key;
                info[++cursor] = kp.mPositionType;

                info[++cursor] = Float.floatToIntBits(kp.mPercentX);
                info[++cursor] = Float.floatToIntBits(kp.mPercentY);
            }
            cursor++;
            info[len] = cursor - len;
            count++;
        }

        return count;
    }
}


text:
<!--
id: 35934027
link: http://tumblr.atmos.org/post/35934027/anywhere-fm
slug: anywhere-fm
date: Sat May 24 2008 14:40:05 GMT-0700 (PDT)
publish: 2008-05-024
tags:
title: Anywhere.FM
-->

Anywhere.FM
===========

[http://www.anywhere.fm/player/](http://www.anywhere.fm/player/)

Little desktop uploader puts your itunes online, and it's a social
network! zomg!

redpajama_set_name: RedPajamaGithub


text:
	Captain the page doesn't exist.

	Check our path again.


text:
<?php defined('SYSPATH') or die('No direct script access.');

class View_Module_Index extends View_Layout
{
    public $title = '';
    private $query;

    public function __construct($query)
    {
        $this->query      = $query;
        $this->pagination = $this->getPagination();
    }

    private function getPagination()
    {
        return Pagination::factory(array(
            'total_items' => $this->count()
            ));
    }

    public function count()
    {
        return $this->query->reset(FALSE)->count_all();
    }

    public function modules()
    {
        $modules = $this->getModules();

        $formattedModules = array_map(array($this, 'formatModule'), $modules);

        return $formattedModules;
    }

    private function getModules()
    {
        return $this->query
            ->limit($this->pagination->items_per_page)
            ->offset($this->pagination->offset)
            ->find_all()
            ->as_array();
    }

    protected function formatModule($module)
    {
        return array(
            'name'        => $module->name,
            'username'    => $module->username,
            'identifier'  => $this->formatModuleIdentifier($module),
            'description' => $this->formatModuleDescription($module),
	        'watchers'    => $module->watchers,
	        'stars'       => $module->stars,
            'forks'       => $module->forks
            );
    }

    protected function formatModuleIdentifier($module)
    {
        return $module->username.'/'.$module->name;
    }

    protected function formatModuleDescription($module)
    {
        return Text::widont($module->description);
    }

    public function pagination()
    {
        return $this->pagination->render();
    }

    public function sorter()
    {
        $default_version = Model_Kohana_Version::latest();
        $view            = new View_Module_Sort($default_version);

        return Kostache::factory()->render($view);
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Solver_Bases.Geometry;

namespace Solver_Bases.Layers
{
    public class Air_Layer : Layer
    {
        public Air_Layer(IGeom geom, int layer_no)
            : base(geom, layer_no)
        { }

        protected override void Set_Material_Parameters()
        {
            material = Material.Air;
            permitivity = Physics_Base.epsilon_0;

            // ok, so this is the actual band gap for air... may as well be infinite but that's the way I'm doing this
            this.band_gap = 500000000.0;
        }

        internal override void Set_Freeze_Out_Temperature()
        {
        }
    }
}


text:
using System.Collections.Generic;
using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.MachineLearningServices.Models
{
    internal partial class ListUsagesResult
    {
        internal static ListUsagesResult DeserializeListUsagesResult(JsonElement element)
        {
            Optional<IReadOnlyList<Usage>> value = default;
            Optional<string> nextLink = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List<Usage> array = new List<Usage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Usage.DeserializeUsage(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return new ListUsagesResult(Optional.ToList(value), nextLink.Value);
        }
    }
}


text:
J2OBJC_INITIALIZED_DEFN(OrgApacheLuceneDocumentSortedSetDocValuesField)

OrgApacheLuceneDocumentFieldType *OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE;

@implementation OrgApacheLuceneDocumentSortedSetDocValuesField

+ (OrgApacheLuceneDocumentFieldType *)TYPE {
  return OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE;
}

- (instancetype)initWithNSString:(NSString *)name
 withOrgApacheLuceneUtilBytesRef:(OrgApacheLuceneUtilBytesRef *)bytes {
  OrgApacheLuceneDocumentSortedSetDocValuesField_initWithNSString_withOrgApacheLuceneUtilBytesRef_(self, name, bytes);
  return self;
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x1, -1, 0, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initWithNSString:withOrgApacheLuceneUtilBytesRef:);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "TYPE", "LOrgApacheLuceneDocumentFieldType;", .constantValue.asLong = 0, 0x19, -1, 1, -1, -1 },
  };
  static const void *ptrTable[] = { "LNSString;LOrgApacheLuceneUtilBytesRef;", &OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE };
  static const J2ObjcClassInfo _OrgApacheLuceneDocumentSortedSetDocValuesField = { "SortedSetDocValuesField", "org.apache.lucene.document", ptrTable, methods, fields, 7, 0x1, 1, 1, -1, -1, -1, -1, -1 };
  return &_OrgApacheLuceneDocumentSortedSetDocValuesField;
}

+ (void)initialize {
  if (self == [OrgApacheLuceneDocumentSortedSetDocValuesField class]) {
    JreStrongAssignAndConsume(&OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE, new_OrgApacheLuceneDocumentFieldType_init());
    {
      [OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE setDocValuesTypeWithOrgApacheLuceneIndexDocValuesType:JreLoadEnum(OrgApacheLuceneIndexDocValuesType, SORTED_SET)];
      [OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE freeze];
    }
    J2OBJC_SET_INITIALIZED(OrgApacheLuceneDocumentSortedSetDocValuesField)
  }
}

@end

void OrgApacheLuceneDocumentSortedSetDocValuesField_initWithNSString_withOrgApacheLuceneUtilBytesRef_(OrgApacheLuceneDocumentSortedSetDocValuesField *self, NSString *name, OrgApacheLuceneUtilBytesRef *bytes) {
  OrgApacheLuceneDocumentField_initWithNSString_withOrgApacheLuceneDocumentFieldType_(self, name, OrgApacheLuceneDocumentSortedSetDocValuesField_TYPE);
  JreStrongAssign(&self->fieldsData_, bytes);
}

OrgApacheLuceneDocumentSortedSetDocValuesField *new_OrgApacheLuceneDocumentSortedSetDocValuesField_initWithNSString_withOrgApacheLuceneUtilBytesRef_(NSString *name, OrgApacheLuceneUtilBytesRef *bytes) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneDocumentSortedSetDocValuesField, initWithNSString_withOrgApacheLuceneUtilBytesRef_, name, bytes)
}

OrgApacheLuceneDocumentSortedSetDocValuesField *create_OrgApacheLuceneDocumentSortedSetDocValuesField_initWithNSString_withOrgApacheLuceneUtilBytesRef_(NSString *name, OrgApacheLuceneUtilBytesRef *bytes) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneDocumentSortedSetDocValuesField, initWithNSString_withOrgApacheLuceneUtilBytesRef_, name, bytes)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneDocumentSortedSetDocValuesField)


text:
This is a tool to automatically generate test cases for checking existence of
Typed Array attributes existence.

## Source Code

* `data.yaml`: test cases data.
* `gentest.py`: script to create test cases using template and data.
* `template.html`: test case template.
* `template-dataview.html`: alternative test case template for DataView
interface.

## How to Generate Tests

```sh
python gentest.py
```

## Authors

* Xie, Yunxiao <yunxiaox.xie@intel.com>
* Wang, Chunyan <chunyanx.wang@intel.com>

## LICENSE

Copyright (c) 2014 Intel Corporation.
Except as noted, this software is licensed under BSD-3-Clause License.
Please see the COPYING file for the BSD-3-Clause License.


text:
.class public Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;
.super Ljava/lang/Object;
.source "WeatherUtility.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/htc/util/weather/WeatherUtility;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "WeatherLocationExtInfo"
.end annotation

# instance fields
.field public engCountry:Ljava/lang/String;

.field public engName:Ljava/lang/String;

.field public engState:Ljava/lang/String;

.field public hasEngInfo:Z

.field public systemLangCountry:Ljava/lang/String;

.field public systemLangName:Ljava/lang/String;

.field public systemLangState:Ljava/lang/String;

# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 1146
    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 1151
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->hasEngInfo:Z

    .line 1156
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->systemLangName:Ljava/lang/String;

    .line 1161
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->systemLangState:Ljava/lang/String;

    .line 1166
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->systemLangCountry:Ljava/lang/String;

    .line 1171
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->engName:Ljava/lang/String;

    .line 1176
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->engState:Ljava/lang/String;

    .line 1181
    const-string v0, ""

    iput-object v0, p0, Lcom/htc/util/weather/WeatherUtility$WeatherLocationExtInfo;->engCountry:Ljava/lang/String;

    return-void
.end method


text:
package org.waveprotocol.wave.client.wavepanel.block.xml;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;

import org.waveprotocol.wave.client.wavepanel.block.BlockStructure;

/**
 * Exposes an XML block dom as a view structure.
 *
 */
public final class XmlStructure implements BlockStructure {

  /**
   * JSO access to a DOM node.
   */
  public final static class XmlNode extends JavaScriptObject implements BlockStructure.Node {

    //
    // Schema: <x id="X..." k="n"></x>
    //
    // Block ids are quoted by prepending "X", so as not to clash with HTML
    // views.
    // "n" is the ordinal of the NodeType enum.
    //

    protected XmlNode() {
    }

    public static XmlNode of(JavaScriptObject jso) {
      return (XmlNode) jso;
    }

    private static String quoteId(String id) {
      return "X" + id;
    }

    private static String unquoteId(String value) {
      return value.substring(1);
    }

    @Override
    public String getId() {
      return unquoteId(getAttribute("id"));
    }

    @Override
    public NodeType getType() {
      int type = getTypeInt();
      if (type < 0) {
        String id = getAttribute("id");
        String kind = getAttribute("k");
        throw new RuntimeException("bad kind: " + kind + ", on id: " + id);
      }
      return NodeType.values()[type];
    }

    private native String getAttribute(String name) /*-{
      return this.getAttribute(name);
    }-*/;

    // For some reason, parseInt fails come back as doubles (NaN), so the JSNI
    // has to handle the error case in order to return ints safely.
    private native int getTypeInt() /*-{
      var k = parseInt(this.getAttribute("k"));
      return k >= 0 ? k : -1;
    }-*/;

    @Override
    public native XmlNode getFirstChild() /*-{
      return this.firstChild;
    }-*/;

    @Override
    public native XmlNode getLastChild() /*-{
      return this.lastChild;
    }-*/;

    @Override
    public native XmlNode getNextSibling() /*-{
      return this.nextSibling;
    }-*/;

    @Override
    public native XmlNode getParent() /*-{
      return this.parentNode;
    }-*/;

    @Override
    public native XmlNode getPreviousSibling() /*-{
      return this.previousSibling;
    }-*/;
  }

  private final XmlNode root;

  private XmlStructure(XmlNode root) {
    this.root = root;
  }

  public static XmlStructure create(String id) {
    return new XmlStructure(XmlNode.of(Document.get().getElementById(XmlNode.quoteId(id))));
  }

  @Override
  public XmlNode getRoot() {
    return root;
  }

  @Override
  public XmlNode getNode(String id) {
    return XmlNode.of(Document.get().getElementById(XmlNode.quoteId(id)));
  }

  /**
   * Detaches the XML tree from the DOM. Use with caution.
   * {@link #getNode(String)} will not work after this.
   */
  public void detach() {
    if (root != null) {
      Element.as(root).removeFromParent();
    }
  }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Syst. Veg. 3:363. 1826

#### Original name
Orobus humilis Ser.

### Remarks
null


text:
package com.ivstuart.tmud.person.statistics.affects;

import com.ivstuart.tmud.common.DiceRoll;
import com.ivstuart.tmud.state.Mob;

public class DamageOverTime extends Affect {

	protected DiceRoll _damageRoll = null;

	public DamageOverTime(Mob mob_, String desc_, int duration_,
			DiceRoll damage_) {
		super(mob_, desc_, duration_);
		_damageRoll = damage_;
	}

	@Override
    public boolean tick() {
        super.tick();

		int damage = _damageRoll.roll();

		_mob.getHp().decrease(damage);

		String msg = this._desc + " deals you " + damage + " damage";

		_mob.out(msg);
        return false;

	}

	@Override
	public String toString() {
		return super.toString() + " " + _damageRoll;
	}

}


text:
{CSSTemplate {
    $classpath : "test.aria.templates.customization.reload.sharedChild.ReplacedCSS"
}}
{macro main()}
.text {
    font-size: 12pt;
}
{/macro}
{/CSSTemplate}


text:
require 'openwsman'
require 'celluloid'
require 'open-uri'

connection_credentials = [
    {
        :host => '10.120.67.93',
        :port => 5985,
        :username => 'wsman',
        :password => 'secret'
    },

    {
        :host => '10.120.4.11',
        :port => 5985,
        :username => 'wsman',
        :password => 'secret'
    }
]

uris = [
#    'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_NICView'
    'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem'
    #'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_SoftwareIdentity'
]

class Downloader
  include Celluloid

  def download(host, port, username, password, uri)
    puts "Requesting #{host}/#{File.basename(uri)}"
    @wsman = Openwsman::Client.new(host, port, "/wsman", "http", username, password)
    #Openwsman::debug = 9
    @wsman.transport.verify_peer=0
    @options = Openwsman::ClientOptions.new
    @options.flags = Openwsman::FLAG_ENUMERATION_OPTIMIZATION
    @options.max_elements = 100

    puts "Client #{host} prepared"
    request(uri) do |response|
      puts "#{host} responded"
    end
  end

  def download_http(*params)
    host = 'http://google.com'
    puts "Requesting #{host}"
    open(host).read
    puts "#{host} responded"
  end

  private
  def request(uri, &response_handler_block)
    puts "Enumerate..."
    response = @wsman.enumerate(@options, nil, uri)
    puts "...done"
    response_handler_block.call(response)

    context = response.context
    puts "Context #{context}"

    while (context)
      response = @wsman.pull( @options, nil, uri, context )
      response_handler_block.call(response)
      context = response.context
    end
  end
end

downloaders = Downloader.pool(size: connection_credentials.size * uris.size)

connection_credentials.each do |credential|
  uris.each do |uri|
    puts "Starting async"
    downloaders.async.download(credential[:host], credential[:port], credential[:username], credential[:password], uri)
  end
end

sleep


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.datavec</groupId>
        <artifactId>datavec-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>datavec-jdbc</artifactId>

    <properties>
        <dbutils.version>1.7</dbutils.version>
        <hikaricp.version>2.4.12</hikaricp.version>
        <derby.version>10.13.1.1</derby.version>
        <module.name>datavec.jdbc</module.name>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>${dbutils.version}</version>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP-java7</artifactId>
            <version>${hikaricp.version}</version>
        </dependency>

        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-common-tests</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>


text:
<?php

/**
 * MySQLクラス
 * pdoを利用しMySQLを前提とした関数を提供
 *
 * @packege ApplestFramework
 * @author Yusei Yamanaka<info@applest.net>
 */
class MySQL {

	private static $instance = null;

	private function __construct() {}
	public static function getInstance() {
		if (is_null(self::$instance))
		{
			self::$instance = new self;
		}
		return self::$instance;
	}

	private $pdo;

	public function connect($source, $user, $password, $charset = 'utf8') {
		$this->pdo = new PDO($source, $user, $password);
		if($charset)
		{
			$this->pdo->query("SET NAMES $charset");
		}
	}

	public function exec($query, $arrval = array(), $get_data = false, $get_last_id = false) {
		Log::verbose('MySQL Query:  '.var_export($query, true));
		Log::verbose('MySQL Values: '.var_export($arrval, true));

		$stmt = $this->pdo->prepare($query);
		$result = $stmt->execute($arrval);

		if($result === false)
		{
			if(Config::get('debug', false)) {
				var_dump($query, $arrval);
				var_dump($this->pdo->errorInfo());
			}
			throw new Exception('Failed SQL Execute.');
		}

		if($get_last_id)
		{
			return $this->pdo->lastInsertId();
		}

		if($get_data === false)
		{
			return $stmt;
		}

		$returndata = array();
		while($data = $stmt->fetch(PDO::FETCH_ASSOC))
		{
			$returndata[] = $data;
		}
		return $returndata;
	}
}


text:
package org.uma.jmetal.algorithm.multiobjective.espea;

import org.uma.jmetal.algorithm.impl.AbstractGeneticAlgorithm;
import org.uma.jmetal.algorithm.multiobjective.espea.util.EnergyArchive;
import org.uma.jmetal.algorithm.multiobjective.espea.util.EnergyArchive.ReplacementStrategy;
import org.uma.jmetal.algorithm.multiobjective.espea.util.ScalarizationWrapper;
import org.uma.jmetal.operator.crossover.CrossoverOperator;
import org.uma.jmetal.operator.mutation.MutationOperator;
import org.uma.jmetal.operator.selection.SelectionOperator;
import org.uma.jmetal.problem.Problem;
import org.uma.jmetal.solution.Solution;
import org.uma.jmetal.util.evaluator.SolutionListEvaluator;

import java.util.ArrayList;
import java.util.List;

/**
 * Implementation of the Electrostatic Potential Energy Evolutionary Algorithm
 * (ESPEA) from the paper "Obtaining Optimal Pareto Front Approximations using
 * Scalarized Preference Information" by M. Braun et al.
 *
 *

 * The algorithm generates preference-biased Pareto front approximations that
 * cover the entire front but focus more solutions in those regions that are
 * interesting to the decision maker. Preferences are presented to the algorithm
 * in the form of a scalarization function (value function) that maps the vector
 * of objective to a real value. Smaller values are deemed to indicate higher
 * desirability to comply with minimization.
 *
 *

 * If no scalarized preference is specified, uniform preferences are assumed and
 * ESPEA generates a uniform approximation of the Pareto front.
 *
 * @author Marlon Braun
 */
@SuppressWarnings("serial")
public class ESPEA<S extends Solution<?>> extends AbstractGeneticAlgorithm<S, List<S>> {

  /**
   * The number of function evaluations that have been executed so far.
   */
  protected int evaluations;

  /**
   * Maximum number of functions evaluations that are executed.
   */
  protected int maxEvaluations;

  /**
   * ESPEA uses two different crossover operators depending on the current
   * archive size. If the archive is not full, it uses the crossover operator
   * provided by {@link #getCrossoverOperator()}. If the archive is full,
   * {@link #fullArchiveCrossoverOperator} is used.
   */
  protected CrossoverOperator<S> fullArchiveCrossoverOperator;

  /**
   * Evaluates the solutions
   */
  protected final SolutionListEvaluator<S> evaluator;

  /**
   * An archive of nondominated solutions that approximates the energy minimum
   * state based on the chosen scalarization function.
   */
  protected final EnergyArchive<S> archive;

  /**
   * Constructor for setting all parameters of ESPEA.
   */
  public ESPEA(Problem<S> problem, int maxEvaluations, int populationSize, CrossoverOperator<S> crossoverOperator,
               CrossoverOperator<S> fullArchiveCrossoverOperator, MutationOperator<S> mutationOperator,
               SelectionOperator<List<S>, S> selectionOperator, ScalarizationWrapper scalarizationWrapper, SolutionListEvaluator<S> evaluator,
               boolean normalizeObjectives, ReplacementStrategy replacementStrategy) {
    super(problem);
    this.maxEvaluations = maxEvaluations;
    setMaxPopulationSize(populationSize);
    this.crossoverOperator = crossoverOperator;
    this.fullArchiveCrossoverOperator = fullArchiveCrossoverOperator;
    this.mutationOperator = mutationOperator;
    this.selectionOperator = selectionOperator;
    this.archive = new EnergyArchive<>(populationSize, scalarizationWrapper, normalizeObjectives, replacementStrategy);
    this.evaluator = evaluator;
  }

  @Override
  public String getName() {
    return "ESPEA";
  }

  @Override
  public String getDescription() {
    return "Electrostatic Potential Energy Evolutionary Algorithms";
  }

  @Override
  protected void initProgress() {
    evaluations = getMaxPopulationSize();
    // Initialize archive
    population.forEach(s -> archive.add(s));
  }

  @Override
  protected void updateProgress() {
    // ESPEA is steady-state
    evaluations++;
  }

  @Override
  protected boolean isStoppingConditionReached() {
    return evaluations >= maxEvaluations;
  }

  @Override
  protected List<S> evaluatePopulation(List<S> population) {
    population = evaluator.evaluate(population, getProblem());
    return population;
  }

  @Override
  protected List<S> replacement(List<S> population, List<S> offspringPopulation) {
    // population and archive are always in sync
    offspringPopulation.forEach(s -> archive.add(s));
    return archive.getSolutionList();
  }

  @Override
  public List<S> getResult() {
    return archive.getSolutionList();
  }

  /*
   * Steady-state implementation of mating selection.
   *
   * @see
   * org.uma.jmetal.algorithm.impl.AbstractGeneticAlgorithm#selection(java.
   * util.List)
   */
  @Override
  protected List<S> selection(List<S> population) {
    // Chosen operator depends on archive size
    CrossoverOperator<S> chosenOperator = archive.isFull() ? fullArchiveCrossoverOperator : crossoverOperator;

    List<S> matingPopulation = new ArrayList<>(chosenOperator.getNumberOfRequiredParents());

    for (int i = 0; i < chosenOperator.getNumberOfRequiredParents(); i++) {
      S solution = selectionOperator.execute(population);
      matingPopulation.add(solution);
    }

    return matingPopulation;
  }

  /*
   * Steady-state implementation of reproduction.
   *
   * @see
   * org.uma.jmetal.algorithm.impl.AbstractGeneticAlgorithm#reproduction(java.
   * util.List)
   */
  @Override
  protected List<S> reproduction(List<S> population) {
    List<S> offspring = crossoverOperator.execute(population);
    mutationOperator.execute(offspring.get(0));

    return offspring;
  }
}


text:
const path = require('path');
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const baseConfig = require('./webpack.base.config');

module.exports = () => webpackMerge(
    {
        entry: {
            bundle: [
                'react-hot-loader/patch',
                'webpack/hot/only-dev-server',
            ],
        },

        plugins: [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NamedModulesPlugin(),
        ],

        devServer: {
            historyApiFallback: true,
            contentBase: path.resolve(__dirname, 'dist/'),
            hot: true,
            host: '0.0.0.0',
        },
    },
    baseConfig());


text:
<!doctype html>

	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>

	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/style.css">

	<link rel="stylesheet" href="css/lightbox.css">

	<title>Caldinho do Nenen</title>

Contato

Galeria de Eventos

Cardápio

Serviços

Caldinho 360º

O Caldinho

Home

Galeria de Eventos

						All

Todos

Dia dos Pais

Corrid GAC

Natal Creche Afogados

Show Zé Lezin

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Corrida GAC 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Dia dos Pais 2016

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Natal em chreche de Afogados

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

Show de Zé Lezin

No results found

			<form>

Search

						<input type="search" placeholder="Try color-1...">

Check boxes

							<input class="filter" data-filter=".check1" type="checkbox" id="checkbox1">
			    			Option 1

							<input class="filter" data-filter=".check2" type="checkbox" id="checkbox2">
							Option 2

							<input class="filter" data-filter=".check3" type="checkbox" id="checkbox3">
							Option 3

Select

							<select class="filter" name="selectThis" id="selectThis">
								<option value="">Choose an option</option>
								<option value=".option1">Option 1</option>
								<option value=".option2">Option 2</option>
								<option value=".option3">Option 3</option>
								<option value=".option4">Option 4</option>
							</select>

Radio buttons

							<input class="filter" data-filter="" type="radio" name="radioButton" id="radio1" checked>
							All

							<input class="filter" data-filter=".radio2" type="radio" name="radioButton" id="radio2">
							Choice 2

							<input class="filter" data-filter=".radio3" type="radio" name="radioButton" id="radio3">
							Choice 3

			</form>

			Close

                    © Bar caldinho do Nenen


text:
package org.codehaus.groovy.grails.web.taglib.jsp;

/**
 * @author Graeme Rocher
 */
public class JspRemoteFunctionTag extends JspInvokeGrailsTagLibTag {
    private static final long serialVersionUID = -4345166429867722872L;

    private static final String TAG_NAME = "remoteFunction";

    private String controller;
    private String action;
    private String id;
    private String update;
    private String before;
    private String after;
    private String method;
    private String asynchronous;
    private String url;
    private String params;
    private String onSuccess;
    private String onFailure;
    private String onComplete;
    private String onLoading;
    private String onLoaded;
    private String onInteractive;

    public JspRemoteFunctionTag() {
        setTagName(TAG_NAME);
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public String getOnSuccess() {
        return onSuccess;
    }

    public void setOnSuccess(String onSuccess) {
        this.onSuccess = onSuccess;
    }

    public String getOnFailure() {
        return onFailure;
    }

    public void setOnFailure(String onFailure) {
        this.onFailure = onFailure;
    }

    public String getOnComplete() {
        return onComplete;
    }

    public void setOnComplete(String onComplete) {
        this.onComplete = onComplete;
    }

    public String getOnLoading() {
        return onLoading;
    }

    public void setOnLoading(String onLoading) {
        this.onLoading = onLoading;
    }

    public String getOnLoaded() {
        return onLoaded;
    }

    public void setOnLoaded(String onLoaded) {
        this.onLoaded = onLoaded;
    }

    public String getOnInteractive() {
        return onInteractive;
    }

    public void setOnInteractive(String onInteractive) {
        this.onInteractive = onInteractive;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getController() {
        return controller;
    }

    public void setController(String controller) {
        this.controller = controller;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getUpdate() {
        return update;
    }

    public void setUpdate(String update) {
        this.update = update;
    }

    public String getBefore() {
        return before;
    }

    public void setBefore(String before) {
        this.before = before;
    }

    public String getAfter() {
        return after;
    }

    public void setAfter(String after) {
        this.after = after;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getAsynchronous() {
        return asynchronous;
    }

    public void setAsynchronous(String asynchronous) {
        this.asynchronous = asynchronous;
    }
}