Class Motion
- java.lang.Object
-
- androidx.constraintlayout.core.motion.Motion
-
- All Implemented Interfaces:
TypedValues
public class Motion extends java.lang.Object implements TypedValues
This contains the picture of a view through the a transition and is used to interpolate it During an transition every view has a MotionController which drives its position.All parameter which affect a views motion are added to MotionController and then setup() builds out the splines that control the view.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface androidx.constraintlayout.core.motion.utils.TypedValues
TypedValues.AttributesType, TypedValues.Custom, TypedValues.CycleType, TypedValues.MotionScene, TypedValues.MotionType, TypedValues.OnSwipe, TypedValues.PositionType, TypedValues.TransitionType, TypedValues.TriggerType
-
-
Field Summary
Fields Modifier and Type Field Description static intDRAW_PATH_AS_CONFIGUREDstatic intDRAW_PATH_BASICstatic intDRAW_PATH_CARTESIANstatic intDRAW_PATH_NONEstatic intDRAW_PATH_RECTANGLEstatic intDRAW_PATH_RELATIVEstatic intDRAW_PATH_SCREENstatic intHORIZONTAL_PATH_Xstatic intHORIZONTAL_PATH_Ystatic intPATH_PERCENTstatic intPATH_PERPENDICULARstatic intROTATION_LEFTstatic intROTATION_RIGHTstatic intVERTICAL_PATH_Xstatic intVERTICAL_PATH_Y-
Fields inherited from interface androidx.constraintlayout.core.motion.utils.TypedValues
BOOLEAN_MASK, FLOAT_MASK, INT_MASK, S_CUSTOM, STRING_MASK, TYPE_FRAME_POSITION, TYPE_TARGET
-
-
Constructor Summary
Constructors Constructor Description Motion(MotionWidget view)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKey(MotionKey key)intbuildKeyFrames(float[] keyFrames, int[] mode, int[] pos)voidbuildPath(float[] points, int pointCount)fill the array point with the center coordinates point[0] is filled with the x coordinate of "time" 0.0 mPoints[point.length-1] is filled with the y coordinate of "time" 1.0voidbuildRect(float p, float[] path, int offset)intgetAnimateRelativeTo()Will return the id of the view to move relative to The position at the start and then end will be viewed relative to this view -1 is the return value if NOT in polar modevoidgetCenter(double p, float[] pos, float[] vel)floatgetCenterX()floatgetCenterY()voidgetDpDt(float position, float locationX, float locationY, float[] mAnchorDpDt)This returns the differential with respect to the animation layout position (Progress) of a point on the view (post layout effects are not computed)intgetDrawPath()floatgetFinalHeight()get the width of the widget at the end of the movement.floatgetFinalWidth()get the width of the widget at the end of the movement.floatgetFinalX()get the left most position of the widget at the end of the movement.floatgetFinalY()get the top most position of the widget at the end of the movement.intgetId(java.lang.String name)MotionPathsgetKeyFrame(int i)provides access to MotionPath objectsintgetKeyFrameInfo(int type, int[] info)Get the keyFrames for the view controlled by this MotionController the info data structure is of the form 0 length if your are at index i the [i+len+1] is the next entry 1 type 1=Attributes, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger 2 position 3 x location 4 y location 5 ...intgetKeyFramePositions(int[] type, float[] pos)Get the keyFrames for the view controlled by this MotionControllerfloatgetMotionStagger()The values set in motion: { stagger: '2' }floatgetStartHeight()get the width of the widget at the start of the movement.floatgetStartWidth()get the width of the widget at the start of the movement.floatgetStartX()get the left most position of the widget at the start of the movement.floatgetStartY()get the top most position of the widget at the start of the movement.intgetTransformPivotTarget()Get the view to pivot aroundMotionWidgetgetView()booleaninterpolate(MotionWidget child, float globalPosition, long time, KeyCache keyCache)The main driver of interpolationvoidsetDrawPath(int debugMode)voidsetEnd(MotionWidget mw)voidsetPathMotionArc(int arc)voidsetStaggerOffset(float staggerOffset)set the offset used in calculating stagger launchesvoidsetStaggerScale(float staggerScale)Set stagger scalevoidsetStart(MotionWidget mw)voidsetStartState(ViewState rect, MotionWidget v, int rotation, int preWidth, int preHeight)voidsetTransformPivotTarget(int transformPivotTarget)Set a view to pivot aroundvoidsetup(int parentWidth, int parentHeight, float transitionDuration, long currentTime)Called after all TimePoints & Cycles have been added; Spines are evaluatedvoidsetupRelative(Motion motionController)booleansetValue(int id, boolean value)Used to set boolean valuesbooleansetValue(int id, float value)Used to set float valuesbooleansetValue(int id, int value)Used to set integer valuesbooleansetValue(int id, java.lang.String value)Used to set String valuesvoidsetView(MotionWidget view)java.lang.StringtoString()Debug string
-
-
-
Field Detail
-
PATH_PERCENT
public static final int PATH_PERCENT
- See Also:
- Constant Field Values
-
PATH_PERPENDICULAR
public static final int PATH_PERPENDICULAR
- See Also:
- Constant Field Values
-
HORIZONTAL_PATH_X
public static final int HORIZONTAL_PATH_X
- See Also:
- Constant Field Values
-
HORIZONTAL_PATH_Y
public static final int HORIZONTAL_PATH_Y
- See Also:
- Constant Field Values
-
VERTICAL_PATH_X
public static final int VERTICAL_PATH_X
- See Also:
- Constant Field Values
-
VERTICAL_PATH_Y
public static final int VERTICAL_PATH_Y
- See Also:
- Constant Field Values
-
DRAW_PATH_NONE
public static final int DRAW_PATH_NONE
- See Also:
- Constant Field Values
-
DRAW_PATH_BASIC
public static final int DRAW_PATH_BASIC
- See Also:
- Constant Field Values
-
DRAW_PATH_RELATIVE
public static final int DRAW_PATH_RELATIVE
- See Also:
- Constant Field Values
-
DRAW_PATH_CARTESIAN
public static final int DRAW_PATH_CARTESIAN
- See Also:
- Constant Field Values
-
DRAW_PATH_AS_CONFIGURED
public static final int DRAW_PATH_AS_CONFIGURED
- See Also:
- Constant Field Values
-
DRAW_PATH_RECTANGLE
public static final int DRAW_PATH_RECTANGLE
- See Also:
- Constant Field Values
-
DRAW_PATH_SCREEN
public static final int DRAW_PATH_SCREEN
- See Also:
- Constant Field Values
-
ROTATION_RIGHT
public static final int ROTATION_RIGHT
- See Also:
- Constant Field Values
-
ROTATION_LEFT
public static final int ROTATION_LEFT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Motion
public Motion(MotionWidget view)
-
-
Method Detail
-
getTransformPivotTarget
public int getTransformPivotTarget()
Get the view to pivot around- Returns:
- id of view or UNSET if not set
-
setTransformPivotTarget
public void setTransformPivotTarget(int transformPivotTarget)
Set a view to pivot around- Parameters:
transformPivotTarget- id of view
-
getKeyFrame
public MotionPaths getKeyFrame(int i)
provides access to MotionPath objects
-
getStartX
public float getStartX()
get the left most position of the widget at the start of the movement.- Returns:
- the left most position
-
getStartY
public float getStartY()
get the top most position of the widget at the start of the movement. Positive is down.- Returns:
- the top most position
-
getFinalX
public float getFinalX()
get the left most position of the widget at the end of the movement.- Returns:
- the left most position
-
getFinalY
public float getFinalY()
get the top most position of the widget at the end of the movement. Positive is down.- Returns:
- the top most position
-
getStartWidth
public float getStartWidth()
get the width of the widget at the start of the movement.- Returns:
- the width at the start
-
getStartHeight
public float getStartHeight()
get the width of the widget at the start of the movement.- Returns:
- the height at the start
-
getFinalWidth
public float getFinalWidth()
get the width of the widget at the end of the movement.- Returns:
- the width at the end
-
getFinalHeight
public float getFinalHeight()
get the width of the widget at the end of the movement.- Returns:
- the height at the end
-
getAnimateRelativeTo
public int getAnimateRelativeTo()
Will return the id of the view to move relative to The position at the start and then end will be viewed relative to this view -1 is the return value if NOT in polar mode- Returns:
- the view id of the view this is in polar mode to or -1 if not in polar
-
setupRelative
public void setupRelative(Motion motionController)
-
getCenterX
public float getCenterX()
-
getCenterY
public float getCenterY()
-
getCenter
public void getCenter(double p, float[] pos, float[] vel)
-
buildPath
public void buildPath(float[] points, int pointCount)fill the array point with the center coordinates point[0] is filled with the x coordinate of "time" 0.0 mPoints[point.length-1] is filled with the y coordinate of "time" 1.0- Parameters:
points- array to fill (should be 2x the number of mPoints
-
buildKeyFrames
public int buildKeyFrames(float[] keyFrames, int[] mode, int[] pos)
-
buildRect
public void buildRect(float p, float[] path, int offset)
-
addKey
public void addKey(MotionKey key)
-
setPathMotionArc
public void setPathMotionArc(int arc)
-
setup
public void setup(int parentWidth, int parentHeight, float transitionDuration, long currentTime)Called after all TimePoints & Cycles have been added; Spines are evaluated
-
toString
public java.lang.String toString()
Debug string- Overrides:
toStringin classjava.lang.Object
-
setView
public void setView(MotionWidget view)
-
getView
public MotionWidget getView()
-
setStart
public void setStart(MotionWidget mw)
-
setEnd
public void setEnd(MotionWidget mw)
-
setStartState
public void setStartState(ViewState rect, MotionWidget v, int rotation, int preWidth, int preHeight)
-
interpolate
public boolean interpolate(MotionWidget child, float globalPosition, long time, KeyCache keyCache)
The main driver of interpolation- Returns:
- do you need to keep animating
-
getDpDt
public void getDpDt(float position, float locationX, float locationY, float[] mAnchorDpDt)This returns the differential with respect to the animation layout position (Progress) of a point on the view (post layout effects are not computed)- Parameters:
position- position in timelocationX- the x location on the view (0 = left edge, 1 = right edge)locationY- the y location on the view (0 = top, 1 = bottom)mAnchorDpDt- returns the differential of the motion with respect to the position
-
getDrawPath
public int getDrawPath()
-
setDrawPath
public void setDrawPath(int debugMode)
-
getKeyFramePositions
public int getKeyFramePositions(int[] type, float[] pos)Get the keyFrames for the view controlled by this MotionController- Parameters:
type- is position(0-100) + 1000 * mType(1=Attributes, 2=Position, 3=TimeCycle 4=Cycle 5=Triggerpos- the x&y position of the keyFrame along the path- Returns:
- Number of keyFrames found
-
getKeyFrameInfo
public int getKeyFrameInfo(int type, int[] info)Get the keyFrames for the view controlled by this MotionController the info data structure is of the form 0 length if your are at index i the [i+len+1] is the next entry 1 type 1=Attributes, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger 2 position 3 x location 4 y location 5 ... length- Parameters:
info- is a data structure array of int that holds info on each keyframe- Returns:
- Number of keyFrames found
-
setValue
public boolean setValue(int id, int value)Description copied from interface:TypedValuesUsed to set integer values- Specified by:
setValuein interfaceTypedValues- Returns:
- true if it accepted the value
-
setValue
public boolean setValue(int id, float value)Description copied from interface:TypedValuesUsed to set float values- Specified by:
setValuein interfaceTypedValues- Returns:
- true if it accepted the value
-
setValue
public boolean setValue(int id, java.lang.String value)Description copied from interface:TypedValuesUsed to set String values- Specified by:
setValuein interfaceTypedValues- Returns:
- true if it accepted the value
-
setValue
public boolean setValue(int id, boolean value)Description copied from interface:TypedValuesUsed to set boolean values- Specified by:
setValuein interfaceTypedValues- Returns:
- true if it accepted the value
-
getId
public int getId(java.lang.String name)
- Specified by:
getIdin interfaceTypedValues
-
setStaggerScale
public void setStaggerScale(float staggerScale)
Set stagger scale
-
setStaggerOffset
public void setStaggerOffset(float staggerOffset)
set the offset used in calculating stagger launches- Parameters:
staggerOffset- fraction of progress before this controller runs
-
getMotionStagger
public float getMotionStagger()
The values set in motion: { stagger: '2' }- Returns:
- value from motion: { stagger: ? } or NaN if not set
-
-