android.graphics.Point#set ( )源码实例Demo

下面列出了android.graphics.Point#set ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressLint("NewApi")
protected int getScreenOrientation() {
    // getResources().getConfiguration().orientation returns wrong value in some devices.
    // Below is another way to calculate screen orientation.
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
        size.set(display.getWidth(), display.getHeight());
    } else {
        display.getSize(size);
    }

    int orientation;
    if (size.x < size.y) {
        orientation = Configuration.ORIENTATION_PORTRAIT;
    } else {
        orientation = Configuration.ORIENTATION_LANDSCAPE;
    }
    return orientation;
}
 
源代码2 项目: mappwidget   文件: MapWidget.java
/**
 * Scrolls the map to specific location without animation.
 * 
 * @param location
 *            - instance of {@link android.location.Location} object.
 * @throws IllegalStateException
 *             if map was not calibrated. For more details see
 *             MapWidget.setShowMyPosition().
 */
public void jumpTo(Location location) {
	if (config == null) {
		Log.w(TAG, "Jump to skipped. Map is not initialized properly.");
		return;
	}

	if (!config.getGpsConfig().isMapCalibrated()) {
		throw new IllegalStateException("Map is not calibrated.");
	}

	Point point = new Point();
	getGpsConfig().getCalibration().translate(location, point);
	point.set((int) (point.x * getScale()), (int) (point.y * getScale()));

	jumpTo(point);
}
 
源代码3 项目: XERUNG   文件: MaterialSpinner.java
private void drawSelector(Canvas canvas, int posX, int posY) {
    if (isSelected) {
        paint.setColor(highlightColor);
    } else {
        paint.setColor(isEnabled() ? arrowColor : disabledColor);
    }

    Point point1 = selectorPoints[0];
    Point point2 = selectorPoints[1];
    Point point3 = selectorPoints[2];

    point1.set(posX, posY);
    point2.set((int) (posX - (arrowSize)), posY);
    point3.set((int) (posX - (arrowSize / 2)), (int) (posY + (arrowSize / 2)));

    selectorPath.reset();
    selectorPath.moveTo(point1.x, point1.y);
    selectorPath.lineTo(point2.x, point2.y);
    selectorPath.lineTo(point3.x, point3.y);
    selectorPath.close();
    canvas.drawPath(selectorPath, paint);
}
 
源代码4 项目: turn-layout-manager   文件: TurnLayoutManager.java
/**
 * Accounting for the settings of {@link Gravity} and {@link Orientation}, find the center point
 * around which this layout manager should arrange list items.  Place the resulting coordinates
 * into {@code out}, to avoid reallocation.
 */
private Point deriveCenter(@Gravity int gravity,
                           int orientation,
                           @Dimension int radius,
                           @Dimension int peekDistance,
                           Point out) {
    final int gravitySign = gravity == Gravity.START ? -1 : 1;
    final int distanceMultiplier = gravity == Gravity.START ? 0 : 1;
    int x, y;
    switch (orientation) {
        case Orientation.HORIZONTAL:
            y = (distanceMultiplier * getHeight()) + gravitySign * (Math.abs(radius - peekDistance));
            x = getWidth() / 2;
            break;
        case Orientation.VERTICAL:
        default:
            y = getHeight() / 2;
            x = (distanceMultiplier * getWidth()) + gravitySign * (Math.abs(radius - peekDistance));
            break;
    }
    out.set(x, y);
    return out;
}
 
源代码5 项目: Luban-Circle-Demo   文件: ScreenUtils.java
public static Point getScreenSize(Context context){
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point out = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(out);
    }else{
        int width = display.getWidth();
        int height = display.getHeight();
        out.set(width, height);
    }
    return out;
}
 
源代码6 项目: SEAL-Demo   文件: RunActivity.java
private void autoCenterMap(LatLng latLng) {
    //move map camera
    Point mMapPoint = mMap.getProjection().toScreenLocation(latLng);
    // add y offset to avoid overlay with mDistanceText
    mMapPoint.set(mMapPoint.x, mMapPoint.y + MAP_Y_OFFSET);
    mMap.moveCamera(CameraUpdateFactory.newLatLng(mMap.getProjection().fromScreenLocation(mMapPoint)));
}
 
源代码7 项目: PopupCircleMenu   文件: PopupCircleView.java
/**
 * @return Point  View在此window的中心坐标
 * */
private Point getViewCenterPoint() {
    Point centerPoint = new Point();
    int[] location = new int[2];
    getLocationInWindow(location);
    centerPoint.set(location[0]+getWidth()/2, location[1]+getWidth()/2);
    return centerPoint;
}
 
源代码8 项目: VideoFaceDetection   文件: Util.java
@SuppressWarnings("deprecation")
private static Point getDefaultDisplaySize(Activity activity, Point size) {
    Display d = activity.getWindowManager().getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        d.getSize(size);
    } else {
        size.set(d.getWidth(), d.getHeight());
    }
    return size;
}
 
源代码9 项目: XRadarView   文件: XRadarView.java
private void drawRegion(Canvas canvas, float scale) {
    canvas.save();
    singlePaint.setColor(singleColor);
    if (enabledRegionShader) {
        singlePaint.setShader(regionShader);
    } else {
        singlePaint.setShader(null);
    }
    List<Point> list = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        int x, y;
        x = (int) (centerX + scale * percents[i] * radius * Math.cos(angle * i + Math.PI / 2));
        y = (int) (centerY - scale * percents[i] * radius * Math.sin(angle * i + Math.PI / 2));
        Point p = new Point();
        p.set(x, y);
        list.add(p);
    }

    Path path = new Path();
    for (int i = 0; i < list.size(); i++) {
        if (i == 0) {
            path.moveTo(list.get(i).x, list.get(i).y);
        } else {
            path.lineTo(list.get(i).x, list.get(i).y);
        }
    }
    path.close();
    canvas.drawPath(path, singlePaint);
    canvas.restore();
}
 
源代码10 项目: Overchan-Android   文件: CompatibilityUtils.java
@SuppressWarnings("deprecation")
public static void getDisplaySize(Display display, Point outSize) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        outSize.set(display.getWidth(), display.getHeight());
    } else {
        CompatibilityImpl.getDisplaySize(display, outSize);
    }
}
 
源代码11 项目: reacteu-app   文件: CameraConfigurationManager.java
/**
   * Reads, one time, values from the camera that are needed by the app.
   */
  void initFromCameraParameters(Camera camera) {
    Camera.Parameters parameters = camera.getParameters();
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);

    screenResolution = new Point();
    int width = metrics.widthPixels;
    int height = metrics.heightPixels;

    // Remove action bar height
    TypedValue typedValue = new TypedValue();
    DisplayMetrics displayMetrics = this.context.getResources().getDisplayMetrics();
    if (this.context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) {
      height -= TypedValue.complexToDimensionPixelSize(typedValue.data, displayMetrics);
    } else {
      int rotation = context.getApplicationContext().getResources().getConfiguration().orientation;
      if (rotation == Configuration.ORIENTATION_PORTRAIT) {
        height -= 40 * displayMetrics.density;
      } else {
        height -= 48 * displayMetrics.density;
      }
    }
//    height -= statusBarHeight();
    height -= 50;

    screenResolution.set(width, height);

    Log.i(TAG, "Screen resolution: " + screenResolution);
    cameraResolution = findBestPreviewSizeValue(parameters, screenResolution);
    Log.i(TAG, "Camera resolution: " + cameraResolution);
  }
 
源代码12 项目: UltimateAndroid   文件: ZoomPanLayout.java
private void constrainPoint( Point point ) {
	int x = point.x;
	int y = point.y;
	int mx = Math.max( 0, Math.min( x, getLimitX() ) );
	int my = Math.max( 0, Math.min( y, getLimitY() ) );
	if ( x != mx || y != my ) {
		point.set( mx, my );
	}
}
 
源代码13 项目: OmegaRecyclerView   文件: HorizontalHelper.java
@Override
public void shiftViewCenter(Direction direction, int shiftAmount, Point outCenter) {
    int newX = outCenter.x + direction.applyTo(shiftAmount);
    outCenter.set(newX, outCenter.y);
}
 
源代码14 项目: AndroidAnimationsActions   文件: MainActivity.java
@OnClick(R.id.playSecondAnim)
protected void playSecondAnim() {
    firstAnimContainer.removeAllViews();
    secondAnimContainer.removeAllViews();
    Point center = new Point(secondAnimContainer.getMeasuredWidth() / 2, secondAnimContainer.getMeasuredHeight() / 2);
    int size = getResources().getDimensionPixelSize(R.dimen.circle_size);
    float delay = 0;
    for (int i = 0; i < 6; i++) {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(size, size);
        final ImageView view = new ImageView(this);
        view.setLayoutParams(params);
        view.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.square));
        Point newPos = new Point();
        switch (i) {
            case 0:
                newPos.set(0, 0);
                break;

            case 1:
                newPos.set(0, center.y);
                break;

            case 2:
                newPos.set(0, center.y * 2 - size);
                break;

            case 3:
                newPos.set(center.x * 2 - size, 0);
                break;

            case 4:
                newPos.set(center.x * 2 - size, center.y);
                break;

            case 5:
                newPos.set(center.x * 2 - size, center.y * 2 - size);
                break;
        }
        play(sequence(parallel(fadeOut(), color(-1, Color.BLUE)), moveTo(center.x, center.y),
                fadeIn(.5f), parallel(moveTo(newPos.x, newPos.y, 1, Interpolations.ExponentialEaseOut)), run(new Runnable() {
                    @Override
                    public void run() {
                        play(sequence(color(Color.BLUE, Color.GREEN, .1f), forever(sequence(color(Color.GREEN, Color.RED, 1), color(Color.GREEN, Color.RED, 1)))), view);
                    }
                }),
                parallel(rotateBy(720, 2, Interpolations.BackEaseOut), sequence(scaleTo(.5f, .5f, 1, Interpolations.BackEaseOut),
                        scaleTo(1, 1, 1, Interpolations.ElasticEaseOut))), sequence(delay(delay), parallel(fadeOut(.5f, Interpolations.ExponentialEaseOut),
                        scaleTo(0, 1, .5f, Interpolations.ExponentialEaseOut)))), view);
        delay += 1f;
        secondAnimContainer.addView(view);
    }
}
 
源代码15 项目: OmegaRecyclerView   文件: VerticalHelper.java
@Override
public void setCurrentViewCenter(Point recyclerCenter, int scrolled, Point outPoint) {
    int newY = recyclerCenter.y - scrolled;
    outPoint.set(recyclerCenter.x, newY);
}
 
源代码16 项目: XPlayer2   文件: DSVOrientation.java
@Override
public void shiftViewCenter(Direction direction, int shiftAmount, Point outCenter) {
    int newX = outCenter.x + direction.applyTo(shiftAmount);
    outCenter.set(newX, outCenter.y);
}
 
源代码17 项目: XPlayer2   文件: DSVOrientation.java
@Override
public void setCurrentViewCenter(Point recyclerCenter, int scrolled, Point outPoint) {
    int newY = recyclerCenter.y - scrolled;
    outPoint.set(recyclerCenter.x, newY);
}
 
源代码18 项目: talk-android   文件: RecipientEditTextView.java
@Override
public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
    Rect rect = mChip.getBounds();
    shadowSize.set(rect.width(), rect.height());
    shadowTouchPoint.set(rect.centerX(), rect.centerY());
}
 
源代码19 项目: openScale   文件: MeasurementPreferences.java
@Override
public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) {
    super.onProvideShadowMetrics(outShadowSize, outShadowTouchPoint);
    outShadowTouchPoint.set(x, y);
}
 
源代码20 项目: OmegaRecyclerView   文件: VerticalHelper.java
@Override
public void shiftViewCenter(Direction direction, int shiftAmount, Point outCenter) {
    int newY = outCenter.y + direction.applyTo(shiftAmount);
    outCenter.set(outCenter.x, newY);
}
 
 方法所在类
 同类方法