1 /* 2 * Copyright (C) 2018 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 package androidx.constraintlayout.motion.widget; 18 19 import android.graphics.RectF; 20 import android.view.View; 21 22 import java.util.HashSet; 23 24 /** 25 * Defines a KeyPositionBase abstract base class KeyPositionBase elements provide 26 * 27 */ 28 29 abstract class KeyPositionBase extends Key { 30 protected static final float SELECTION_SLOPE = 20; 31 int mCurveFit = UNSET; 32 33 /** 34 * Get the position of the view 35 * 36 * 37 * @param layoutWidth 38 * @param layoutHeight 39 * @param startX 40 * @param startY 41 * @param endX 42 * @param endY 43 * 44 */ calcPosition(int layoutWidth, int layoutHeight, float startX, float startY, float endX, float endY)45 abstract void calcPosition(int layoutWidth, 46 int layoutHeight, 47 float startX, 48 float startY, 49 float endX, 50 float endY); 51 52 /** 53 * @return 54 * 55 */ getPositionX()56 abstract float getPositionX(); 57 58 /** 59 * @return 60 * 61 */ getPositionY()62 abstract float getPositionY(); 63 64 @Override getAttributeNames(HashSet<String> attributes)65 void getAttributeNames(HashSet<String> attributes) { 66 } 67 68 /** 69 * 70 * @param view 71 * @param start 72 * @param end 73 * @param x 74 * @param y 75 * @param attribute 76 * @param value 77 * 78 */ positionAttributes(View view, RectF start, RectF end, float x, float y, String[] attribute, float[] value)79 abstract void positionAttributes(View view, 80 RectF start, 81 RectF end, 82 float x, 83 float y, 84 String[] attribute, 85 float[] value); 86 87 /** 88 * 89 * @param layoutWidth 90 * @param layoutHeight 91 * @param start 92 * @param end 93 * @param x 94 * @param y 95 * @return 96 * 97 */ intersects(int layoutWidth, int layoutHeight, RectF start, RectF end, float x, float y)98 public abstract boolean intersects(int layoutWidth, 99 int layoutHeight, 100 RectF start, 101 RectF end, 102 float x, 103 float y); 104 } 105