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();
}
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;
}
}
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;
}
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;
}
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();
}
Aggregations