public class Motion implements TypedValues


Contains the picture of a view through a transition and is used to interpolate it. During a 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.

Summary

Constants

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Public fields

String

Public constructors

Public methods

void
int
buildKeyFrames(float[] keyFrames, int[] mode, int[] pos)
void
buildPath(float[] points, int pointCount)

Fills 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

void
buildRect(float p, float[] path, int offset)
String

Returns the id of the view to move relative to.

void
getCenter(double p, float[] pos, float[] vel)
float
float
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)

int
float

get the width of the widget at the end of the movement.

float

get the width of the widget at the end of the movement.

float

get the left most position of the widget at the end of the movement.

float

get the top most position of the widget at the end of the movement.

int
getId(String name)
MotionPaths
getKeyFrame(int i)

provides access to MotionPath objects

int
getKeyFrameInfo(int type, int[] info)

Gets the keyFrames for the view controlled by this MotionController.

int
getKeyFramePositions(int[] type, float[] pos)

Get the keyFrames for the view controlled by this MotionController

float

The values set in motion: { stagger: '2' }

float

get the width of the widget at the start of the movement.

float

get the width of the widget at the start of the movement.

float

get the left most position of the widget at the start of the movement.

float

get the top most position of the widget at the start of the movement.

int

Get the view to pivot around

MotionWidget
boolean
interpolate(
    MotionWidget child,
    float globalPosition,
    long time,
    KeyCache keyCache
)

The main driver of interpolation

void
setDrawPath(int debugMode)
void
void
setIdString(String stringId)
void
void
setStaggerOffset(float staggerOffset)

set the offset used in calculating stagger launches

void
setStaggerScale(float staggerScale)

Set stagger scale

void
void
setStartState(
    ViewState rect,
    MotionWidget v,
    int rotation,
    int preWidth,
    int preHeight
)
void
setTransformPivotTarget(int transformPivotTarget)

Set a view to pivot around

boolean
setValue(int id, boolean value)

Used to set boolean values

boolean
setValue(int id, float value)

Used to set float values

boolean
setValue(int id, int value)

Used to set integer values

boolean
setValue(int id, String value)

Used to set String values

void
void
setup(
    int parentWidth,
    int parentHeight,
    float transitionDuration,
    long currentTime
)

Called after all TimePoints &Cycles have been added; Spines are evaluated

void
setupRelative(Motion motionController)

set up the motion to be relative to this other motionController

String

Debug string

Inherited Constants

From androidx.constraintlayout.core.motion.utils.TypedValues
static final int
static final int
static final int
static final int
static final String
S_CUSTOM = "CUSTOM"
static final int
static final int

Constants

DRAW_PATH_AS_CONFIGURED

Added in 1.1.0-rc01
public static final int DRAW_PATH_AS_CONFIGURED = 4

DRAW_PATH_BASIC

Added in 1.1.0-rc01
public static final int DRAW_PATH_BASIC = 1

DRAW_PATH_CARTESIAN

Added in 1.1.0-rc01
public static final int DRAW_PATH_CARTESIAN = 3

DRAW_PATH_NONE

Added in 1.1.0-rc01
public static final int DRAW_PATH_NONE = 0

DRAW_PATH_RECTANGLE

Added in 1.1.0-rc01
public static final int DRAW_PATH_RECTANGLE = 5

DRAW_PATH_RELATIVE

Added in 1.1.0-rc01
public static final int DRAW_PATH_RELATIVE = 2

DRAW_PATH_SCREEN

Added in 1.1.0-rc01
public static final int DRAW_PATH_SCREEN = 6

HORIZONTAL_PATH_X

Added in 1.1.0-rc01
public static final int HORIZONTAL_PATH_X = 2

HORIZONTAL_PATH_Y

Added in 1.1.0-rc01
public static final int HORIZONTAL_PATH_Y = 3

PATH_PERCENT

Added in 1.1.0-rc01
public static final int PATH_PERCENT = 0

PATH_PERPENDICULAR

Added in 1.1.0-rc01
public static final int PATH_PERPENDICULAR = 1

ROTATION_LEFT

Added in 1.1.0-rc01
public static final int ROTATION_LEFT = 2

ROTATION_RIGHT

Added in 1.1.0-rc01
public static final int ROTATION_RIGHT = 1

VERTICAL_PATH_X

Added in 1.1.0-rc01
public static final int VERTICAL_PATH_X = 4

VERTICAL_PATH_Y

Added in 1.1.0-rc01
public static final int VERTICAL_PATH_Y = 5

Public fields

mId

Added in 1.1.0-rc01
public String mId

Public constructors

Motion

Added in 1.1.0-rc01
public Motion(MotionWidget view)

Public methods

addKey

Added in 1.1.0-rc01
public void addKey(MotionKey key)

buildKeyFrames

Added in 1.1.0-rc01
public int buildKeyFrames(float[] keyFrames, int[] mode, int[] pos)

buildPath

Added in 1.1.0-rc01
public void buildPath(float[] points, int pointCount)

Fills 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
float[] points

array to fill (should be 2x the number of mPoints

buildRect

Added in 1.1.0-rc01
public void buildRect(float p, float[] path, int offset)

getAnimateRelativeTo

Added in 1.1.0-rc01
public String getAnimateRelativeTo()

Returns 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
String

the view id of the view this is in polar mode to or -1 if not in polar

getCenter

Added in 1.1.0-rc01
public void getCenter(double p, float[] pos, float[] vel)

getCenterX

Added in 1.1.0-rc01
public float getCenterX()

getCenterY

Added in 1.1.0-rc01
public float getCenterY()

getDpDt

Added in 1.1.0-rc01
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
float position

position in time

float locationX

the x location on the view (0 = left edge, 1 = right edge)

float locationY

the y location on the view (0 = top, 1 = bottom)

float[] mAnchorDpDt

returns the differential of the motion with respect to the position

getDrawPath

Added in 1.1.0-rc01
public int getDrawPath()

getFinalHeight

Added in 1.1.0-rc01
public float getFinalHeight()

get the width of the widget at the end of the movement.

Returns
float

the height at the end

getFinalWidth

Added in 1.1.0-rc01
public float getFinalWidth()

get the width of the widget at the end of the movement.

Returns
float

the width at the end

getFinalX

Added in 1.1.0-rc01
public float getFinalX()

get the left most position of the widget at the end of the movement.

Returns
float

the left most position

getFinalY

Added in 1.1.0-rc01
public float getFinalY()

get the top most position of the widget at the end of the movement. Positive is down.

Returns
float

the top most position

getId

Added in 1.1.0-rc01
public int getId(String name)

getKeyFrame

Added in 1.1.0-rc01
public MotionPaths getKeyFrame(int i)

provides access to MotionPath objects

getKeyFrameInfo

Added in 1.1.0-rc01
public int getKeyFrameInfo(int type, int[] info)

Gets 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
int[] info

is a data structure array of int that holds info on each keyframe

Returns
int

Number of keyFrames found

getKeyFramePositions

Added in 1.1.0-rc01
public int getKeyFramePositions(int[] type, float[] pos)

Get the keyFrames for the view controlled by this MotionController

Parameters
int[] type

is position(0-100) + 1000 * mType(1=Attributes, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger

float[] pos

the x&y position of the keyFrame along the path

Returns
int

Number of keyFrames found

getMotionStagger

Added in 1.1.0-rc01
public float getMotionStagger()

The values set in motion: { stagger: '2' }

Returns
float

value from motion: { stagger: ? } or NaN if not set

getStartHeight

Added in 1.1.0-rc01
public float getStartHeight()

get the width of the widget at the start of the movement.

Returns
float

the height at the start

getStartWidth

Added in 1.1.0-rc01
public float getStartWidth()

get the width of the widget at the start of the movement.

Returns
float

the width at the start

getStartX

Added in 1.1.0-rc01
public float getStartX()

get the left most position of the widget at the start of the movement.

Returns
float

the left most position

getStartY

Added in 1.1.0-rc01
public float getStartY()

get the top most position of the widget at the start of the movement. Positive is down.

Returns
float

the top most position

getTransformPivotTarget

Added in 1.1.0-rc01
public int getTransformPivotTarget()

Get the view to pivot around

Returns
int

id of view or UNSET if not set

getView

Added in 1.1.0-rc01
public MotionWidget getView()

interpolate

Added in 1.1.0-rc01
public boolean interpolate(
    MotionWidget child,
    float globalPosition,
    long time,
    KeyCache keyCache
)

The main driver of interpolation

Returns
boolean

do you need to keep animating

setDrawPath

Added in 1.1.0-rc01
public void setDrawPath(int debugMode)

setEnd

Added in 1.1.0-rc01
public void setEnd(MotionWidget mw)

setIdString

Added in 1.1.0-rc01
public void setIdString(String stringId)

setPathMotionArc

Added in 1.1.0-rc01
public void setPathMotionArc(int arc)

setStaggerOffset

Added in 1.1.0-rc01
public void setStaggerOffset(float staggerOffset)

set the offset used in calculating stagger launches

Parameters
float staggerOffset

fraction of progress before this controller runs

setStaggerScale

Added in 1.1.0-rc01
public void setStaggerScale(float staggerScale)

Set stagger scale

setStart

Added in 1.1.0-rc01
public void setStart(MotionWidget mw)

setStartState

Added in 1.1.0-rc01
public void setStartState(
    ViewState rect,
    MotionWidget v,
    int rotation,
    int preWidth,
    int preHeight
)

setTransformPivotTarget

Added in 1.1.0-rc01
public void setTransformPivotTarget(int transformPivotTarget)

Set a view to pivot around

Parameters
int transformPivotTarget

id of view

setValue

Added in 1.1.0-rc01
public boolean setValue(int id, boolean value)

Used to set boolean values

Returns
boolean

true if it accepted the value

setValue

Added in 1.1.0-rc01
public boolean setValue(int id, float value)

Used to set float values

Returns
boolean

true if it accepted the value

setValue

Added in 1.1.0-rc01
public boolean setValue(int id, int value)

Used to set integer values

Returns
boolean

true if it accepted the value

setValue

Added in 1.1.0-rc01
public boolean setValue(int id, String value)

Used to set String values

Returns
boolean

true if it accepted the value

setView

Added in 1.1.0-rc01
public void setView(MotionWidget view)

setup

Added in 1.1.0-rc01
public void setup(
    int parentWidth,
    int parentHeight,
    float transitionDuration,
    long currentTime
)

Called after all TimePoints &Cycles have been added; Spines are evaluated

setupRelative

Added in 1.1.0-rc01
public void setupRelative(Motion motionController)

set up the motion to be relative to this other motionController

toString

public String toString()

Debug string