1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 package android.media.videoeditor; 19 20 import android.graphics.Rect; 21 22 /** 23 * This class represents a Ken Burns effect. 24 * {@hide} 25 */ 26 public class EffectKenBurns extends Effect { 27 /** 28 * Instance variables 29 */ 30 private Rect mStartRect; 31 private Rect mEndRect; 32 33 /** 34 * Objects of this type cannot be instantiated by using the default 35 * constructor 36 */ 37 @SuppressWarnings("unused") 38 private EffectKenBurns() { 39 this(null, null, null, null, 0, 0); 40 } 41 42 /** 43 * Constructor 44 * 45 * @param mediaItem The media item owner 46 * @param effectId The effect id 47 * @param startRect The start rectangle 48 * @param endRect The end rectangle 49 * @param startTimeMs The start time 50 * @param durationMs The duration of the Ken Burns effect in milliseconds 51 */ 52 public EffectKenBurns(MediaItem mediaItem, String effectId, Rect startRect, 53 Rect endRect, long startTimeMs, long durationMs) { 54 super(mediaItem, effectId, startTimeMs, durationMs); 55 56 if ( (startRect.width() <= 0) || (startRect.height() <= 0) ) { 57 throw new IllegalArgumentException("Invalid Start rectangle"); 58 } 59 if ( (endRect.width() <= 0) || (endRect.height() <= 0) ) { 60 throw new IllegalArgumentException("Invalid End rectangle"); 61 } 62 63 mStartRect = startRect; 64 mEndRect = endRect; 65 } 66 67 68 /** 69 * Get the start rectangle. 70 * 71 * @return The start rectangle 72 */ 73 public Rect getStartRect() { 74 return mStartRect; 75 } 76 77 78 /** 79 * Get the end rectangle. 80 * 81 * @return The end rectangle 82 */ 83 public Rect getEndRect() { 84 return mEndRect; 85 } 86 87 /** 88 * Get the KenBurn effect start and end rectangle coordinates 89 * @param start The rect object to be populated with start 90 * rectangle coordinates 91 * 92 * @param end The rect object to be populated with end 93 * rectangle coordinates 94 */ 95 void getKenBurnsSettings(Rect start, Rect end) { 96 start.left = getStartRect().left; 97 start.top = getStartRect().top; 98 start.right = getStartRect().right; 99 start.bottom = getStartRect().bottom; 100 end.left = getEndRect().left; 101 end.top = getEndRect().top; 102 end.right = getEndRect().right; 103 end.bottom = getEndRect().bottom; 104 } 105 } 106