Search in sources :

Example 96 with PointF

use of android.graphics.PointF in project StreetComplete by westnordost.

the class MainActivity method onLeaveNote.

@Override
public void onLeaveNote(String note, ArrayList<String> imagePaths, Point screenPosition) {
    int[] mapPosition = new int[2];
    View mapView = mapFragment.getView();
    if (mapView == null)
        return;
    mapView.getLocationInWindow(mapPosition);
    PointF notePosition = new PointF(screenPosition);
    notePosition.offset(-mapPosition[0], -mapPosition[1]);
    LatLon position = mapFragment.getPositionAt(notePosition);
    questController.createNote(note, imagePaths, position);
    unsyncedChangesCounter.increase(null);
    closeBottomSheet();
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) PointF(android.graphics.PointF) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 97 with PointF

use of android.graphics.PointF in project Slide by ccrama.

the class SubsamplingScaleImageView method onSizeChanged.

/**
 * On resize, preserve center and scale. Various behaviours are possible, override this method to use another.
 */
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    PointF sCenter = getCenter();
    if (readySent && sCenter != null) {
        this.anim = null;
        this.pendingScale = scale;
        this.sPendingCenter = sCenter;
    }
}
Also used : PointF(android.graphics.PointF)

Example 98 with PointF

use of android.graphics.PointF in project Slide by ccrama.

the class SubsamplingScaleImageView method vTranslateForSCenter.

/**
 * Get the translation required to place a given source coordinate at the center of the screen, with the center
 * adjusted for asymmetric padding. Accepts the desired scale as an argument, so this is independent of current
 * translate and scale. The result is fitted to bounds, putting the image point as near to the screen center as permitted.
 */
private PointF vTranslateForSCenter(float sCenterX, float sCenterY, float scale) {
    int vxCenter = getPaddingLeft() + (getWidth() - getPaddingRight() - getPaddingLeft()) / 2;
    int vyCenter = getPaddingTop() + (getHeight() - getPaddingBottom() - getPaddingTop()) / 2;
    if (satTemp == null) {
        satTemp = new ScaleAndTranslate(0, new PointF(0, 0));
    }
    satTemp.scale = scale;
    satTemp.vTranslate.set(vxCenter - (sCenterX * scale), vyCenter - (sCenterY * scale));
    fitToBounds(true, satTemp);
    return satTemp.vTranslate;
}
Also used : PointF(android.graphics.PointF) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 99 with PointF

use of android.graphics.PointF in project Slide by ccrama.

the class SubsamplingScaleImageView method limitedSCenter.

/**
 * Given a requested source center and scale, calculate what the actual center will have to be to keep the image in
 * pan limits, keeping the requested center as near to the middle of the screen as allowed.
 */
private PointF limitedSCenter(float sCenterX, float sCenterY, float scale, PointF sTarget) {
    PointF vTranslate = vTranslateForSCenter(sCenterX, sCenterY, scale);
    int vxCenter = getPaddingLeft() + (getWidth() - getPaddingRight() - getPaddingLeft()) / 2;
    int vyCenter = getPaddingTop() + (getHeight() - getPaddingBottom() - getPaddingTop()) / 2;
    float sx = (vxCenter - vTranslate.x) / scale;
    float sy = (vyCenter - vTranslate.y) / scale;
    sTarget.set(sx, sy);
    return sTarget;
}
Also used : PointF(android.graphics.PointF) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 100 with PointF

use of android.graphics.PointF in project Slide by ccrama.

the class SubsamplingScaleImageView method resetScaleAndCenter.

/**
 * Fully zoom out and return the image to the middle of the screen. This might be useful if you have a view pager
 * and want images to be reset when the user has moved to another page.
 */
public final void resetScaleAndCenter() {
    this.anim = null;
    this.pendingScale = limitedScale(0);
    if (isReady()) {
        this.sPendingCenter = new PointF(sWidth() / 2, sHeight() / 2);
    } else {
        this.sPendingCenter = new PointF(0, 0);
    }
    invalidate();
}
Also used : PointF(android.graphics.PointF)

Aggregations

PointF (android.graphics.PointF)686 Paint (android.graphics.Paint)132 Point (android.graphics.Point)53 RectF (android.graphics.RectF)53 Matrix (android.graphics.Matrix)43 Test (org.junit.Test)40 Path (android.graphics.Path)29 View (android.view.View)28 Drawable (android.graphics.drawable.Drawable)23 ArrayList (java.util.ArrayList)23 MotionEvent (android.view.MotionEvent)22 NonNull (android.support.annotation.NonNull)21 Rect (android.graphics.Rect)18 ValueAnimator (android.animation.ValueAnimator)14 ViewGroup (android.view.ViewGroup)11 List (java.util.List)11 Animator (android.animation.Animator)10 Bitmap (android.graphics.Bitmap)10 GestureDetector (android.view.GestureDetector)10 LinearSmoothScroller (android.support.v7.widget.LinearSmoothScroller)9