1 /* 2 * Copyright (C) 2022 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.core.dsl; 18 19 public class KeyCycle extends KeyAttribute { 20 private static final String TAG = "KeyCycle"; 21 private Wave mWaveShape = null; 22 private float mWavePeriod = Float.NaN; 23 private float mWaveOffset = Float.NaN; 24 private float mWavePhase = Float.NaN; 25 KeyCycle(int frame, String target)26 KeyCycle(int frame, String target) { 27 super(frame, target); 28 TYPE = "KeyCycle"; 29 } 30 31 public enum Wave { 32 SIN, 33 SQUARE, 34 TRIANGLE, 35 SAW, 36 REVERSE_SAW, 37 COS 38 } 39 getShape()40 public Wave getShape() { 41 return mWaveShape; 42 } 43 setShape(Wave waveShape)44 public void setShape(Wave waveShape) { 45 mWaveShape = waveShape; 46 } 47 getPeriod()48 public float getPeriod() { 49 return mWavePeriod; 50 } 51 setPeriod(float wavePeriod)52 public void setPeriod(float wavePeriod) { 53 mWavePeriod = wavePeriod; 54 } 55 getOffset()56 public float getOffset() { 57 return mWaveOffset; 58 } 59 setOffset(float waveOffset)60 public void setOffset(float waveOffset) { 61 mWaveOffset = waveOffset; 62 } 63 getPhase()64 public float getPhase() { 65 return mWavePhase; 66 } 67 setPhase(float wavePhase)68 public void setPhase(float wavePhase) { 69 mWavePhase = wavePhase; 70 } 71 72 @Override attributesToString(StringBuilder builder)73 protected void attributesToString(StringBuilder builder) { 74 super.attributesToString(builder); 75 76 if (mWaveShape != null) { 77 builder.append("shape:'").append(mWaveShape).append("',\n"); 78 } 79 append(builder, "period", mWavePeriod); 80 append(builder, "offset", mWaveOffset); 81 append(builder, "phase", mWavePhase); 82 83 } 84 85 } 86