类android.graphics.Point源码实例Demo

下面列出了怎么用android.graphics.Point的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: habpanelviewer   文件: MotionDetector.java
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;
}
 
源代码2 项目: colorpicker   文件: ColorPickerView.java
/**
 * 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);
}
 
源代码3 项目: Leanplum-Android-SDK   文件: HTMLOptions.java
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;
}
 
源代码4 项目: LB-Launcher   文件: WallpaperCropActivity.java
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);
    }
}
 
源代码5 项目: LB-Launcher   文件: WallpaperPickerActivity.java
@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);
}
 
源代码6 项目: CodeScaner   文件: PreviewCallback.java
@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");
    }
  }
 
源代码7 项目: firebase-android-sdk   文件: FiamAnimator.java
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);
}
 
源代码8 项目: TelePlus-Android   文件: MediaCodecInfo.java
/**
 * 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);
}
 
源代码9 项目: Trebuchet   文件: WallpaperPickerActivity.java
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;
}
 
源代码10 项目: BigApp_Discuz_Android   文件: FloatingView.java
public FloatingView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;


    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingView);
    mColor = a.getColor(R.styleable.FloatingView_FloatingView_color, Color.TRANSPARENT);
    mButtonPaint.setStyle(Paint.Style.FILL);
    mButtonPaint.setColor(mColor);
    float radius, dx, dy;
    radius = a.getFloat(R.styleable.FloatingView_FloatingView_shadowRadius, 10.0f);
    dx = a.getFloat(R.styleable.FloatingView_FloatingView_shadowDx, 0.0f);
    dy = a.getFloat(R.styleable.FloatingView_FloatingView_shadowDy, 3.5f);
    int color = a.getInteger(R.styleable.FloatingView_FloatingView_shadowColor, Color.TRANSPARENT);
    mButtonPaint.setShadowLayer(radius, dx, dy, color);

    Drawable drawable = a.getDrawable(R.styleable.FloatingView_FloatingView_drawable);
    if (null != drawable) {
        mBitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    WindowManager mWindowManager = (WindowManager)
            context.getSystemService(Context.WINDOW_SERVICE);
    Display display = mWindowManager.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);
        mYHidden = size.y;
    } else mYHidden = display.getHeight();
}
 
源代码11 项目: android-gps-test-tool   文件: DrawCircle.java
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)
	}
}
 
源代码12 项目: VMLibrary   文件: VMDimen.java
/**
 * 获取屏幕大小
 */
public static Point getScreenSize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point outSize = new Point();
    display.getSize(outSize);
    return outSize;
}
 
源代码13 项目: android_9.0.0_r45   文件: ThreadedRenderer.java
/**
 * Set the light center.
 */
public void setLightCenter(final Display display,
        final int windowLeft, final int windowTop) {
    // Adjust light position for window offsets.
    final Point displaySize = new Point();
    display.getRealSize(displaySize);
    final float lightX = displaySize.x / 2f - windowLeft;
    final float lightY = mLightY - windowTop;

    nSetLightCenter(mNativeProxy, lightX, lightY, mLightZ);
}
 
源代码14 项目: AcgClub   文件: DimenUtils.java
/**
 * Get the size of current screen.
 *
 * @param context the context
 * @return the size
 */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static Point getScreenSize(Context context) {
  WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = windowManager.getDefaultDisplay();
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
    return new Point(display.getWidth(), display.getHeight());
  } else {
    Point point = new Point();
    display.getSize(point);
    return point;
  }
}
 
源代码15 项目: za-Farmer   文件: Gestures.java
/**
 * 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)
    };
}
 
源代码16 项目: Camera2Vision   文件: Utils.java
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;
}
 
源代码17 项目: AndroidHttpCapture   文件: CameraManager.java
/**
 * 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;
}
 
源代码18 项目: imsdk-android   文件: BitmapSticker.java
@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;
}
 
源代码19 项目: DevUtils   文件: CameraSizeAssist.java
/**
 * 根据手机支持的拍照分辨率计算, 设置预览尺寸
 * @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;
}
 
源代码20 项目: JZAndroidChart   文件: Chart.java
/**
 * 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()));
}
 
源代码21 项目: PdfViewPager   文件: SubsamplingScaleImageView.java
@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;
}
 
源代码22 项目: CircleFloatBar   文件: BezierEvaluator.java
@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;
}
 
@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();
}
 
源代码24 项目: Field-Book   文件: DragSortController.java
/**
 * 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;
    }
}
 
源代码25 项目: TurboLauncher   文件: WallpaperPickerActivity.java
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;
}
 
源代码26 项目: ShareBox   文件: QRCodeReaderView.java
/**
 * 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);
}
 
源代码27 项目: snowplow-android-tracker   文件: Subject.java
/**
 * 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());
    }
}
 
源代码28 项目: FireFiles   文件: AppsProvider.java
@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);
}
 
源代码29 项目: CustomViewSets   文件: CustomBasicOpView.java
@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)));
}
 
public static Point getShiftedPoint(@NonNull Point referencePoint, double distanceInPixels, double bearing) {
    double angleInRadians = Math.toRadians(bearing + 90);
    return new Point(
            (int) (referencePoint.x - (distanceInPixels * Math.cos(angleInRadians))),
            (int) (referencePoint.y - (distanceInPixels * Math.sin(angleInRadians)))
    );
}
 
 类所在包
 类方法
 同包方法