Java Code Examples for android.graphics.Rect#scale()

The following examples show how to use android.graphics.Rect#scale() . 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: TaskSnapshotSurface.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Calculates the snapshot frame in window coordinate space from crop.
 *
 * @param crop rect that is in snapshot coordinate space.
 */
@VisibleForTesting
Rect calculateSnapshotFrame(Rect crop) {
    final Rect frame = new Rect(crop);
    final float scale = mSnapshot.getScale();

    // Rescale the frame from snapshot to window coordinate space
    frame.scale(1 / scale);

    // By default, offset it to to top/left corner
    frame.offsetTo((int) (-crop.left / scale), (int) (-crop.top / scale));

    // However, we also need to make space for the navigation bar on the left side.
    final int colorViewLeftInset = getColorViewLeftInset(mStableInsets.left,
            mContentInsets.left);
    frame.offset(colorViewLeftInset, 0);
    return frame;
}
 
Example 2
Source File: AccessibilityController.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void getMagnifiedFrameInContentCoordsLocked(Rect rect) {
    MagnificationSpec spec = mMagnificationSpec;
    mMagnificationRegion.getBounds(rect);
    rect.offset((int) -spec.offsetX, (int) -spec.offsetY);
    rect.scale(1.0f / spec.scale);
}
 
Example 3
Source File: CompatibilityInfo.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Translate the screen rect to the application frame.
 */
public void translateRectInScreenToAppWinFrame(Rect rect) {
    rect.scale(applicationInvertedScale);
}
 
Example 4
Source File: CompatibilityInfo.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Translate a Rect in application's window to screen.
 */
public void translateRectInAppWindowToScreen(Rect rect) {
    rect.scale(applicationScale);
}
 
Example 5
Source File: CompatibilityInfo.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Translate a Rect in screen coordinates into the app window's coordinates.
 */
public void translateRectInScreenToAppWindow(Rect rect) {
    rect.scale(applicationInvertedScale);
}
 
Example 6
Source File: NumberPicker.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
        int right, int bottom) {
    AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
    info.setClassName(NumberPicker.class.getName());
    info.setPackageName(mContext.getPackageName());
    info.setSource(NumberPicker.this);

    if (hasVirtualDecrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
    }
    info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
    if (hasVirtualIncrementButton()) {
        info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
    }

    info.setParent((View) getParentForAccessibility());
    info.setEnabled(NumberPicker.this.isEnabled());
    info.setScrollable(true);

    final float applicationScale =
        getContext().getResources().getCompatibilityInfo().applicationScale;

    Rect boundsInParent = mTempRect;
    boundsInParent.set(left, top, right, bottom);
    boundsInParent.scale(applicationScale);
    info.setBoundsInParent(boundsInParent);

    info.setVisibleToUser(isVisibleToUser());

    Rect boundsInScreen = boundsInParent;
    int[] locationOnScreen = mTempArray;
    getLocationOnScreen(locationOnScreen);
    boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
    boundsInScreen.scale(applicationScale);
    info.setBoundsInScreen(boundsInScreen);

    if (mAccessibilityFocusedView != View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    }
    if (mAccessibilityFocusedView == View.NO_ID) {
        info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    }
    if (NumberPicker.this.isEnabled()) {
        if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
        if (getWrapSelectorWheel() || getValue() > getMinValue()) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    }

    return info;
}