/* * Moonlight|3D * Copyright (C) 2006 The Moonlight|3D team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on May 2, 2006 */ package ml.backend.anim; import java.util.ArrayList; import ml.backend.anim.KeyframeAnimationTrack.KeyValuePair; import ml.core.helper.Value; import ml.core.helper.Value.Type; public class ConstantValueInterpolator implements KeyframeInterpolator { public boolean isAppliciable(Type valueType) { return true; // this interpolator can handle all types } public Value interpolate(KeyframeAnimationTrack track, double time) { ArrayList keys=track.getKeyList(); if(keys.size()==0) { return track.getDefaultValue(); } if(keys.get(0).time>time) { return keys.get(0).value; } if(time>keys.get(keys.size()-1).time) { return keys.get(keys.size()-1).value; } for(int i=0;ikeys.get(i).time) { return keys.get(i).value; } } return null; // this line should never actually be reached } public String getType() { return "ConstantValueInterpolator"; } }