Java Code Examples for android.graphics.RectF#setEmpty()
The following examples show how to use
android.graphics.RectF#setEmpty() .
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: DefaultScrollbarHorizontal.java From ProjectX with Apache License 2.0 | 6 votes |
@Override public void getTouchBound(ScrollbarRecyclerView view, RectF bound, int slop) { if (mAnimatorValue == 0 && !mAlwaysTouchable) { bound.setEmpty(); return; } if (mTouchStartOnBar) { bound.set(view.getPaddingLeft() + mPaddingStart - slop, mSliderBound.top - slop, view.getWidth() - view.getPaddingRight() - mPaddingEnd + slop, mSliderBound.bottom + slop); } else { bound.set(mSliderBound.left - slop, mSliderBound.top - slop, mSliderBound.right + slop, mSliderBound.bottom + slop); } }
Example 2
Source File: DefaultScrollbarVertical.java From ProjectX with Apache License 2.0 | 6 votes |
@Override public void getTouchBound(ScrollbarRecyclerView view, RectF bound, int slop) { if (mAnimatorValue == 0 && !mAlwaysTouchable) { bound.setEmpty(); return; } if (mTouchStartOnBar) { bound.set(mSliderBound.left - slop, view.getPaddingTop() + mPaddingStart - slop, mSliderBound.right + slop, view.getHeight() - view.getPaddingBottom() - mPaddingEnd + slop); } else { bound.set(mSliderBound.left - slop, mSliderBound.top - slop, mSliderBound.right + slop, mSliderBound.bottom + slop); } }
Example 3
Source File: ChipDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
/** * Calculates the chip icon's ChipDrawable-absolute bounds (top-left is <code> * [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]</code>). */ private void calculateChipIconBounds(@NonNull Rect bounds, @NonNull RectF outBounds) { outBounds.setEmpty(); if (showsChipIcon() || showsCheckedIcon()) { float offsetFromStart = chipStartPadding + iconStartPadding; float chipWidth = getCurrentChipIconWidth(); if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { outBounds.left = bounds.left + offsetFromStart; outBounds.right = outBounds.left + chipWidth; } else { outBounds.right = bounds.right - offsetFromStart; outBounds.left = outBounds.right - chipWidth; } float chipHeight = getCurrentChipIconHeight(); outBounds.top = bounds.exactCenterY() - chipHeight / 2f; outBounds.bottom = outBounds.top + chipHeight; } }
Example 4
Source File: ChipDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
/** * Calculates the chip text's ChipDrawable-absolute bounds (top-left is <code> * [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]</code>). */ private void calculateTextBounds(@NonNull Rect bounds, @NonNull RectF outBounds) { outBounds.setEmpty(); if (text != null) { float offsetFromStart = chipStartPadding + calculateChipIconWidth() + textStartPadding; float offsetFromEnd = chipEndPadding + calculateCloseIconWidth() + textEndPadding; if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { outBounds.left = bounds.left + offsetFromStart; outBounds.right = bounds.right - offsetFromEnd; } else { outBounds.left = bounds.left + offsetFromEnd; outBounds.right = bounds.right - offsetFromStart; } // Top and bottom included for completion. Don't position the chip text vertically based on // these bounds. Instead, use #calculateTextOriginAndAlignment(). outBounds.top = bounds.top; outBounds.bottom = bounds.bottom; } }
Example 5
Source File: ChipDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
/** * Calculates the close icon's ChipDrawable-absolute bounds (top-left is <code> * [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]</code>). */ private void calculateCloseIconBounds(@NonNull Rect bounds, @NonNull RectF outBounds) { outBounds.setEmpty(); if (showsCloseIcon()) { float offsetFromEnd = chipEndPadding + closeIconEndPadding; if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { outBounds.right = bounds.right - offsetFromEnd; outBounds.left = outBounds.right - closeIconSize; } else { outBounds.left = bounds.left + offsetFromEnd; outBounds.right = outBounds.left + closeIconSize; } outBounds.top = bounds.exactCenterY() - closeIconSize / 2f; outBounds.bottom = outBounds.top + closeIconSize; } }
Example 6
Source File: ChipDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
private void calculateCloseIconTouchBounds(@NonNull Rect bounds, @NonNull RectF outBounds) { outBounds.setEmpty(); if (showsCloseIcon()) { float offsetFromEnd = chipEndPadding + closeIconEndPadding + closeIconSize + closeIconStartPadding + textEndPadding; if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { outBounds.right = bounds.right; outBounds.left = outBounds.right - offsetFromEnd; } else { outBounds.left = bounds.left; outBounds.right = bounds.left + offsetFromEnd; } outBounds.top = bounds.top; outBounds.bottom = bounds.bottom; } }
Example 7
Source File: ScaleDragHelper.java From sketch with Apache License 2.0 | 5 votes |
/** * 获取绘制区域 */ void getDrawRect(RectF rectF) { if (!imageZoomer.isWorking()) { if (SLog.isLoggable(SLog.LEVEL_VERBOSE | SLog.TYPE_ZOOM)) { SLog.v(NAME, "not working. getDrawRect"); } rectF.setEmpty(); return; } Size drawableSize = imageZoomer.getDrawableSize(); rectF.set(0, 0, drawableSize.getWidth(), drawableSize.getHeight()); getDrawMatrix().mapRect(rectF); }
Example 8
Source File: CompositionAvatarView.java From CompositionAvatar with MIT License | 5 votes |
private void updateDrawableBounds(DrawableInfo drawableInfo) { final Drawable drawable = drawableInfo.mDrawable; final float radius = mSteinerCircleRadius; if (radius <= 0) { drawable.setBounds(0, 0, 0, 0); return; } final int dWidth = drawable.getIntrinsicWidth(); final int dHeight = drawable.getIntrinsicHeight(); final RectF bounds = mTempBounds; bounds.setEmpty(); if (dWidth <= 0 || dHeight <= 0 || dWidth == dHeight || FitType.FIT == mFitType) { bounds.inset(-radius, -radius); } else { float scale; if (dWidth > dHeight) { scale = radius / (float) dHeight; } else { scale = radius / (float) dWidth; } bounds.inset(-dWidth * scale, -dHeight * scale); if (FitType.START == mFitType || FitType.END == mFitType) { int dir = FitType.START == mFitType ? 1 : -1; bounds.offset((bounds.width() * 0.5f - radius) * dir, (bounds.height() * 0.5f - radius) * dir); } } bounds.offset(drawableInfo.mCenterX, drawableInfo.mCenterY); drawable.setBounds((int) bounds.left, (int) bounds.top, Math.round(bounds.right), Math.round(bounds.bottom)); }
Example 9
Source File: ScrollBarHelper.java From sketch with Apache License 2.0 | 4 votes |
void onDraw(@NonNull Canvas canvas) { final RectF drawRectF = tempDisplayRectF; imageZoomer.getDrawRect(drawRectF); if (drawRectF.isEmpty()) { if (SLog.isLoggable(SLog.LEVEL_DEBUG | SLog.TYPE_ZOOM)) { SLog.d(ImageZoomer.NAME, "displayRectF is empty. drawScrollBar. drawRectF=%s", drawRectF.toString()); } return; } Size viewSize = imageZoomer.getViewSize(); final int viewWidth = viewSize.getWidth(); final int viewHeight = viewSize.getHeight(); final float displayWidth = drawRectF.width(); final float displayHeight = drawRectF.height(); if (viewWidth <= 0 || viewHeight <= 0 || displayWidth == 0 || displayHeight == 0) { if (SLog.isLoggable(SLog.LEVEL_DEBUG | SLog.TYPE_ZOOM)) { SLog.d(ImageZoomer.NAME, "size is 0. drawScrollBar. viewSize=%dx%d, displaySize=%sx%s", viewWidth, viewHeight, displayWidth, displayHeight); } return; } ImageView imageView = imageZoomer.getImageView(); final int finalViewWidth = viewWidth - (scrollBarMargin * 2); final int finalViewHeight = viewHeight - (scrollBarMargin * 2); if ((int) displayWidth > viewWidth) { final float widthScale = (float) viewWidth / displayWidth; final int horScrollBarWidth = (int) (finalViewWidth * widthScale); RectF horScrollBarRectF = scrollBarRectF; horScrollBarRectF.setEmpty(); horScrollBarRectF.left = imageView.getPaddingLeft() + scrollBarMargin + (drawRectF.left < 0 ? (int) ((Math.abs(drawRectF.left) / drawRectF.width()) * finalViewWidth) : 0); horScrollBarRectF.top = imageView.getPaddingTop() + scrollBarMargin + finalViewHeight - scrollBarSize; horScrollBarRectF.right = horScrollBarRectF.left + horScrollBarWidth; horScrollBarRectF.bottom = horScrollBarRectF.top + scrollBarSize; canvas.drawRoundRect(horScrollBarRectF, scrollBarRadius, scrollBarRadius, scrollBarPaint); } if ((int) displayHeight > viewHeight) { final float heightScale = (float) viewHeight / displayHeight; final int verScrollBarHeight = (int) (finalViewHeight * heightScale); RectF verScrollBarRectF = scrollBarRectF; verScrollBarRectF.setEmpty(); verScrollBarRectF.left = imageView.getPaddingLeft() + scrollBarMargin + finalViewWidth - scrollBarSize; verScrollBarRectF.top = imageView.getPaddingTop() + scrollBarMargin + (drawRectF.top < 0 ? (int) ((Math.abs(drawRectF.top) / drawRectF.height()) * finalViewHeight) : 0); verScrollBarRectF.right = verScrollBarRectF.left + scrollBarSize; verScrollBarRectF.bottom = verScrollBarRectF.top + verScrollBarHeight; canvas.drawRoundRect(verScrollBarRectF, scrollBarRadius, scrollBarRadius, scrollBarPaint); } }
Example 10
Source File: SelectionActionModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Merges a {@link RectF} into an existing list of any objects which contain a rectangle. * While merging, this method makes sure that: * * <ol> * <li>No rectangle is redundant (contained within a bigger rectangle)</li> * <li>Rectangles of the same height and vertical position that intersect get merged</li> * </ol> * * @param list the list of rectangles (or other rectangle containers) to merge the new * rectangle into * @param candidate the {@link RectF} to merge into the list * @param extractor a function that can extract a {@link RectF} from an element of the given * list * @param packer a function that can wrap the resulting {@link RectF} into an element that * the list contains * @hide */ @VisibleForTesting public static <T> void mergeRectangleIntoList(final List<T> list, final RectF candidate, final Function<T, RectF> extractor, final Function<RectF, T> packer) { if (candidate.isEmpty()) { return; } final int elementCount = list.size(); for (int index = 0; index < elementCount; ++index) { final RectF existingRectangle = extractor.apply(list.get(index)); if (existingRectangle.contains(candidate)) { return; } if (candidate.contains(existingRectangle)) { existingRectangle.setEmpty(); continue; } final boolean rectanglesContinueEachOther = candidate.left == existingRectangle.right || candidate.right == existingRectangle.left; final boolean canMerge = candidate.top == existingRectangle.top && candidate.bottom == existingRectangle.bottom && (RectF.intersects(candidate, existingRectangle) || rectanglesContinueEachOther); if (canMerge) { candidate.union(existingRectangle); existingRectangle.setEmpty(); } } for (int index = elementCount - 1; index >= 0; --index) { final RectF rectangle = extractor.apply(list.get(index)); if (rectangle.isEmpty()) { list.remove(index); } } list.add(packer.apply(candidate)); }
Example 11
Source File: PinchImageView.java From PinchImageView with MIT License | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 12
Source File: PinchImageView.java From UGank with GNU General Public License v3.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 13
Source File: PinchImageView.java From FaceT with Mozilla Public License 2.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 14
Source File: PinchImageView.java From LLApp with Apache License 2.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 15
Source File: PinchImageView.java From SmallGdufe-Android with GNU General Public License v3.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 16
Source File: PinchImageView.java From ImagePicker with Apache License 2.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 17
Source File: PinchImageView.java From AcgClub with MIT License | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }
Example 18
Source File: PinchImageView.java From leafpicrevived with GNU General Public License v3.0 | 4 votes |
@Override protected RectF resetInstance(RectF obj) { obj.setEmpty(); return obj; }