Class 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.

    • 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 java.lang.String 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)
        set up the motion to be relative to this other 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:
        toString in class java.lang.Object
      • 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 time
        locationX - 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=Trigger
        pos - 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: TypedValues
        Used to set integer values
        Specified by:
        setValue in interface TypedValues
        Returns:
        true if it accepted the value
      • setValue

        public boolean setValue​(int id,
                                float value)
        Description copied from interface: TypedValues
        Used to set float values
        Specified by:
        setValue in interface TypedValues
        Returns:
        true if it accepted the value
      • setValue

        public boolean setValue​(int id,
                                java.lang.String value)
        Description copied from interface: TypedValues
        Used to set String values
        Specified by:
        setValue in interface TypedValues
        Returns:
        true if it accepted the value
      • setValue

        public boolean setValue​(int id,
                                boolean value)
        Description copied from interface: TypedValues
        Used to set boolean values
        Specified by:
        setValue in interface TypedValues
        Returns:
        true if it accepted the value
      • getId

        public int getId​(java.lang.String name)
        Specified by:
        getId in interface TypedValues
      • 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
      • setIdString

        public void setIdString​(java.lang.String stringId)