TypeEvaluator.java revision 17fb4b0d1cfbad1f026fec704c86640f070b4c2f
117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/*
217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Copyright (C) 2010 The Android Open Source Project
317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Licensed under the Apache License, Version 2.0 (the "License");
517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * you may not use this file except in compliance with the License.
617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * You may obtain a copy of the License at
717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *      http://www.apache.org/licenses/LICENSE-2.0
917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
1017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Unless required by applicable law or agreed to in writing, software
1117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * distributed under the License is distributed on an "AS IS" BASIS,
1217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * See the License for the specific language governing permissions and
1417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * limitations under the License.
1517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
1617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haasepackage android.animation;
1817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/**
2017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Interface for use with the {@link Animator#setEvaluator(TypeEvaluator)} function. Evaluators
2117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * allow developers to create animations on arbitrary property types, by allowing them to supply
2217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * custom evaulators for types that are not automatically understood and used by the animation
2317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * system.
2417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
2517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @see Animator#setEvaluator(TypeEvaluator)
2617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
2717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haasepublic interface TypeEvaluator {
2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
3017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This function returns the result of linearly interpolating the start and end values, with
3117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>fraction</code> representing the proportion between the start and end values. The
3217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * calculation is a simple parametric calculation: <code>result = x0 + t * (v1 - v0)</code>,
3317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>,
3417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * and <code>t</code> is <code>fraction</code>.
3517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
3617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param fraction   The fraction from the starting to the ending values
3717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param startValue The start value.
3817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param endValue   The end value.
3917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return A linear interpolation between the start and end values, given the
4017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *         <code>fraction</code> parameter.
4117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
4217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public Object evaluate(float fraction, Object startValue, Object endValue);
4317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
4417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase}