001/* 002 AUTOMATICALLY GENERATED BY jTemp FROM 003 /Users/jsh2/Work/openimaj/target/checkout/content/animation/src/main/jtemp/org/openimaj/content/animation/animator/LinearTimeBased#TT#ValueAnimator.jtemp 004*/ 005/** 006 * Copyright (c) 2011, The University of Southampton and the individual contributors. 007 * All rights reserved. 008 * 009 * Redistribution and use in source and binary forms, with or without modification, 010 * are permitted provided that the following conditions are met: 011 * 012 * * Redistributions of source code must retain the above copyright notice, 013 * this list of conditions and the following disclaimer. 014 * 015 * * Redistributions in binary form must reproduce the above copyright notice, 016 * this list of conditions and the following disclaimer in the documentation 017 * and/or other materials provided with the distribution. 018 * 019 * * Neither the name of the University of Southampton nor the names of its 020 * contributors may be used to endorse or promote products derived from this 021 * software without specific prior written permission. 022 * 023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 024 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 025 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 026 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 027 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 028 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 030 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 033 */ 034package org.openimaj.content.animation.animator; 035 036/** 037 * A {@link TimeBasedValueAnimator} that linearly animates a short value between two 038 * values over a given time. 039 * 040 * @author Jonathon Hare (jsh2@ecs.soton.ac.uk) 041 * @author David Dupplaw (dpd@ecs.soton.ac.uk) 042 */ 043public class LinearTimeBasedShortValueAnimator extends TimeBasedValueAnimator<Short> 044{ 045 /** 046 * Construct a {@link LinearTimeBasedShortValueAnimator} with the given 047 * start and finish values, and the given duration in millseconds. 048 * The animation starts on the first call to makeNextValue() 049 * and completes once duration ticks have been reached. 050 * 051 * @param start start value 052 * @param finish stop value 053 * @param duration in milliseconds 054 */ 055 public LinearTimeBasedShortValueAnimator( short start, short finish, long duration) { 056 super( start, finish, duration ); 057 } 058 059 /** 060 * Calculates the value of the short based on the start, end and current 061 * percentage. 062 * @param pc The percentage 063 * @return A short that is <code>pc</code> along between start and finish 064 */ 065 @Override 066 public Short calculateValue( double pc ) 067 { 068 return (short)((endValue-startValue)*pc + startValue); 069 } 070}