android.graphics.Point Java Examples
The following examples show how to use
android.graphics.Point.
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 File: FiamAnimator.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
public void slideOutOfView( final Application app, final View view, Position end, final AnimationCompleteListener completeListener) { Point start = Position.getPoint(end, view); AnimatorListenerAdapter animatorListenerAdapter = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); // Remove fiam from window only after the animation is complete completeListener.onComplete(); } }; view.animate() .translationX(start.x) .translationY(start.y) .setDuration(app.getResources().getInteger(android.R.integer.config_longAnimTime)) .setListener(animatorListenerAdapter); }
Example #2
Source File: WallpaperPickerActivity.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
private ResourceWallpaperInfo getPreKKDefaultWallpaperInfo() { Resources sysRes = Resources.getSystem(); int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android"); File defaultThumbFile = getDefaultThumbFile(); Bitmap thumb = null; boolean defaultWallpaperExists = false; if (defaultThumbFile.exists()) { thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath()); defaultWallpaperExists = true; } else { Resources res = getResources(); Point defaultThumbSize = getDefaultThumbnailSize(res); int rotation = BitmapUtils.getRotationFromExif(res, resId); thumb = createThumbnail( defaultThumbSize, getContext(), null, null, sysRes, resId, rotation, false); if (thumb != null) { defaultWallpaperExists = saveDefaultWallpaperThumb(thumb); } } if (defaultWallpaperExists) { return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb)); } return null; }
Example #3
Source File: MediaCodecInfo.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns the smallest video size greater than or equal to a specified size that also satisfies * the {@link MediaCodec}'s width and height alignment requirements. * <p> * Must not be called if the device SDK version is less than 21. * * @param width Width in pixels. * @param height Height in pixels. * @return The smallest video size greater than or equal to the specified size that also satisfies * the {@link MediaCodec}'s width and height alignment requirements, or null if not a video * codec. */ @TargetApi(21) public Point alignVideoSizeV21(int width, int height) { if (capabilities == null) { logNoSupport("align.caps"); return null; } VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities(); if (videoCapabilities == null) { logNoSupport("align.vCaps"); return null; } int widthAlignment = videoCapabilities.getWidthAlignment(); int heightAlignment = videoCapabilities.getHeightAlignment(); return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment, Util.ceilDivide(height, heightAlignment) * heightAlignment); }
Example #4
Source File: WallpaperPickerActivity.java From LB-Launcher with Apache License 2.0 | 6 votes |
@Override public void onClick(WallpaperPickerActivity a) { BitmapRegionTileSource.ResourceBitmapSource bitmapSource = new BitmapRegionTileSource.ResourceBitmapSource( mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE); bitmapSource.loadInBackground(); BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource); CropView v = a.getCropView(); v.setTileSource(source, null); Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize( a.getResources(), a.getWindowManager()); RectF crop = WallpaperCropActivity.getMaxCropRect( source.getImageWidth(), source.getImageHeight(), wallpaperSize.x, wallpaperSize.y, false); v.setScale(wallpaperSize.x / crop.width()); v.setTouchEnabled(false); a.setSystemWallpaperVisiblity(false); }
Example #5
Source File: PreviewCallback.java From CodeScaner with MIT License | 6 votes |
@Override public void onPreviewFrame(byte[] data, Camera camera) { Point cameraResolution = configManager.getCameraResolution(); Handler thePreviewHandler = previewHandler; if (cameraResolution != null && thePreviewHandler != null) { // Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, // cameraResolution.y, data); Point screenResolution = configManager.getScreenResolution(); Message message; if (screenResolution.x < screenResolution.y){ // portrait message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.y, cameraResolution.x, data); } else { // landscape message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); } message.sendToTarget(); previewHandler = null; } else { Log.d(TAG, "Got preview callback, but no handler or resolution available"); } }
Example #6
Source File: MotionDetector.java From habpanelviewer with GNU General Public License v3.0 | 6 votes |
private synchronized ArrayList<Point> detect(LumaData s) { if (mComparer == null) { mComparer = new Comparer(s.getWidth(), s.getHeight(), mBoxes, mLeniency); } if (mPreviousState == null) { mPreviousState = s; return null; } if (s.getWidth() != mPreviousState.getWidth() || s.getHeight() != mPreviousState.getHeight()) { return null; } ArrayList<Point> differing = mComparer.isDifferent(s, mPreviousState); mPreviousState.release(); mPreviousState = s; return differing; }
Example #7
Source File: WallpaperCropActivity.java From LB-Launcher with Apache License 2.0 | 6 votes |
static public void suggestWallpaperDimension(Resources res, final SharedPreferences sharedPrefs, WindowManager windowManager, final WallpaperManager wallpaperManager, boolean fallBackToDefaults) { final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager); // If we have saved a wallpaper width/height, use that instead int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1); int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1); if (savedWidth == -1 || savedHeight == -1) { if (!fallBackToDefaults) { return; } else { savedWidth = defaultWallpaperSize.x; savedHeight = defaultWallpaperSize.y; } } if (savedWidth != wallpaperManager.getDesiredMinimumWidth() || savedHeight != wallpaperManager.getDesiredMinimumHeight()) { wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight); } }
Example #8
Source File: ColorPickerView.java From colorpicker with Apache License 2.0 | 6 votes |
/** * This will return the closes point on the circle relative to the touch event * * @param touchX * @param touchY * @return */ private Point getClosestPoint(float touchX, float touchY) { //Todo: find if there is a faster way. //This is for center 0,0 double angle = Math.atan2(touchY - getCenterYInParent(), touchX - getCenterXInParent()); double onCircleX = Math.cos(angle) * mRadius; double onCircleY = Math.sin(angle) * mRadius; //fetch the selected color from the drawable mLastSelectedColor = getColorFromColorRing((float) onCircleX + mCenterX, (float) onCircleY + mCenterY); Log.d("colorpicker", "Selected color: " + mLastSelectedColor); fireColorListener(getColor()); //The circle is on an offset, not on 0,0 but centered and in a viewgroup (our parent framelayout) onCircleX += getCenterXInParent(); onCircleY += getCenterYInParent(); return new Point((int) onCircleX, (int) onCircleY); }
Example #9
Source File: HTMLOptions.java From Leanplum-Android-SDK with Apache License 2.0 | 6 votes |
int getHtmlYOffset(Activity context) { int yOffset = 0; if (context == null) { return yOffset; } if (htmlYOffset != null && !TextUtils.isEmpty(htmlYOffset.type)) { yOffset = htmlYOffset.value; if ("%".equals(htmlYOffset.type)) { Point size = SizeUtil.getDisplaySize(context); yOffset = (size.y - SizeUtil.getStatusBarHeight(context)) * yOffset / 100; } else { yOffset = SizeUtil.dpToPx(context, yOffset); } } return yOffset; }
Example #10
Source File: Utils.java From Camera2Vision with Apache License 2.0 | 5 votes |
public static int getScreenHeight(Context c) { WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.y; }
Example #11
Source File: BitmapSticker.java From imsdk-android with MIT License | 5 votes |
@Override public boolean onTouchEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) { setDoubleDownPoints(0, 0, 0, 0); lastDoubleDegress = 1000; lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9])); } return !isOut; }
Example #12
Source File: CustomBasicOpView.java From CustomViewSets with Apache License 2.0 | 5 votes |
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mWidth = w; mHeight = h; startXYPoint = new Point(mWidth/2-rectWidth/2, 3 * margin + padding + DensityUtils.sp2px(getContext(), 16)); endXPoint = new Point(mWidth - (3 * margin + padding), 3 * margin + padding + DensityUtils.sp2px(getContext(), 16)); endYPoint = new Point(3 * margin + padding, mHeight - (3 * margin + padding + DensityUtils.sp2px(getContext(), 16))); }
Example #13
Source File: Gestures.java From za-Farmer with MIT License | 5 votes |
/** * Returns an array of {@link PointerGesture}s representing a pinch close. * * @param bounds The area to pinch over. * @param percent The size of the pinch as a percentage of the total area. * @param speed The speed at which to move in pixels per second. * @return An array containing the two PointerGestures representing this pinch. */ public PointerGesture[] pinchClose(Rect area, float percent, int speed) { Point[] bottomLeft = new Point[2]; Point[] topRight = new Point[2]; calcPinchCoordinates(area, percent, bottomLeft, topRight); // A pinch close is a multi-point gesture composed of two swipes moving from the outer // coordinates to the inner ones. return new PointerGesture[] { swipe(bottomLeft[OUTER], bottomLeft[INNER], speed).pause(250), swipe(topRight[OUTER], topRight[INNER], speed).pause(250) }; }
Example #14
Source File: Renderer.java From Learning-Java-by-Building-Android-Games-Second-Edition with MIT License | 5 votes |
Renderer(SurfaceView sh, Point screenSize){ mSurfaceHolder = sh.getHolder(); mPaint = new Paint(); // Initialize the camera mCamera = new Camera(screenSize.x, screenSize.y); }
Example #15
Source File: SubsamplingScaleImageView.java From pdfview-android with Apache License 2.0 | 5 votes |
@Override protected int[] doInBackground(Void... params) { try { String sourceUri = source.toString(); Context context = contextRef.get(); DecoderFactory<? extends ImageRegionDecoder> decoderFactory = decoderFactoryRef.get(); SubsamplingScaleImageView view = viewRef.get(); if (context != null && decoderFactory != null && view != null) { view.debug("TilesInitTask.doInBackground"); decoder = decoderFactory.make(); Point dimensions = decoder.init(context, source); int sWidth = dimensions.x; int sHeight = dimensions.y; int exifOrientation = view.getExifOrientation(context, sourceUri); if (view.sRegion != null) { view.sRegion.left = Math.max(0, view.sRegion.left); view.sRegion.top = Math.max(0, view.sRegion.top); view.sRegion.right = Math.min(sWidth, view.sRegion.right); view.sRegion.bottom = Math.min(sHeight, view.sRegion.bottom); sWidth = view.sRegion.width(); sHeight = view.sRegion.height(); } return new int[] { sWidth, sHeight, exifOrientation }; } } catch (Exception e) { Log.e(TAG, "Failed to initialise bitmap decoder", e); this.exception = e; } return null; }
Example #16
Source File: GaoDeMapAiLineManager.java From FimiX8-RE with MIT License | 5 votes |
public void onMarkerDrag(Marker marker) { if (this.lineMarkerSelectListener != null) { Rect rect = this.lineMarkerSelectListener.getDeletePosition(); Point mPoint = this.aMap.getProjection().toScreenLocation(marker.getPosition()); if (rect.left > mPoint.x || mPoint.x > rect.right || rect.top > mPoint.y || mPoint.y <= rect.bottom) { } } }
Example #17
Source File: ExternalStorageProvider.java From FireFiles with Apache License 2.0 | 5 votes |
@Override public AssetFileDescriptor openDocumentThumbnail( String documentId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException { if (mArchiveHelper.isArchivedDocument(documentId)) { return mArchiveHelper.openDocumentThumbnail(documentId, sizeHint, signal); } return openOrCreateDocumentThumbnail(documentId, sizeHint, signal); }
Example #18
Source File: DrawCircle.java From android-gps-test-tool with Apache License 2.0 | 5 votes |
public void createMercatorCircle(double radius, Point center){ double lon1 = degToRad(center.x); double lat1 = degToRad(center.y); double R_KM = 6371; //radius km double R_MI = 3963; //radius mi //double d = radius/R_KM; //angular distance on earth's surface double d = radius/R_MI; Polygon circle = new Polygon(); int nodes = 100; //number of nodes in circle int step = Math.round(360/nodes); int n = 0; double[] pointArray; for(int x = 0; x <= 360; x++){ int z = Math.round(n+=step); double bearing = degToRad(x); double lat2 = Math.asin( Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(bearing) ); double lon2 = lon1 + Math.atan2( Math.sin(bearing) * Math.sin(d) * Math.cos(lat1), Math.cos(d) - Math.sin(lat1) * Math.sin(lat2) ); //pointArray[x] = GeometryEngine.project(x, y, sr) } }
Example #19
Source File: Utils.java From alltv with MIT License | 5 votes |
/** * Returns the screen/display size */ public static Point getDisplaySize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; }
Example #20
Source File: AppsProvider.java From FireFiles with Apache License 2.0 | 5 votes |
@Override public AssetFileDescriptor openDocumentThumbnail( String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException { // TODO: extend ExifInterface to support fds final ParcelFileDescriptor pfd = openDocument(docId, "r", signal); return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH); }
Example #21
Source File: CameraManager.java From AndroidHttpCapture with MIT License | 5 votes |
/** * Like {@link #getFramingRect} but coordinates are in terms of the preview frame, * not UI / screen. * * @return {@link Rect} expressing barcode scan area in terms of the preview size */ public synchronized Rect getFramingRectInPreview() { if (framingRectInPreview == null) { Rect framingRect = getFramingRect(); if (framingRect == null) { return null; } Rect rect = new Rect(framingRect); Point cameraResolution = configManager.getCameraResolution(); Point screenResolution = configManager.getScreenResolution(); if (cameraResolution == null || screenResolution == null) { // Called early, before init even finished return null; } //rect.left = rect.left * cameraResolution.x / screenResolution.x; //rect.right = rect.right * cameraResolution.x / screenResolution.x; //rect.top = rect.top * cameraResolution.y / screenResolution.y; //rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y; rect.left = rect.left * cameraResolution.y / screenResolution.x; rect.right = rect.right * cameraResolution.y / screenResolution.x; rect.top = rect.top * cameraResolution.x / screenResolution.y; rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; framingRectInPreview = rect; } return framingRectInPreview; }
Example #22
Source File: Subject.java From snowplow-android-tracker with Apache License 2.0 | 5 votes |
/** * Sets the default screen resolution * of the device the Tracker is running * on. * * @param context the android context */ @SuppressWarnings("deprecation") public void setDefaultScreenResolution(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); this.setScreenResolution(size.x, size.y); } else { this.setScreenResolution(display.getWidth(), display.getHeight()); } }
Example #23
Source File: BezierEvaluator.java From CircleFloatBar with Apache License 2.0 | 5 votes |
@Override public Point evaluate(float t, Point startValue, Point endValue) { int x = (int) ((1 - t) * (1 - t) * startValue.x + 2 * t * (1 - t) * controllPoint.x + t * t * endValue.x); int y = (int) ((1 - t) * (1 - t) * startValue.y + 2 * t * (1 - t) * controllPoint.y + t * t * endValue.y); curPoint.set(x, y); return curPoint; }
Example #24
Source File: QRCodeReaderView.java From ShareBox with Apache License 2.0 | 5 votes |
/** * Transform result to surfaceView coordinates * <p> * This method is needed because coordinates are given in landscape camera coordinates when * device is in portrait mode and different coordinates otherwise. * * @return a new PointF array with transformed points */ private PointF[] transformToViewCoordinates(QRCodeReaderView view, ResultPoint[] resultPoints) { int orientationDegrees = view.getCameraDisplayOrientation(); Orientation orientation = orientationDegrees == 90 || orientationDegrees == 270 ? Orientation.PORTRAIT : Orientation.LANDSCAPE; Point viewSize = new Point(view.getWidth(), view.getHeight()); Point cameraPreviewSize = view.mCameraManager.getPreviewSize(); boolean isMirrorCamera = view.mCameraManager.getPreviewCameraId() == Camera.CameraInfo.CAMERA_FACING_FRONT; return qrToViewPointTransformer.transform(resultPoints, isMirrorCamera, orientation, viewSize, cameraPreviewSize); }
Example #25
Source File: WallpaperPickerActivity.java From TurboLauncher with Apache License 2.0 | 5 votes |
private DefaultWallpaperInfo getDefaultWallpaper() { File defaultThumbFile = new File(getFilesDir(), DEFAULT_WALLPAPER_THUMBNAIL_FILENAME); Bitmap thumb = null; boolean defaultWallpaperExists = false; if (defaultThumbFile.exists()) { thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath()); defaultWallpaperExists = true; } else { // Delete old thumbnail file, since we had a bug where the thumbnail wasn't being drawn // before new File(getFilesDir(), OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete(); Resources res = getResources(); Point defaultThumbSize = getDefaultThumbnailSize(res); Drawable wallpaperDrawable = WallpaperManager.getInstance(this).getBuiltInDrawable( defaultThumbSize.x, defaultThumbSize.y, true, 0.5f, 0.5f); if (wallpaperDrawable != null) { thumb = Bitmap.createBitmap( defaultThumbSize.x, defaultThumbSize.y, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(thumb); wallpaperDrawable.setBounds(0, 0, defaultThumbSize.x, defaultThumbSize.y); wallpaperDrawable.draw(c); c.setBitmap(null); } if (thumb != null) { defaultWallpaperExists = writeImageToFileAsJpeg(defaultThumbFile, thumb); } } if (defaultWallpaperExists) { return new DefaultWallpaperInfo(new BitmapDrawable(thumb)); } return null; }
Example #26
Source File: CameraSizeAssist.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 根据手机支持的拍照分辨率计算, 设置预览尺寸 * @param max 是否使用最大的尺寸 * @param point 指定的尺寸 ( 为 null, 则使用屏幕尺寸 ) * ( 从指定的宽高, 开始往下 ( 超过的不处理 ) 选择最接近尺寸 ) point.x = 宽, point.y = 高 * @param distortion 偏差比例值 * @return {@link Camera.Size} 拍照分辨率 */ public Camera.Size getPictureSize(final boolean max, final Point point, final double distortion) { if (mCamera == null) { LogPrintUtils.dTag(TAG, "camera is null"); return null; } try { // 计算大小并返回 return calcPictureSize(max, point, distortion); } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getPictureSize"); } return null; }
Example #27
Source File: DragSortController.java From Field-Book with GNU General Public License v2.0 | 5 votes |
/** * Overrides to provide fading when slide removal is enabled. */ @Override public void onDragFloatView(View floatView, Point position, Point touch) { if (mRemoveEnabled && mIsRemoving) { mPositionX = position.x; } }
Example #28
Source File: Chart.java From JZAndroidChart with Apache License 2.0 | 5 votes |
/** * Computes the current scrollable surface size, in pixels. For example, if the entire lib * area is visible, this is simply the current size of {@link #mContentRect}. If the lib * is zoomed in 200% in both directions, the returned size will be twice as large horizontally * and vertically. */ private void computeScrollSurfaceSize(Point out) { out.set((int) (mContentRect.width() * (Viewport.AXIS_X_MAX - Viewport.AXIS_X_MIN) / mCurrentViewport.width()), (int) (mContentRect.height() * (Viewport.AXIS_Y_MAX - Viewport.AXIS_Y_MIN) / mCurrentViewport.height())); }
Example #29
Source File: SubsamplingScaleImageView.java From PdfViewPager with Apache License 2.0 | 5 votes |
@Override protected int[] doInBackground(Void... params) { try { String sourceUri = source.toString(); Context context = contextRef.get(); DecoderFactory<? extends ImageRegionDecoder> decoderFactory = decoderFactoryRef.get(); SubsamplingScaleImageView view = viewRef.get(); if (context != null && decoderFactory != null && view != null) { decoder = decoderFactory.make(); Point dimensions = decoder.init(context, source); int sWidth = dimensions.x; int sHeight = dimensions.y; int exifOrientation = view.getExifOrientation(context, sourceUri); if (view.sRegion != null) { view.sRegion.left = Math.max(0, view.sRegion.left); view.sRegion.top = Math.max(0, view.sRegion.top); view.sRegion.right = Math.min(sWidth, view.sRegion.right); view.sRegion.bottom = Math.min(sHeight, view.sRegion.bottom); sWidth = view.sRegion.width(); sHeight = view.sRegion.height(); } return new int[]{sWidth, sHeight, exifOrientation}; } } catch (Exception e) { Log.e(TAG, "Failed to initialise bitmap decoder", e); this.exception = e; } return null; }
Example #30
Source File: GenericCharacteristicTableRow.java From SensorTag-CC2650 with Apache License 2.0 | 5 votes |
@Override public void onConfigurationChanged (Configuration newConfig) { WindowManager wm = (WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point dSize = new Point(); display.getSize(dSize); this.sl1.displayWidth = this.sl2.displayWidth = this.sl3.displayWidth = dSize.x - iconSize - 5; this.invalidate(); }