List of usage examples for android.graphics Point Point
public Point(int x, int y)
From source file:Main.java
/** * Looks through the byte array and calculates size of the picture inside it. Operation is very * fast, as no actual decoding will be done. *///from w w w .ja v a2 s . c om public static Point extractSize(byte[] data) { final BitmapFactory.Options ops = new BitmapFactory.Options(); ops.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(data, 0, data.length, ops); return new Point(ops.outWidth, ops.outHeight); }
From source file:com.google.sample.cast.refplayer.utils.Utils.java
@SuppressWarnings("deprecation") /**// w ww . j a v a2 s .c o m * Returns the screen/display size * */ public static Point getDisplaySize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); return new Point(width, height); }
From source file:cn.ieclipse.af.view.ah.AutoHeightViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int size = getChildCount(); if (size > 0 && getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) { Point p = mHeights.get(getCurrentItem()); if (p == null) { try { int i = getChildIndex(); View child = getChildAt(i); if (child != null) { child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)); int w = child.getMeasuredWidth(); int h = child.getMeasuredHeight(); mHeights.put(getCurrentItem(), new Point(w, h)); heightMeasureSpec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY); // widthMeasureSpec = MeasureSpec.makeMeasureSpec(w, // MeasureSpec.EXACTLY); }/*from ww w. jav a 2 s . co m*/ } catch (Exception e) { e.printStackTrace(); } } else { heightMeasureSpec = MeasureSpec.makeMeasureSpec(p.y, MeasureSpec.EXACTLY); // widthMeasureSpec = MeasureSpec.makeMeasureSpec(p.x, // MeasureSpec.EXACTLY); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.ameron32.apps.tapnotes._trial.ui.MultiViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Point size = new Point(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec)); if (mMaxWidth >= 0 || mMaxHeight >= 0) { Point maxSize = new Point(mMaxWidth, mMaxHeight); constrainTo(size, maxSize);// www. j a v a 2s . c o m widthMeasureSpec = MeasureSpec.makeMeasureSpec(size.x, MeasureSpec.EXACTLY); heightMeasureSpec = MeasureSpec.makeMeasureSpec(size.y, MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); onMeasurePage(widthMeasureSpec, heightMeasureSpec); }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(parameters.getSupportedPreviewSizes()); Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() { @Override// w w w .j ava2 s. c o m public int compare(Camera.Size a, Camera.Size b) { int aPixels = a.height * a.width; int bPixels = b.height * b.width; if (bPixels < aPixels) { return -1; } if (bPixels > aPixels) { return 1; } return 0; } }); Point bestSize = null; float screenAspectRatio = (float) screenResolution.x / (float) screenResolution.y; float diff = Float.POSITIVE_INFINITY; for (Camera.Size supportedPreviewSize : supportedPreviewSizes) { int realWidth = supportedPreviewSize.width; int realHeight = supportedPreviewSize.height; int pixels = realWidth * realHeight; if (pixels < MIN_PREVIEW_PIXELS || pixels > MAX_PREVIEW_PIXELS) { continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { return new Point(realWidth, realHeight); } float aspectRatio = (float) maybeFlippedWidth / (float) maybeFlippedHeight; float newDiff = Math.abs(aspectRatio - screenAspectRatio); if (newDiff < diff) { bestSize = new Point(realWidth, realHeight); diff = newDiff; } } if (bestSize == null) { Camera.Size defaultSize = parameters.getPreviewSize(); bestSize = new Point(defaultSize.width, defaultSize.height); } return bestSize; }
From source file:com.color.kid.kidpaint.tools.implementation.FillTool.java
@Override public boolean handleUp(PointF coordinate) { int bitmapHeight = PaintroidApplication.drawingSurface.getBitmapHeight(); int bitmapWidth = PaintroidApplication.drawingSurface.getBitmapWidth(); if ((coordinate.x > bitmapWidth) || (coordinate.y > bitmapHeight) || (coordinate.x < 0) || (coordinate.y < 0)) {/* ww w . j av a2 s.c o m*/ return false; } if (mColorTolerance == 0 && mBitmapPaint.getColor() == PaintroidApplication.drawingSurface.getPixel(coordinate)) { return false; } Command command = new FillCommand(new Point((int) coordinate.x, (int) coordinate.y), mBitmapPaint, mColorTolerance); IndeterminateProgressDialog.getInstance().show(); ((FillCommand) command).addObserver(this); PaintroidApplication.commandManager.commitCommand(command); return true; }
From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.FillTool.java
@Override public boolean handleUp(PointF coordinate) { int bitmapHeight = AnimalsColoringApplication.drawingSurface.getBitmapHeight(); int bitmapWidth = AnimalsColoringApplication.drawingSurface.getBitmapWidth(); if ((coordinate.x > bitmapWidth) || (coordinate.y > bitmapHeight) || (coordinate.x < 0) || (coordinate.y < 0)) {/*from w w w .jav a2 s . c o m*/ return false; } if (mColorTolerance == 0 && mBitmapPaint.getColor() == AnimalsColoringApplication.drawingSurface.getPixel(coordinate)) { return false; } Command command = new FillCommand(new Point((int) coordinate.x, (int) coordinate.y), mBitmapPaint, mColorTolerance); IndeterminateProgressDialog.getInstance().show(); ((FillCommand) command).addObserver(this); AnimalsColoringApplication.commandManager.commitCommand(command); return true; }
From source file:com.mirasense.scanditsdk.plugin.SubViewPickerController.java
@Override public void show(final JSONObject settings, final Bundle options, final Bundle overlayOptions, boolean legacyMode) { mPendingClose.set(false);// w w w . ja va2s.c o m mLegacyMode = legacyMode; mContinuousMode = PhonegapParamParser.shouldRunInContinuousMode(options); mOrientationHandler = new SubViewPickerOrientationHandler(Looper.getMainLooper(), mPlugin, null); mCloseWhenDidScanCallbackFinishes = false; mOrientationHandler.start(true); final Activity pluginActivity = mPlugin.cordova.getActivity(); DisplayMetrics display = pluginActivity.getApplicationContext().getResources().getDisplayMetrics(); int width = (int) (display.widthPixels * 160.f / display.densityDpi); int height = (int) (display.heightPixels * 160.f / display.densityDpi); mScreenDimensions = new Point(Math.min(width, height), Math.max(width, height)); // initialization must be performed on main thread. this.runOnUiThread(new Runnable() { @Override public void run() { ScanSettings scanSettings; if (settings == null) { scanSettings = LegacySettingsParamParser.getSettings(options); } else { try { scanSettings = ScanSettings.createWithJson(settings); } catch (JSONParseException e) { Log.e("ScanditSDK", "Exception while creating settings"); e.printStackTrace(); sendRuntimeError("Exception while creating settings: " + e.getMessage() + ". Falling back to default scan settings."); scanSettings = ScanSettings.create(); } } BarcodePickerWithSearchBar picker = new BarcodePickerWithSearchBar(pluginActivity, scanSettings); picker.setOnScanListener(SubViewPickerController.this); mPickerStateMachine = new PickerStateMachine(picker, SubViewPickerController.this); mOrientationHandler.setScreenDimensions(mScreenDimensions); mOrientationHandler.setPicker(mPickerStateMachine.getPicker()); // Set all the UI options. PhonegapParamParser.updatePicker(picker, options, SubViewPickerController.this); internalUpdateUI(overlayOptions, options); // Create the layout to add the picker to and add it on top of the web view. mLayout = new RelativeLayout(pluginActivity); ViewGroup viewGroup = getPickerParent(); if (viewGroup == null) return; // couldn't determine view group, nothing to be done. viewGroup.addView(mLayout); RelativeLayout.LayoutParams rLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); mLayout.addView(mPickerStateMachine.getPicker(), rLayoutParams); PhonegapParamParser.updateLayout(pluginActivity, mPickerStateMachine.getPicker(), options, mScreenDimensions); if (mPendingClose.compareAndSet(true, false)) { // picker was closed(canceled) in the meantime. close it now. SubViewPickerController.this.close(); } if (!mLegacyMode) return; // In legacy mode, start scanning when show is called. int state = PhonegapParamParser.shouldStartInPausedState(options) ? PickerStateMachine.PAUSED : PickerStateMachine.ACTIVE; mPickerStateMachine.setState(state); } }); }
From source file:com.pseudosudostudios.jdd.views.Grid.java
/** * Defines the centers for the tiles/* ww w .ja v a 2 s. c om*/ */ public void setCenters() { Point gridCenter = new Point(getWidth() / 2, getHeight() / 2); vertical_offset = Math.abs(vertical_offset); horizontal_offset = Math.abs(horizontal_offset); int space = Math.min(vertical_offset, horizontal_offset); int x, y; for (int row = 0; row < tiles.length; row++) { for (int col = 0; col < tiles[row].length; col++) { if (row == 0) y = gridCenter.y - space; else if (row == 1) y = gridCenter.y; else y = gridCenter.y + space; if (col == 0) x = gridCenter.x - space; else if (col == 1) x = gridCenter.x; else x = gridCenter.x + space; tiles[row][col].updateCenter(new Point(x, y)); } } }
From source file:com.dm.material.dashboard.candybar.helpers.ViewHelper.java
public static int getNavigationBarHeight(@NonNull Context context) { Point appUsableSize = getAppUsableScreenSize(context); Point realScreenSize = getRealScreenSize(context); if (appUsableSize.x < realScreenSize.x) { Point point = new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y); return point.x; }//from w w w . ja v a 2s . com if (appUsableSize.y < realScreenSize.y) { Point point = new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y); return point.y; } return 0; }