Motion
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 |
DRAW_PATH_BASIC = 1 |
static final int |
|
static final int |
DRAW_PATH_NONE = 0 |
static final int |
|
static final int |
|
static final int |
DRAW_PATH_SCREEN = 6 |
static final int |
|
static final int |
|
static final int |
PATH_PERCENT = 0 |
static final int |
|
static final int |
ROTATION_LEFT = 2 |
static final int |
ROTATION_RIGHT = 1 |
static final int |
VERTICAL_PATH_X = 4 |
static final int |
VERTICAL_PATH_Y = 5 |
Public constructors |
|---|
Motion(MotionWidget view) |
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(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 |
|
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 |
getView() |
boolean |
interpolate(The main driver of interpolation |
void |
setDrawPath(int debugMode) |
void |
setEnd(MotionWidget mw) |
void |
setIdString(String stringId) |
void |
setPathMotionArc(int arc) |
void |
setStaggerOffset(float staggerOffset)set the offset used in calculating stagger launches |
void |
setStaggerScale(float staggerScale)Set stagger scale |
void |
setStart(MotionWidget mw) |
void |
setStartState( |
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 |
Used to set String values |
void |
setView(MotionWidget view) |
void |
setup(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 |
toString()Debug string |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
Public constructors
Public methods
buildPath
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 |
getAnimateRelativeTo
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 |
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 | |
|---|---|
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 |
getFinalHeight
public float getFinalHeight()
get the width of the widget at the end of the movement.
| Returns | |
|---|---|
float |
the height at the end |
getFinalWidth
public float getFinalWidth()
get the width of the widget at the end of the movement.
| Returns | |
|---|---|
float |
the width at the end |
getFinalX
public float getFinalX()
get the left most position of the widget at the end of the movement.
| Returns | |
|---|---|
float |
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 | |
|---|---|
float |
the top most position |
getKeyFrame
public MotionPaths getKeyFrame(int i)
provides access to MotionPath objects
getKeyFrameInfo
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
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
public float getMotionStagger()
The values set in motion: { stagger: '2' }
| Returns | |
|---|---|
float |
value from motion: { stagger: ? } or NaN if not set |
getStartHeight
public float getStartHeight()
get the width of the widget at the start of the movement.
| Returns | |
|---|---|
float |
the height at the start |
getStartWidth
public float getStartWidth()
get the width of the widget at the start of the movement.
| Returns | |
|---|---|
float |
the width at the start |
getStartX
public float getStartX()
get the left most position of the widget at the start of the movement.
| Returns | |
|---|---|
float |
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 | |
|---|---|
float |
the top most position |
getTransformPivotTarget
public int getTransformPivotTarget()
Get the view to pivot around
| Returns | |
|---|---|
int |
id of view or UNSET if not set |
interpolate
public boolean interpolate(
MotionWidget child,
float globalPosition,
long time,
KeyCache keyCache
)
The main driver of interpolation
| Returns | |
|---|---|
boolean |
do you need to keep animating |
setStaggerOffset
public void setStaggerOffset(float staggerOffset)
set the offset used in calculating stagger launches
| Parameters | |
|---|---|
float staggerOffset |
fraction of progress before this controller runs |
setStartState
public void setStartState(
ViewState rect,
MotionWidget v,
int rotation,
int preWidth,
int preHeight
)
setTransformPivotTarget
public void setTransformPivotTarget(int transformPivotTarget)
Set a view to pivot around
| Parameters | |
|---|---|
int transformPivotTarget |
id of view |
setValue
public boolean setValue(int id, boolean value)
Used to set boolean values
| Returns | |
|---|---|
boolean |
true if it accepted the value |
setValue
public boolean setValue(int id, float value)
Used to set float values
| Returns | |
|---|---|
boolean |
true if it accepted the value |
setValue
public boolean setValue(int id, int value)
Used to set integer values
| Returns | |
|---|---|
boolean |
true if it accepted the value |
setValue
public boolean setValue(int id, String value)
Used to set String values
| Returns | |
|---|---|
boolean |
true if it accepted the value |
setup
public void setup(
int parentWidth,
int parentHeight,
float transitionDuration,
long currentTime
)
Called after all TimePoints &Cycles have been added; Spines are evaluated
setupRelative
public void setupRelative(Motion motionController)
set up the motion to be relative to this other motionController