Example usage for android.graphics PointF PointF

List of usage examples for android.graphics PointF PointF

Introduction

In this page you can find the example usage for android.graphics PointF PointF.

Prototype

public PointF() 

Source Link

Usage

From source file:xyz.zpayh.hdimage.HDImageView.java

public final PointF sourceToViewCoordinate(float sx, float sy) {
    return sourceToViewCoordinate(sx, sy, new PointF());
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Sets scale and translate ready for the next draw.
 *///from   w w  w . jav  a  2s .  c  o  m
private void preDraw() {
    if (getWidth() == 0 || getHeight() == 0 || sWidth <= 0 || sHeight <= 0) {
        return;
    }

    // If waiting to translate to new center position, set translate now
    if (sPendingCenter != null && pendingScale != null) {
        setScale(pendingScale);
        if (vTranslate == null) {
            vTranslate = new PointF();
        }
        vTranslate.x = (getWidth() / 2) - (scale * sPendingCenter.x);
        vTranslate.y = (getHeight() / 2) - (scale * sPendingCenter.y);
        sPendingCenter = null;
        pendingScale = null;
        fitToBounds(true);
        refreshRequiredTiles(true);
    }

    // On first display of base image set up position, and in other cases make sure scale is correct.
    fitToBounds(false);
}

From source file:xyz.zpayh.hdimage.HDImageView.java

private void startZoomForCenter(PointF sCenter, float scaleEnd) {
    if (mValueAnimator != null) {
        mValueAnimator.cancel();//from   w w  w  . j a  v a  2  s .  c o  m
    }
    final int vxCenter = (getWidth() + getPaddingLeft() - getPaddingRight()) / 2;
    final int vyCenter = (getHeight() + getPaddingTop() - getPaddingBottom()) / 2;

    final float limitScale = limitedScale(scaleEnd);

    final PointF limitSourceCenter = limitedSourceCenter(sCenter.x, sCenter.y, limitScale, new PointF());

    mValueAnimator = new AnimationBuilder(limitSourceCenter).setTarget(this).setScaleStart(mScale)
            .setScaleEnd(limitScale).setViewFocusStart(sourceToViewCoordinate(limitSourceCenter))
            .setViewFocusEnd(new PointF(vxCenter, vyCenter)).setDuration(mDuration).setInterrupt(false)
            .setTranslateInterpolator(mTranslationAnimationInterpolator)
            .setScaleInterpolator(mScaleAnimationInterpolator).addAnimationListener(mAnimatorListener)
            .addAnimationListener(mAnimatorListenerCompat).addAnimationUpdateListener(mAnimatorUpdateListener)
            .addAnimationUpdateListener(mAnimatorUpdateListenerCompat).build();

    mValueAnimator.start();

    Log.d(TAG, "startZoomForCenter");
}

From source file:xyz.zpayh.hdimage.HDImageView.java

private void startZoomForFixed(PointF sCenter, PointF vFocus, float scaleEnd) {

    if (mValueAnimator != null) {
        mValueAnimator.cancel();/*from  w w w . j a  va  2s .  c  om*/
    }

    final float limitScale = limitedScale(scaleEnd);

    final PointF limitSourceCenter = limitedSourceCenter(sCenter.x, sCenter.y, limitScale, new PointF());

    PointF focusEnd;
    if (vFocus != null) {
        PointF center = getCenter();
        float vTranslateXEnd = vFocus.x - (limitScale * center.x);
        float vTranslateYEnd = vFocus.y - (limitScale * center.y);
        ScaleAndTranslate satEnd = new ScaleAndTranslate(limitScale,
                new PointF(vTranslateXEnd, vTranslateYEnd));
        fitToBounds(true, satEnd);
        focusEnd = new PointF(vFocus.x + (satEnd.mViewTranslate.x - vTranslateXEnd),
                vFocus.y + (satEnd.mViewTranslate.y - vTranslateYEnd));
    } else {
        final int vxCenter = (getWidth() + getPaddingLeft() - getPaddingRight()) / 2;
        final int vyCenter = (getHeight() + getPaddingTop() - getPaddingBottom()) / 2;
        focusEnd = new PointF(vxCenter, vyCenter);
    }

    mValueAnimator = new AnimationBuilder(limitSourceCenter).setTarget(this).setScaleStart(mScale)
            .setScaleEnd(limitScale).setViewFocusStart(sourceToViewCoordinate(limitSourceCenter))
            .setViewFocusEnd(focusEnd).setDuration(mDuration).setInterrupt(false)
            .setTranslateInterpolator(mTranslationAnimationInterpolator)
            .setScaleInterpolator(mScaleAnimationInterpolator).addAnimationListener(mAnimatorListener)
            .addAnimationListener(mAnimatorListenerCompat).addAnimationUpdateListener(mAnimatorUpdateListener)
            .addAnimationUpdateListener(mAnimatorUpdateListenerCompat).build();

    mValueAnimator.start();

    Log.d(TAG, "startZoomForFixed");
}

From source file:cn.ismartv.tvrecyclerview.widget.StaggeredGridLayoutManager.java

@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
    final int direction = calculateScrollDirectionForPosition(targetPosition);
    PointF outVector = new PointF();
    if (direction == 0) {
        return null;
    }//from   w ww  .j a  va  2  s.c om
    if (mOrientation == HORIZONTAL) {
        outVector.x = direction;
        outVector.y = 0;
    } else {
        outVector.x = 0;
        outVector.y = direction;
    }
    return outVector;
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Convert screen coordinate to source coordinate.
 *//*from   www .  j  a v  a  2s. c  o  m*/
public final PointF viewToSourceCoord(PointF vxy) {
    return viewToSourceCoord(vxy.x, vxy.y, new PointF());
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Convert screen coordinate to source coordinate.
 *///from  www  .j  ava2  s.c  om
public final PointF viewToSourceCoord(float vx, float vy) {
    return viewToSourceCoord(vx, vy, new PointF());
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Convert source coordinate to screen coordinate.
 *//*from   w  ww .j a  va 2 s.  co m*/
public final PointF sourceToViewCoord(PointF sxy) {
    return sourceToViewCoord(sxy.x, sxy.y, new PointF());
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Convert source coordinate to screen coordinate.
 *///from ww  w.j a v a  2s  .c  o m
public final PointF sourceToViewCoord(float sx, float sy) {
    return sourceToViewCoord(sx, sy, new PointF());
}