android.graphics.PointF Java Examples
The following examples show how to use
android.graphics.PointF.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: document-viewer Author: SufficientlySecure File: TouchManagerView.java License: GNU General Public License v3.0 | 6 votes |
protected Region getRegion(final PointF startPoint, final PointF endPoint) { final float width = getWidth(); final float height = getHeight(); final float xStep = width / GRID_X; final float yStep = height / GRID_Y; final float cellWidth = 100 / GRID_X; final float cellHeight = 100 / GRID_X; float left = MathUtils.fmin(startPoint.x, endPoint.x); float right = MathUtils.fmax(startPoint.x, endPoint.x); float top = MathUtils.fmin(startPoint.y, endPoint.y); float bottom = MathUtils.fmax(startPoint.y, endPoint.y); left = cellWidth * (float) Math.floor(left / xStep); right = cellWidth * (float) Math.floor(right / xStep) + cellWidth; top = cellHeight * (float) Math.floor(top / yStep); bottom = cellHeight * (float) Math.floor(bottom / yStep) + cellHeight; return new Region(MathUtils.rect(left, top, right, bottom)); }
Example #2
Source Project: BLE-Indoor-Positioning Author: neXenio File: BeaconMap.java License: Apache License 2.0 | 6 votes |
protected void drawDeviceHistory(Canvas canvas) { PointF deviceCenter; float heatmapRadius = (float) canvasProjection.getCanvasUnitsFromMeters(1); float recencyScore; int alpha; for (Location location : recentLocations) { if (location == null || !location.hasLatitudeAndLongitude()) { continue; } deviceCenter = getPointFromLocation(location); recencyScore = getRecencyScore(location.getTimestamp(), TimeUnit.SECONDS.toMillis(10)); alpha = (int) (255 * 0.25 * recencyScore); historyFillPaint.setAlpha(alpha); RadialGradient gradient = new RadialGradient(deviceCenter.x, deviceCenter.y, heatmapRadius, new int[]{secondaryFillPaint.getColor(), Color.TRANSPARENT}, null, Shader.TileMode.CLAMP); historyFillPaint.setShader(gradient); canvas.drawCircle(deviceCenter.x, deviceCenter.y, heatmapRadius, historyFillPaint); } }
Example #3
Source Project: GestureViews Author: alexvasilkov File: ImageControlActivity.java License: Apache License 2.0 | 6 votes |
private void resetImage(boolean animate) { final GestureController controller = imageView.getController(); if (controller.isAnimating()) { return; // Waiting for animation end } if (animate) { final State state = controller.getState().copy(); final PointF pivot = getPivot(); // Restoring initial image zoom and rotation final float minZoom = controller.getStateController().getMinZoom(state); state.zoomTo(minZoom, pivot.x, pivot.y); state.rotateTo(0f, pivot.x, pivot.y); // Animating state changes. Do not forget to make a state's copy prior to any changes. controller.setPivot(pivot.x, pivot.y); controller.animateStateTo(state); } else { // Immediately resetting the state controller.resetState(); } }
Example #4
Source Project: GLEXP-Team-onebillion Author: XPRIZE File: OC_PlayZoneMenu.java License: Apache License 2.0 | 6 votes |
public void moveMediaIconsBySpeedFrac(float frameFrac) { float speedX = (float)mediaIconsGroup.propertyValue("speedx"); if(speedX == 0) return; PointF loc = OBMisc.copyPoint(mediaIconsGroup.position()); loc.x += speedX * frameFrac; float decay = (float)Math.pow(0.99f,frameFrac); if(Math.abs(speedX) > MAX_SPEED*0.1) speedX *= decay; else speedX = 0; if(!setMediaIconsGroupLoc(loc)) { setControlSpeed(mediaIconsGroup,0.0f,0.0f); } else { setControlSpeed(mediaIconsGroup,speedX,0.0f); } }
Example #5
Source Project: GLEXP-Team-onebillion Author: XPRIZE File: OC_SectionIT.java License: Apache License 2.0 | 6 votes |
public void setUpDragObjectsForEvent(String ev) { Map<String,Object> event = (Map<String, Object>) eventsDict.get(ev); Map<String, Map<String, Object>> objectsdict = (Map<String, Map<String, Object>>) event.get("objectsdict"); for (String k : objectsdict.keySet()) { OBControl c = objectDict.get(k); PointF pt = c.position(); c.setProperty("origpos",new PointF(pt.x,pt.y)); c.setProperty("destpos",pointFromObjectsDict(objectsdict,k)); Map<String,Object>odict = objectsdict.get(k); Map<String,Object>oattrs = (Map<String, Object>) odict.get("attrs"); String fstr = (String) oattrs.get("scalex"); if (fstr != null) { c.setProperty("scale",c.scale()); float f = Float.parseFloat(fstr); c.setProperty("destscale",f); } c.setProperty("destcontainer",oattrs.get("parent")); } }
Example #6
Source Project: 365browser Author: mogoweb File: Layout.java License: Apache License 2.0 | 6 votes |
/** * @param e The {@link MotionEvent} to consider. * @param offsets The current touch offsets that should be applied to the * {@link EventFilter}s. * @param isKeyboardShowing Whether or not the keyboard is showing. * @return The {@link EventFilter} the {@link Layout} is listening to. */ public EventFilter findInterceptingEventFilter( MotionEvent e, PointF offsets, boolean isKeyboardShowing) { // The last added overlay will be drawn on top of everything else, therefore the last // filter added should have the first chance to intercept any touch events. for (int i = mSceneOverlays.size() - 1; i >= 0; i--) { EventFilter eventFilter = mSceneOverlays.get(i).getEventFilter(); if (eventFilter == null) continue; if (offsets != null) eventFilter.setCurrentMotionEventOffsets(offsets.x, offsets.y); if (eventFilter.onInterceptTouchEvent(e, isKeyboardShowing)) return eventFilter; } EventFilter layoutEventFilter = getEventFilter(); if (layoutEventFilter != null) { if (offsets != null) { layoutEventFilter.setCurrentMotionEventOffsets(offsets.x, offsets.y); } if (layoutEventFilter.onInterceptTouchEvent(e, isKeyboardShowing)) { return layoutEventFilter; } } return null; }
Example #7
Source Project: CrazyDaily Author: crazysunj File: NotePreviewActivity.java License: Apache License 2.0 | 6 votes |
private void handlePreViewImageItem(int index, List<String> data, List<ImagePreViewAdapter.ImagePreViewEntity> imageData, OnCompleteListener listener) { String original = data.get(index); ImageLoader.download(this, original, file -> { if (file == null) { listener.onComplete(null); return; } String absolutePath = file.getAbsolutePath(); float imageScale = getImageScale(absolutePath); imageData.add(new ImagePreViewAdapter.ImagePreViewEntity(original, absolutePath, imageScale + 3.0f, ImageSource.uri(Uri.fromFile(file)), new ImageViewState(imageScale, new PointF(0, 0), 0))); final int nextIndex = index + 1; if (nextIndex == data.size()) { listener.onComplete(imageData); } else { handlePreViewImageItem(nextIndex, data, imageData, listener); } }); }
Example #8
Source Project: Lassi-Android Author: Mindinventory File: Camera1.java License: MIT License | 6 votes |
@Override void setExposureCorrection(final float EVvalue, @NonNull final float[] bounds, @Nullable final PointF[] points, final boolean notify) { schedule(mExposureCorrectionTask, true, new Runnable() { @Override public void run() { if (!mCameraOptions.isExposureCorrectionSupported()) return; float value = EVvalue; float max = mCameraOptions.getExposureCorrectionMaxValue(); float min = mCameraOptions.getExposureCorrectionMinValue(); value = value < min ? min : value > max ? max : value; // cap mExposureCorrectionValue = value; Camera.Parameters params = mCamera.getParameters(); int indexValue = (int) (value / params.getExposureCompensationStep()); params.setExposureCompensation(indexValue); mCamera.setParameters(params); if (notify) { mCameraCallbacks.dispatchOnExposureCorrectionChanged(value, bounds, points); } } }); }
Example #9
Source Project: Machine-Learning-Projects-for-Mobile-Applications Author: PacktPublishing File: FaceGraphic.java License: MIT License | 6 votes |
private void drawHat(Canvas canvas, PointF facePosition, float faceWidth, float faceHeight, PointF noseBasePosition) { final float HAT_FACE_WIDTH_RATIO = (float)(4.0 / 4.0); final float HAT_FACE_HEIGHT_RATIO = (float)(3.0 / 6.0); final float HAT_CENTER_Y_OFFSET_FACTOR = (float)(1.0 / 8.0); float hatCenterY = facePosition.y + (faceHeight * HAT_CENTER_Y_OFFSET_FACTOR); float hatWidth = faceWidth * HAT_FACE_WIDTH_RATIO; float hatHeight = faceHeight * HAT_FACE_HEIGHT_RATIO; int left = (int)(noseBasePosition.x - (hatWidth / 2)); int right = (int)(noseBasePosition.x + (hatWidth / 2)); int top = (int)(hatCenterY - (hatHeight / 2)); int bottom = (int)(hatCenterY + (hatHeight / 2)); mHatGraphic.setBounds(left, top, right, bottom); mHatGraphic.draw(canvas); }
Example #10
Source Project: ViewPagerTabIndicator Author: gdutxiaoxu File: GestureImageView.java License: Artistic License 2.0 | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); viewSize = new PointF(width, height); //��ȡ��ǰDrawable�Ĵ�С Drawable drawable = getDrawable(); if (drawable == null) { Log.e("no drawable", "drawable is nullPtr"); } else { imageSize = new PointF(drawable.getMinimumWidth(), drawable.getMinimumHeight()); } FitCenter(); }
Example #11
Source Project: Matisse-Kotlin Author: NFLeo File: SubsamplingScaleImageView.java License: Apache License 2.0 | 6 votes |
/** * Double tap zoom handler triggered from gesture detector or on touch, depending on whether * quick scale is enabled. */ private void doubleTapZoom(PointF sCenter, PointF vFocus) { if (!panEnabled) { if (sRequestedCenter != null) { // With a center specified from code, zoom around that point. sCenter.x = sRequestedCenter.x; sCenter.y = sRequestedCenter.y; } else { // With no requested center, scale around the image center. sCenter.x = sWidth()/2; sCenter.y = sHeight()/2; } } float doubleTapZoomScale = Math.min(maxScale, SubsamplingScaleImageView.this.doubleTapZoomScale); boolean zoomIn = scale <= doubleTapZoomScale * 0.9; float targetScale = zoomIn ? doubleTapZoomScale : minScale(); if (doubleTapZoomStyle == ZOOM_FOCUS_CENTER_IMMEDIATE) { setScaleAndCenter(targetScale, sCenter); } else if (doubleTapZoomStyle == ZOOM_FOCUS_CENTER || !zoomIn || !panEnabled) { new AnimationBuilder(targetScale, sCenter).withInterruptible(false).withDuration(doubleTapZoomDuration).withOrigin(ORIGIN_DOUBLE_TAP_ZOOM).start(); } else if (doubleTapZoomStyle == ZOOM_FOCUS_FIXED) { new AnimationBuilder(targetScale, sCenter, vFocus).withInterruptible(false).withDuration(doubleTapZoomDuration).withOrigin(ORIGIN_DOUBLE_TAP_ZOOM).start(); } invalidate(); }
Example #12
Source Project: Study_Android_Demo Author: RealMoMo File: StoreHouseHeader.java License: Apache License 2.0 | 5 votes |
public void initWithPointList(ArrayList<float[]> pointList) { float drawWidth = 0; float drawHeight = 0; boolean shouldLayout = mItemList.size() > 0; mItemList.clear(); for (int i = 0; i < pointList.size(); i++) { float[] line = pointList.get(i); PointF startPoint = new PointF(PtrLocalDisplay.dp2px(line[0]) * mScale, PtrLocalDisplay.dp2px(line[1]) * mScale); PointF endPoint = new PointF(PtrLocalDisplay.dp2px(line[2]) * mScale, PtrLocalDisplay.dp2px(line[3]) * mScale); drawWidth = Math.max(drawWidth, startPoint.x); drawWidth = Math.max(drawWidth, endPoint.x); drawHeight = Math.max(drawHeight, startPoint.y); drawHeight = Math.max(drawHeight, endPoint.y); StoreHouseBarItem item = new StoreHouseBarItem(i, startPoint, endPoint, mTextColor, mLineWidth); item.resetPosition(mHorizontalRandomness); mItemList.add(item); } mDrawZoneWidth = (int) Math.ceil(drawWidth); mDrawZoneHeight = (int) Math.ceil(drawHeight); if (shouldLayout) { requestLayout(); } }
Example #13
Source Project: GLEXP-Team-onebillion Author: XPRIZE File: OC_Puzzle.java License: Apache License 2.0 | 5 votes |
public void checkTarget(OBControl targ,PointF pt) { setStatus(STATUS_DRAGGING); targ.setZPosition(13); dragOffset = OB_Maths.DiffPoints(targ.position(), pt); finishLock.lock(); finishLock.unlockWithCondition(MSE_DN); }
Example #14
Source Project: TurboLauncher Author: Phonemetra File: PagedView.java License: Apache License 2.0 | 5 votes |
public FlingAlongVectorAnimatorUpdateListener(View dragView, PointF vel, Rect from, long startTime, float friction) { mDragView = dragView; mVelocity = vel; mFrom = from; mPrevTime = startTime; mFriction = 1f - (mDragView.getResources().getDisplayMetrics().density * friction); }
Example #15
Source Project: materialup Author: goodev File: DefaultZoomableController.java License: Apache License 2.0 | 5 votes |
/** * Maps point from the view's to the image's relative coordinate system. * This takes into account the zoomable transformation. */ public PointF mapViewToImage(PointF viewPoint) { float[] points = mTempValues; points[0] = viewPoint.x; points[1] = viewPoint.y; mActiveTransform.invert(mActiveTransformInverse); mActiveTransformInverse.mapPoints(points, 0, points, 0, 1); mapAbsoluteToRelative(points, points, 1); return new PointF(points[0], points[1]); }
Example #16
Source Project: hellocharts-android Author: lecho File: ChartComputator.java License: Apache License 2.0 | 5 votes |
/** * Finds the chart point (i.e. within the chart's domain and range) represented by the given pixel coordinates, if * that pixel is within the chart region described by {@link #contentRectMinusAllMargins}. If the point is found, * the "dest" * argument is set to the point and this function returns true. Otherwise, this function returns false and * "dest" is * unchanged. */ public boolean rawPixelsToDataPoint(float x, float y, PointF dest) { if (!contentRectMinusAllMargins.contains((int) x, (int) y)) { return false; } dest.set(currentViewport.left + (x - contentRectMinusAllMargins.left) * currentViewport.width() / contentRectMinusAllMargins.width(), currentViewport.bottom + (y - contentRectMinusAllMargins.bottom) * currentViewport.height() / -contentRectMinusAllMargins.height()); return true; }
Example #17
Source Project: show-case-card-view Author: dimorinny File: TopLeft.java License: Apache License 2.0 | 5 votes |
@Override public PointF getPosition(Activity activity) { return new PointF( NavigationBarUtils.navigationBarMarginForLeftOrientation(activity), 0F ); }
Example #18
Source Project: edx-app-android Author: edx File: SubsamplingScaleImageView.java License: Apache License 2.0 | 5 votes |
/** * 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; }
Example #19
Source Project: FORMWatchFace Author: romannurik File: FormClockView.java License: Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); mHourMinRenderer.updateTime(); PointF hourMinSize = mHourMinRenderer.measure(true); mHourMinRenderer.draw(canvas, (mWidth - hourMinSize.x) / 2, (mHeight - hourMinSize.y) / 2, true, false); mSecondsRenderer.updateTime(); PointF secondsSize = mSecondsRenderer.measure(true); mSecondsRenderer.draw(canvas, (mWidth + hourMinSize.x) / 2 - secondsSize.x, (mHeight + hourMinSize.y) / 2 + TypedValue.applyDimension(5, TypedValue.COMPLEX_UNIT_DIP, getResources().getDisplayMetrics()), true, false); long timeToNextSecondsAnimation = mSecondsRenderer.timeToNextAnimation(); long timeToNextHourMinAnimation = mHourMinRenderer.timeToNextAnimation(); if (timeToNextHourMinAnimation < 0 || timeToNextSecondsAnimation < 0) { postInvalidateOnAnimation(); } else { postInvalidateDelayed(Math.min(timeToNextHourMinAnimation, timeToNextSecondsAnimation)); } }
Example #20
Source Project: android_9.0.0_r45 Author: lulululbj File: PathKeyframes.java License: Apache License 2.0 | 5 votes |
/** * Returns an IntKeyframeSet for the Y component of the Path. * @return an IntKeyframeSet for the Y component of the Path. */ public IntKeyframes createYIntKeyframes() { return new IntKeyframesBase() { @Override public int getIntValue(float fraction) { PointF pointF = (PointF) PathKeyframes.this.getValue(fraction); return Math.round(pointF.y); } }; }
Example #21
Source Project: Learning-Java-by-Building-Android-Games-Second-Edition Author: PacktPublishing File: Level.java License: MIT License | 5 votes |
public Level(Context context, PointF mScreenSize, GameEngine ge){ objects = new ArrayList<>(); GameObjectFactory factory = new GameObjectFactory( context, mScreenSize, ge); buildGameObjects(factory); }
Example #22
Source Project: Telegram Author: DrKLO File: Render.java License: GNU General Public License v2.0 | 5 votes |
private static void PaintStamp(Point point, RenderState state) { float brushWeight = state.baseWeight * state.scale; PointF start = point.toPointF(); float angle = Math.abs(state.angle) > 0.0f ? state.angle : 0.0f; float alpha = state.alpha; state.prepare(); state.appendValuesCount(1); state.addPoint(start, brushWeight, angle, alpha, 0); }
Example #23
Source Project: GLEXP-Team-onebillion Author: XPRIZE File: OC_Numberlines_S1.java License: Apache License 2.0 | 5 votes |
public void finishScene2(OBLabel target) throws Exception { OBLabel largeNum = null; for(OBLabel lab : largeNums) { if(lab.text().equals(target.text())) largeNum =lab; } float width = largeNum.width(), height = largeNum.height(); PointF loc = OBMisc.copyPoint(largeNum.position()); lockScreen(); largeNum.setColour(target.colour()); largeNum.setWidth(target.width()); largeNum.setHeight(target.height()); largeNum.setPosition(target.position()); largeNum.setZPosition(10); target.setColour(Color.BLACK); unlockScreen(); largeNum.show(); OBAnimationGroup.runAnims(Arrays.asList(OBAnim.moveAnim(loc,largeNum), OBAnim.propertyAnim("width",width,largeNum), OBAnim.propertyAnim("height",height,largeNum), OBAnim.colourAnim("colour",largeNumColour,largeNum) ),0.7,true,OBAnim.ANIM_EASE_IN_EASE_OUT,this); lockScreen(); objectDict.get("container1").lowlight(); objectDict.get("container2").lowlight(); unlockScreen(); waitForSecs(0.3f); }
Example #24
Source Project: DevUtils Author: afkT File: ElectricFanLoadingRenderer.java License: Apache License 2.0 | 5 votes |
@Override public void onAnimationUpdate(ValueAnimator animation) { PointF point = (PointF) animation.getAnimatedValue(); target.mLeafRect.set((int) point.x, (int) point.y, (int) (point.x + mLeafDrawable.getIntrinsicWidth()), (int) (point.y + mLeafDrawable.getIntrinsicHeight())); target.mLeafRotation = target.mMaxRotation * animation.getAnimatedFraction(); }
Example #25
Source Project: Learning-Java-by-Building-Android-Games-Second-Edition Author: PacktPublishing File: Transform.java License: MIT License | 5 votes |
PointF getFiringLocation(float laserLength){ PointF mFiringLocation = new PointF(); if(mFacingRight) { mFiringLocation.x = mLocation.x + (mObjectWidth / 8f); }else { mFiringLocation.x = mLocation.x + (mObjectWidth / 8f) - (laserLength); } // Move the height down a bit of ship height from origin mFiringLocation.y = mLocation.y + (mObjectHeight / 1.28f); return mFiringLocation; }
Example #26
Source Project: document-viewer Author: SufficientlySecure File: GLBitmaps.java License: GNU General Public License v3.0 | 5 votes |
protected boolean draw(final GLCanvas canvas, final PointF vb, final RectF tr, final RectF actual) { final float offsetX = tr.left - vb.x; final float offsetY = tr.top - vb.y; final float scaleX = tr.width() / width; final float scaleY = tr.height() / height; final float sizeX = partSize * scaleX; final float sizeY = partSize * scaleY; final RectF src = new RectF(); final RectF rect = new RectF(offsetX, offsetY, offsetX + sizeX, offsetY + sizeY); final RectF r = new RectF(); boolean res = true; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { final int index = row * columns + col; res &= draw(canvas, row, col, this.textures[index], actual, src, rect, r); rect.left += sizeX; rect.right += sizeX; } rect.left = offsetX; rect.right = offsetX + sizeX; rect.top += sizeY; rect.bottom += sizeY; } return res; }
Example #27
Source Project: AndroidDocumentScanner Author: mayuce File: PolygonView.java License: MIT License | 5 votes |
private void setPointsCoordinates(Map<Integer, PointF> pointFMap) { pointer1.setX(pointFMap.get(0).x); pointer1.setY(pointFMap.get(0).y); pointer2.setX(pointFMap.get(1).x); pointer2.setY(pointFMap.get(1).y); pointer3.setX(pointFMap.get(2).x); pointer3.setY(pointFMap.get(2).y); pointer4.setX(pointFMap.get(3).x); pointer4.setY(pointFMap.get(3).y); }
Example #28
Source Project: MoeQuest Author: HotBitmapGG File: PhotoImageView.java License: Apache License 2.0 | 5 votes |
/** * Inverse of transformCoordTouchToBitmap. This function will transform the coordinates in the * drawable's coordinate system to the view's coordinate system. * * @param bx x-coordinate in original bitmap coordinate system * @param by y-coordinate in original bitmap coordinate system * @return Coordinates of the point in the view's coordinate system. */ private PointF transformCoordBitmapToTouch(float bx, float by) { matrix.getValues(m); float origW = getDrawable().getIntrinsicWidth(); float origH = getDrawable().getIntrinsicHeight(); float px = bx / origW; float py = by / origH; float finalX = m[Matrix.MTRANS_X] + getImageWidth() * px; float finalY = m[Matrix.MTRANS_Y] + getImageHeight() * py; return new PointF(finalX, finalY); }
Example #29
Source Project: InDoorSurfaceView Author: karonl File: PathUnit.java License: Apache License 2.0 | 5 votes |
public PathUnit(List<PointF> list) { int i = 0; path = new Path(); for (PointF point : list) { if (i == 0) path.moveTo(point.x, point.y); path.lineTo(point.x, point.y); i++; } RectF rectF = new RectF(); path.computeBounds(rectF, true); region = new Region(); region.setPath(path, new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom)); }
Example #30
Source Project: SmileBar Author: eugeneek File: SmileBar.java License: Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); for (int i = 0; i < MAX_RATE; i++) { PointF pos = points[i]; canvas.save(); canvas.translate(pos.x, pos.y); drawSmile(canvas, i); canvas.restore(); } }