Example usage for android.view ScaleGestureDetector getFocusX

List of usage examples for android.view ScaleGestureDetector getFocusX

Introduction

In this page you can find the example usage for android.view ScaleGestureDetector getFocusX.

Prototype

public float getFocusX() 

Source Link

Document

Get the X coordinate of the current gesture's focal point.

Usage

From source file:com.hippo.largeimageview.GestureRecognizer.java

@Override
public boolean onScale(ScaleGestureDetector detector) {
    mScale = true;//from w w  w  .  j  ava  2 s .c om
    mListener.onScale(detector.getFocusX(), detector.getFocusY(), detector.getScaleFactor());
    return true;
}

From source file:org.ros.android.view.visualization.layer.CameraControlLayer.java

@Override
public void onStart(final VisualizationView view, ConnectedNode connectedNode) {
    view.post(new Runnable() {
        @Override/*from w  w  w  . j  a  va  2 s . c o m*/
        public void run() {
            translateGestureDetector = new GestureDetectorCompat(view.getContext(),
                    new GestureDetector.SimpleOnGestureListener() {
                        @Override
                        public boolean onDown(MotionEvent e) {
                            // This must return true in order for onScroll() to trigger.
                            return true;
                        }

                        @Override
                        public boolean onScroll(MotionEvent event1, MotionEvent event2, final float distanceX,
                                final float distanceY) {
                            view.getCamera().translate(-distanceX, distanceY);
                            listeners.signal(new SignalRunnable<CameraControlListener>() {
                                @Override
                                public void run(CameraControlListener listener) {
                                    listener.onTranslate(-distanceX, distanceY);
                                }
                            });
                            return true;
                        }

                        @Override
                        public boolean onDoubleTap(final MotionEvent e) {
                            listeners.signal(new SignalRunnable<CameraControlListener>() {
                                @Override
                                public void run(CameraControlListener listener) {
                                    listener.onDoubleTap(e.getX(), e.getY());
                                }
                            });
                            return true;
                        }
                    });
            rotateGestureDetector = new RotateGestureDetector(
                    new RotateGestureDetector.OnRotateGestureListener() {
                        @Override
                        public boolean onRotate(MotionEvent event1, MotionEvent event2,
                                final double deltaAngle) {
                            final float focusX = (event1.getX(0) + event1.getX(1)) / 2;
                            final float focusY = (event1.getY(0) + event1.getY(1)) / 2;
                            view.getCamera().rotate(focusX, focusY, deltaAngle);
                            listeners.signal(new SignalRunnable<CameraControlListener>() {
                                @Override
                                public void run(CameraControlListener listener) {
                                    listener.onRotate(focusX, focusY, deltaAngle);
                                }
                            });
                            return true;
                        }
                    });
            zoomGestureDetector = new ScaleGestureDetector(view.getContext(),
                    new ScaleGestureDetector.SimpleOnScaleGestureListener() {
                        @Override
                        public boolean onScale(ScaleGestureDetector detector) {
                            if (!detector.isInProgress()) {
                                return false;
                            }
                            final float focusX = detector.getFocusX();
                            final float focusY = detector.getFocusY();
                            final float factor = detector.getScaleFactor();
                            view.getCamera().zoom(focusX, focusY, factor);
                            listeners.signal(new SignalRunnable<CameraControlListener>() {
                                @Override
                                public void run(CameraControlListener listener) {
                                    listener.onZoom(focusX, focusY, factor);
                                }
                            });
                            return true;
                        }
                    });
        }
    });
}

From source file:cn.goodjobs.common.view.photodraweeview.ScaleDragDetector.java

@Override
public boolean onScale(ScaleGestureDetector detector) {
    float scaleFactor = detector.getScaleFactor();

    if (Float.isNaN(scaleFactor) || Float.isInfinite(scaleFactor)) {
        return false;
    }/*from   w ww  .j  av a2  s.c  o m*/

    mScaleDragGestureListener.onScale(scaleFactor, detector.getFocusX(), detector.getFocusY());
    return true;
}

From source file:am.widget.scalerecyclerview.ScaleRecyclerView.java

/**
 * ??//  ww  w .  j av a  2  s.  co  m
 *
 * @param detector 
 */
protected void dispatchScaleEnd(ScaleGestureDetector detector) {
    onScaleEnd(mScale, detector.getFocusX(), detector.getFocusY());
}

From source file:am.widget.scalerecyclerview.ScaleRecyclerView.java

/**
 * ?/* w  w  w. j  av a 2 s  .c  om*/
 *
 * @param detector 
 * @return ??
 */
protected boolean dispatchScaleBegin(ScaleGestureDetector detector) {
    onScaleBegin(mScale, detector.getFocusX(), detector.getFocusY());
    return true;
}

From source file:am.widget.scalerecyclerview.ScaleRecyclerView.java

/**
 * ?/*from w w  w.ja  va2  s .  c  om*/
 *
 * @param detector 
 * @return ??
 */
protected boolean dispatchScale(ScaleGestureDetector detector) {
    onScale(mScale * detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY());
    return true;
}

From source file:org.mozilla.gecko.ui.PanZoomController.java

@Override
public void onScaleEnd(ScaleGestureDetector detector) {
    mState = PanZoomState.PANNING_HOLD;//from  ww  w . j a  v  a2 s  .c  om
    mLastTimestamp = System.currentTimeMillis();
    mX.touchPos = detector.getFocusX();
    mY.touchPos = detector.getFocusY();
}

From source file:org.mozilla.gecko.ui.PanZoomController.java

@Override
public boolean onScale(ScaleGestureDetector detector) {
    mState = PanZoomState.PINCHING;/*from ww  w  .java2  s.  com*/
    float newZoom = detector.getCurrentSpan() / mInitialZoomSpan;

    IntSize screenSize = mController.getScreenSize();
    float x = mInitialZoomFocus.x - (detector.getFocusX() / newZoom);
    float y = mInitialZoomFocus.y - (detector.getFocusY() / newZoom);
    float width = screenSize.width / newZoom;
    float height = screenSize.height / newZoom;
    mController.setVisibleRect(x, y, width, height);
    mController.notifyLayerClientOfGeometryChange();
    populatePositionAndLength();
    return true;
}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

private ScaleGestureDetector getTwoFingerGestureDetector(final XYPlot plot) {
    ScaleGestureDetector.SimpleOnScaleGestureListener gestureListener = new ScaleGestureDetector.SimpleOnScaleGestureListener() {
        @Override//from   ww  w. java2  s  .c om
        public boolean onScale(ScaleGestureDetector detector) {
            float factor = detector.getPreviousSpan() / detector.getCurrentSpan();
            float pixelX = detector.getFocusX();
            RectF gridRect = plot.getGraphWidget().getGridRect();
            // getXVal throws IAE if the X value is outside of the rectangle
            if (gridRect.contains(pixelX, gridRect.top)) {
                double pivot = plot.getGraphWidget().getXVal(pixelX);
                zoom(factor, pivot);
            }

            plot.setDomainBoundaries(minX, maxX, BoundaryMode.FIXED);
            redrawPlot(plot);
            return true;
        }
    };

    return new ScaleGestureDetector(getActivity(), gestureListener);
}

From source file:org.mozilla.gecko.ui.PanZoomController.java

@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
    mState = PanZoomState.PINCHING;/* ww w  .j av a 2 s.co m*/
    FloatRect initialZoomRect = mController.getVisibleRect();
    float initialZoom = mController.getZoomFactor();

    mInitialZoomFocus = new FloatPoint(initialZoomRect.x + (detector.getFocusX() / initialZoom),
            initialZoomRect.y + (detector.getFocusY() / initialZoom));
    mInitialZoomSpan = detector.getCurrentSpan() / initialZoom;
    return true;
}