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(float x, float y) 

Source Link

Usage

From source file:com.android.audiorecorder.gallery.widget.GalleryViewPager.java

private float[] handleMotionEvent(MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        last = new PointF(event.getX(0), event.getY(0));
        break;//from  www. j a v a2  s.  c o  m
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_UP:
        PointF curr = new PointF(event.getX(0), event.getY(0));
        return new float[] { curr.x - last.x, curr.y - last.y };

    }
    return null;
}

From source file:org.mozilla.gecko.gfx.PointUtils.java

public static PointF interpolate(PointF startPoint, PointF endPoint, float weight) {
    float x = FloatUtils.interpolate(startPoint.x, endPoint.x, weight);
    float y = FloatUtils.interpolate(startPoint.y, endPoint.y, weight);
    return new PointF(x, y);
}

From source file:com.putao.widget.touchgallery.GalleryWidget.GalleryViewPager.java

@TargetApi(Build.VERSION_CODES.ECLAIR)
private float[] handleMotionEvent(MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        last = new PointF(event.getX(0), event.getY(0));
        break;/*from   w w  w  .j a va  2  s .co m*/
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_UP:
        PointF curr = new PointF(event.getX(0), event.getY(0));
        return new float[] { curr.x - last.x, curr.y - last.y };
    }
    return null;
}

From source file:cn.dreamtobe.touchgallery.GalleryWidget.GalleryViewPager.java

@TargetApi(Build.VERSION_CODES.ECLAIR)
private float[] handleMotionEvent(MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        last = new PointF(event.getX(0), event.getY(0));
        break;//from  ww  w  .jav  a  2 s. co m
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_UP:
        PointF curr = new PointF(event.getX(0), event.getY(0));
        return new float[] { curr.x - last.x, curr.y - last.y };

    }
    return null;
}

From source file:cn.iotguard.GalleryWidget.GalleryViewPager.java

private float[] handleMotionEvent(MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        last = new PointF(event.getX(0), event.getY(0));
        ////ww  w .j  a  va 2s  .c o m
        if (GalleryFileActivity.ll_dibumenu != null
                && GalleryFileActivity.ll_dibumenu.getVisibility() == View.GONE) {
            GalleryFileActivity.ll_dibumenu.setVisibility(View.VISIBLE);
        }
        if (Show_bigpic2.ll_dibumenu != null && Show_bigpic2.ll_dibumenu.getVisibility() == View.GONE) {
            Show_bigpic2.ll_dibumenu.setVisibility(View.VISIBLE);
        }

        //
        if (GalleryFileActivity.timeCount != null) {
            GalleryFileActivity.timeCount.cancel();
        }
        GalleryFileActivity.timeCount = new TimeCount_pic_dibu(Millis.pic_dibus, 1000);
        GalleryFileActivity.timeCount.start();
        System.out.println("pic    ");
        if (Show_bigpic2.timeCount != null) {
            Show_bigpic2.timeCount.cancel();
        }
        Show_bigpic2.timeCount = new TimeCount_pic_dibu_showbigpic2(Millis.pic_dibus, 1000);
        Show_bigpic2.timeCount.start();

        break;
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_UP:
        PointF curr = new PointF(event.getX(0), event.getY(0));
        return new float[] { curr.x - last.x, curr.y - last.y };

    }
    return null;
}

From source file:cn.limc.androidcharts.event.SlipGestureDetector.java

public boolean onTouchEvent(MotionEvent event) {
    int pointers = event.getPointerCount();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    // ?/*w  w w  . ja v  a2s .c  o  m*/
    case MotionEvent.ACTION_DOWN:
        initalX = event.getX();
        if (pointers > 1) {
            touchMode = TOUCH_MODE_MULTI;
        } else {
            touchMode = TOUCH_MODE_SINGLE;
        }
        break;
    case MotionEvent.ACTION_UP:
        startPointA = null;
        startPointB = null;
        break;
    case MotionEvent.ACTION_POINTER_UP:
        startPointA = null;
        startPointB = null;
    case MotionEvent.ACTION_POINTER_DOWN:
        olddistance = calcDistance(event);
        if (olddistance > MIN_DISTANCE) {
            touchMode = TOUCH_MODE_MULTI;
            startPointA = new PointF(event.getX(0), event.getY(0));
            startPointB = new PointF(event.getX(1), event.getY(1));
        }
        return true;
    case MotionEvent.ACTION_MOVE:
        if (touchMode == TOUCH_MODE_SINGLE) {
            final float finalX = event.getX();
            // MotionEvent finalEvent = event;
            if (performLongClick) {
                return super.onTouchEvent(event);
            } else {
                if (finalX - initalX >= mStickScaleValue) {
                    if (onSlipGestureListener != null) {
                        onSlipGestureListener.onMoveRight((ISlipable) instance, event);
                    }
                } else if (initalX - finalX >= mStickScaleValue) {
                    if (onSlipGestureListener != null) {
                        onSlipGestureListener.onMoveLeft((ISlipable) instance, event);
                    }
                }
                initalX = finalX;
                // initalEvent = finalEvent;
                return true;
            }
        } else if (touchMode == TOUCH_MODE_MULTI) {
            newdistance = calcDistance(event);
            if (Math.abs(newdistance - olddistance) > MIN_DISTANCE) {
                if (onZoomGestureListener != null) {
                    if (newdistance > olddistance) {
                        onZoomGestureListener.onZoomIn((IZoomable) instance, event);
                    } else {
                        onZoomGestureListener.onZoomOut((IZoomable) instance, event);
                    }
                }
            }
            olddistance = newdistance;
            return true;
            // startPointA = new PointF(event.getX(), event.getY());
            // startPointB = new PointF(event.getX(1), event.getY(1));
        }
        break;
    }
    return super.onTouchEvent(event);
}

From source file:com.support.design.activity.CheeseDetailActivity.java

private void loadBackdrop() {
    final SimpleDraweeView mDraweeView = (SimpleDraweeView) findViewById(R.id.backdrop);
    mDraweeView.getHierarchy().setActualImageFocusPoint(new PointF(0.5f, 0.35f));
    mDraweeView.setImageURI(Uri.parse(mImageUrl));
}

From source file:com.hookedonplay.decoviewsample.SamplePeopleFragment.java

@Override
protected void createTracks() {
    setDemoFinished(false);//  w  w w. ja va 2 s . co  m
    final DecoView decoView = getDecoView();
    final View view = getView();
    if (decoView == null || view == null) {
        return;
    }

    view.setBackgroundColor(Color.argb(255, 128, 218, 128));

    decoView.executeReset();
    decoView.deleteAll();

    float circleInset = getDimension(23) - (getDimension(46) * 0.3f);
    SeriesItem seriesBack1Item = new SeriesItem.Builder(COLOR_BACK).setRange(0, mSeriesMax, mSeriesMax)
            .setChartStyle(SeriesItem.ChartStyle.STYLE_PIE).setInset(new PointF(circleInset, circleInset))
            .build();

    mBack1Index = decoView.addSeries(seriesBack1Item);

    SeriesItem series1Item = new SeriesItem.Builder(COLOR_BLUE).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Men").build()).setCapRounded(false)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries1Index = decoView.addSeries(series1Item);

    SeriesItem series2Item = new SeriesItem.Builder(COLOR_PINK).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Women").build()).setCapRounded(false)
            //.setChartStyle(SeriesItem.ChartStyle.STYLE_PIE)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries2Index = decoView.addSeries(series2Item);

    SeriesItem series3Item = new SeriesItem.Builder(COLOR_YELLOW).setRange(0, mSeriesMax, 0)
            .setInitialVisibility(false).setLineWidth(getDimension(46))
            .setSeriesLabel(new SeriesLabel.Builder("Children").build()).setCapRounded(false)
            //.setChartStyle(SeriesItem.ChartStyle.STYLE_PIE)
            .addEdgeDetail(new EdgeDetail(EdgeDetail.EdgeType.EDGE_INNER, COLOR_EDGE, 0.3f))
            .setShowPointWhenEmpty(false).build();

    mSeries3Index = decoView.addSeries(series3Item);

}

From source file:com.liangxun.yuejiula.galleryweidget.GalleryViewPager.java

@TargetApi(Build.VERSION_CODES.ECLAIR)
private float[] handleMotionEvent(MotionEvent event) {
    try {//w w w . j av a2  s .  c o  m
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            last = new PointF(event.getX(0), event.getY(0));
            break;
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
            PointF curr = new PointF(event.getX(0), event.getY(0));
            return new float[] { curr.x - last.x, curr.y - last.y };

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.imczy.customactivitytransition.transition.ShareElemReturnChangePosition.java

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (null == startValues || null == endValues) {
        return null;
    }/*ww  w.  j  av a 2  s  .  c  o m*/

    if (startValues.view.getId() > 0) {
        Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION);
        Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION);

        final View view = endValues.view;

        Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(),
                endRect.centerX(), endRect.centerY() - endRect.height() / 2);

        ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position",
                new PointF(startRect.centerX(), startRect.centerY())), null, changePosPath);
        objectAnimator.setInterpolator(new FastOutSlowInInterpolator());

        return objectAnimator;
    }
    return null;

}