List of usage examples for android.graphics Point set
public void set(int x, int y)
From source file:com.pdftron.pdf.utils.Utils.java
/** * Gets the size of the display, in pixels. * * @param context the Context/* ww w.j ava 2 s.c o m*/ * @param outSize A Point object to receive the size information */ public static void getDisplaySize(Context context, Point outSize) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (outSize == null) { outSize = new Point(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(outSize); } else { outSize.set(display.getWidth(), display.getHeight()); } }
From source file:com.apptentive.android.sdk.util.Util.java
public static Point getScreenSize(Context context) { Point ret = new Point(); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); // TODO: getWidth(), getHeight(), and getOrientation() are deprecated in API 13 in favor of getSize() and getRotation(). ret.set(display.getWidth(), display.getHeight()); return ret;//from w w w . ja v a 2 s .c o m }
From source file:android.support.v13.view.DragStartHelper.java
/** * Compute the position of the touch event that started the drag operation. * @param point The position of the touch event that started the drag operation. *///w w w. j a v a 2 s . co m public void getTouchPosition(Point point) { point.set(mLastTouchX, mLastTouchY); }
From source file:ru.jango.j0widget.imagebrowser.ImageBrowserView.java
/** * Calculates rectangle sides based on it's square and proportions. The point is to create a * new rect with the same square, but with the appropriate proportions of sides. This method * is a part of this process.//from ww w . j av a 2s .co m * * @param square square of the source rectangle (width * height) * @param pro sides factor of the source rectangle (width / height) * @param ret object, through witch the result would be returned */ private void calculateSize(float square, float pro, final Point ret) { float height = (float) Math.sqrt(square / pro); float width = height * pro; ret.set((int) width, (int) height); }
From source file:com.example.linhdq.test.documents.creation.crop.CropImageActivity.java
private void zoomToBlurredRegion(CropData data) { float width = data.getBlurriness().getPixBlur().getWidth(); float height = data.getBlurriness().getPixBlur().getHeight(); float widthScale = width / data.getBitmap().getWidth(); float heightScale = height / data.getBitmap().getHeight(); final Point c = data.getBlurriness().getMostBlurredRegion().getCenter(); c.set((int) (c.x / widthScale), (int) (c.y / heightScale)); float[] pts = { c.x, c.y }; mImageView.getImageMatrix().mapPoints(pts); /*// ww w. java2 s .c o m int w = (Math.min(mBitmap.getWidth(), mBitmap.getHeight())) / 25; Rect focusArea = new Rect((int) (Math.max(c.x-w,0)*widthScale), (int) (Math.max(c.y-w,0)*heightScale), (int) (Math.min(c.x+w,mBitmap.getWidth())*widthScale), (int) (Math.min(c.y+w,mBitmap.getHeight())*heightScale)); //final int progressColor = getResources().getColor(R.color.progress_color); //final int edgeWidth = getResources().getDimensionPixelSize(R.dimen.crop_edge_width); Clip.clipRectangle2(); BlurHighLightView hv = new BlurHighLightView(focusArea,progressColor,edgeWidth, mImageView.getImageMatrix()); mImageView.add(hv); */ mImageView.setMaxZoom(3); mImageView.zoomTo(3, pts[0], pts[1], 2000); }
From source file:io.github.dector.rkpi.views.AppViewPager.java
/** * Load, scale and setup background image * * @param context activity context//w ww. ja va 2 s. c om */ private void initBackground(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point displaySize = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(displaySize); } else { displaySize.set(display.getWidth(), display.getHeight()); } BitmapFactory.Options decodeOptions = new BitmapFactory.Options(); decodeOptions.inJustDecodeBounds = true; BitmapFactory.decodeResource(context.getResources(), R.drawable.background); decodeOptions.inJustDecodeBounds = false; decodeOptions.inSampleSize = DeviceTools.getSampleSize(decodeOptions, displaySize); Bitmap sourceBackground = BitmapFactory.decodeResource(context.getResources(), R.drawable.background, decodeOptions); Bitmap background = Bitmap.createScaledBitmap(sourceBackground, displaySize.x, displaySize.y, true); Drawable bitmapDrawable = new BitmapDrawable(context.getResources(), background); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setBackground(bitmapDrawable); } else { setBackgroundDrawable(bitmapDrawable); } sourceBackground.recycle(); }
From source file:com.google.android.apps.muzei.util.PanScaleProxyView.java
/** * Computes the current scrollable surface size, in pixels. For example, if the entire chart * area is visible, this is simply the current view width and height. If the chart * is zoomed in 200% in both directions, the returned size will be twice as large horizontally * and vertically./*from w w w .j a va 2 s .c o m*/ */ private void computeScrollSurfaceSize(Point out) { out.set((int) (mWidth / mCurrentViewport.width()), (int) (mHeight / mCurrentViewport.height())); }
From source file:android.support.v7.view.menu.MenuPopupHelper.java
/** * Creates the popup and assigns cached properties. * * @return an initialized popup//from w w w. ja va 2 s.c o m */ @NonNull private MenuPopup createPopup() { final WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); final Display display = windowManager.getDefaultDisplay(); final Point displaySize = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(displaySize); } else if (Build.VERSION.SDK_INT >= 13) { display.getSize(displaySize); } else { displaySize.set(display.getWidth(), display.getHeight()); } final int smallestWidth = Math.min(displaySize.x, displaySize.y); final int minSmallestWidthCascading = mContext.getResources() .getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width); final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading; final MenuPopup popup; if (enableCascadingSubmenus) { popup = new CascadingMenuPopup(mContext, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly); } else { popup = new StandardMenuPopup(mContext, mMenu, mAnchorView, mPopupStyleAttr, mPopupStyleRes, mOverflowOnly); } // Assign immutable properties. popup.addMenu(mMenu); popup.setOnDismissListener(mInternalOnDismissListener); // Assign mutable properties. These may be reassigned later. popup.setAnchorView(mAnchorView); popup.setCallback(mPresenterCallback); popup.setForceShowIcon(mForceShowIcon); popup.setGravity(mDropDownGravity); return popup; }
From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java
@SuppressLint("NewApi") private Point getDisplayDimensions() { Point size = new Point(); Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size);/*w ww . j a v a 2 s . c om*/ } else { size.set(display.getWidth(), display.getHeight()); } return size; }
From source file:org.mitre.svmp.activities.AppRTCVideoActivity.java
@Override protected void connectToRoom() { // Uncomment to get ALL WebRTC tracing and SENSITIVE libjingle logging. // Logging.enableTracing( // "/sdcard/trace.txt", // EnumSet.of(Logging.TraceLevel.TRACE_ALL), // Logging.Severity.LS_SENSITIVE); Point deviceDisplaySize = new Point(); // displaySize.set(720, 1280); getWindowManager().getDefaultDisplay().getSize(deviceDisplaySize); Point displaySize = new Point(); displaySize.set(deviceDisplaySize.x, deviceDisplaySize.y * (16 / 9)); // displaySize.set(720, 1280); vsv = new VideoStreamsView(this, displaySize, performanceAdapter); vsv.setPreserveEGLContextOnPause(true); vsv.setBackgroundColor(Color.WHITE); // start this VideoStreamsView // with a color of dark gray createTopPanel();//ww w. ja va2 s .c om setContentView(vsv); addContentView(ll, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 50 * deviceDisplaySize.y / 1280)); addContentView(scrollBtnsRLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // addContentView(view, params); // vsvProgrssBar.setVisibility(View.INVISIBLE); touchHandler = new TouchHandler(this, displaySize, performanceAdapter); rotationHandler = new RotationHandler(this); keyHandler = new KeyHandler(this); configHandler = new ConfigHandler(this); AppRTCHelper.abortUnless(PeerConnectionFactory.initializeAndroidGlobals(this), "Failed to initializeAndroidGlobals"); // Create observers. sdpObserver = new SDPObserver(this); // sdpaObserver = new SDPAObserver(this); pcObserver = new PCObserver(this); sdpMediaConstraints = new MediaConstraints(); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true")); super.connectToRoom(); }