Java Code Examples for android.graphics.RectF#isEmpty()

The following examples show how to use android.graphics.RectF#isEmpty() . 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: PinchImageView.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 *
 * @param direction
 * @return
 */
@Override
public boolean canScrollHorizontally(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.right > getWidth();
    } else {
        return bound.left < 0;
    }
}
 
Example 2
Source File: PinchImageView.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 *
 * @param direction
 * @return
 */
@Override
public boolean canScrollVertically(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.bottom > getHeight();
    } else {
        return bound.top < 0;
    }
}
 
Example 3
Source File: PinchImageView.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 * @param direction
 * @return
 */
@Override
public boolean canScrollVertically(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.bottom > getHeight();
    } else {
        return bound.top < 0;
    }
}
 
Example 4
Source File: PinchImageView.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 * @param direction
 * @return
 */
@Override
public boolean canScrollHorizontally(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.right > getWidth();
    } else {
        return bound.left < 0;
    }
}
 
Example 5
Source File: PinchImageView.java    From ImagePicker with Apache License 2.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 *
 * @param direction
 * @return
 */
@Override
public boolean canScrollVertically(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.bottom > getHeight();
    } else {
        return bound.top < 0;
    }
}
 
Example 6
Source File: PinchImageView.java    From ImagePicker with Apache License 2.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 *
 * @param direction
 * @return
 */
@Override
public boolean canScrollHorizontally(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.right > getWidth();
    } else {
        return bound.left < 0;
    }
}
 
Example 7
Source File: PinchImageView.java    From AcgClub with MIT License 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 */
@Override
public boolean canScrollVertically(int direction) {
  if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
    return true;
  }
  RectF bound = getImageBound(null);
  if (bound == null) {
    return false;
  }
  if (bound.isEmpty()) {
    return false;
  }
  if (direction > 0) {
    return bound.bottom > getHeight();
  } else {
    return bound.top < 0;
  }
}
 
Example 8
Source File: PinchImageView.java    From AcgClub with MIT License 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 */
@Override
public boolean canScrollHorizontally(int direction) {
  if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
    return true;
  }
  RectF bound = getImageBound(null);
  if (bound == null) {
    return false;
  }
  if (bound.isEmpty()) {
    return false;
  }
  if (direction > 0) {
    return bound.right > getWidth();
  } else {
    return bound.left < 0;
  }
}
 
Example 9
Source File: PDFPageView.java    From Reader with Apache License 2.0 6 votes vote down vote up
@Override
protected void drawStrikeOut(float scale, Canvas canvas, Paint paint) {
    LogUtils.d(TAG, "drawStrikeOut page=" + getPage()+" scale="+scale);
    if (mStrikeOutLists != null && mStrikeOutLists.size() > 0) {
        LogUtils.d(TAG, "drawStrikeOut mStrikeOutLists.size()="+mStrikeOutLists.size());

        for (AnnotationPointsBean point : mStrikeOutLists) {
            ArrayList<RectF> lists = point.getLists();
            for (int i = 0; i < lists.size(); i++) {
                RectF rect = lists.get(i);
                paint.setStrokeWidth(3.0f * scale);//设置笔刷的粗细度
                paint.setStyle(Paint.Style.FILL); //实心效果
                paint.setColor(getResources().getColor(R.color.my_strikeout_color));
                if (!rect.isEmpty()){
                    Log.d(TAG, "drawStrikeOut: rect.left="+rect.left+" rect.top="+rect.top+" rect.right="+rect.right+" bottom="+rect.bottom);
                    canvas.drawLine(rect.left*scale,(rect.bottom+rect.top)/2*scale,rect.right*scale,(rect.bottom+rect.top)/2*scale,paint);
                }

            }
        }
        Log.d(TAG, "drawUnderline: 当前删除框集合的大小size=" + baseAnnoLists.size());
    }
}
 
Example 10
Source File: ScaleDragHelper.java    From sketch with Apache License 2.0 6 votes vote down vote up
@Override
public void onActionUp(@NonNull MotionEvent ev) {
    float currentScale = SketchUtils.formatFloat(getZoomScale(), 2);
    if (currentScale < SketchUtils.formatFloat(imageZoomer.getMinZoomScale(), 2)) {
        // 如果当前缩放倍数小于最小倍数就回滚至最小倍数
        RectF drawRectF = new RectF();
        getDrawRect(drawRectF);
        if (!drawRectF.isEmpty()) {
            zoom(imageZoomer.getMinZoomScale(), drawRectF.centerX(), drawRectF.centerY(), true);
        }
    } else if (currentScale > SketchUtils.formatFloat(imageZoomer.getMaxZoomScale(), 2)) {
        // 如果当前缩放倍数大于最大倍数就回滚至最大倍数
        if (tempLastScaleFocusX != 0 && tempLastScaleFocusY != 0) {
            zoom(imageZoomer.getMaxZoomScale(), tempLastScaleFocusX, tempLastScaleFocusY, true);
        }
    }
}
 
Example 11
Source File: PinchImageView.java    From PinchImageView with MIT License 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 * @param direction
 * @return
 */
@Override
public boolean canScrollVertically(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.bottom > getHeight();
    } else {
        return bound.top < 0;
    }
}
 
Example 12
Source File: PinchImageView.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 *
 * @param direction
 * @return
 */
@Override
public boolean canScrollVertically(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.bottom > getHeight();
    } else {
        return bound.top < 0;
    }
}
 
Example 13
Source File: PinchImageView.java    From PinchImageView with MIT License 6 votes vote down vote up
/**
 * 与ViewPager结合的时候使用
 * @param direction
 * @return
 */
@Override
public boolean canScrollHorizontally(int direction) {
    if (mPinchMode == PinchImageView.PINCH_MODE_SCALE) {
        return true;
    }
    RectF bound = getImageBound(null);
    if (bound == null) {
        return false;
    }
    if (bound.isEmpty()) {
        return false;
    }
    if (direction > 0) {
        return bound.right > getWidth();
    } else {
        return bound.left < 0;
    }
}
 
Example 14
Source File: ViewTransformDelegater.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * View表内容の拡大縮小回転平行移動を初期化
 */
public void init() {
	if (DEBUG) Log.v(TAG, "init:" + mIsRestored);
	mState = STATE_RESET;
	clearPendingTasks();
	if (!mIsRestored) {
		onInit();
		updateTransform(true);
		mCurrentDegrees = 0.f;
	}
	mIsRestored = false;
	mIsRotating = Math.abs(((int)(mCurrentDegrees / 360.f)) * 360.f - mCurrentDegrees) > ViewUtils.EPS;

	// set limit rectangle that the image can move
	mLimitRect.set(getDrawingRect());
	if (DEBUG) Log.v(TAG, "init:mLimitRect=" + mLimitRect);
	// update image size
	final RectF bounds = getContentBounds();
	if ((bounds != null) && !bounds.isEmpty()) {
		mContentRect.set(bounds);
	} else {
		mContentRect.set(mLimitRect);
	}
	if (DEBUG) Log.v(TAG, "init:mContentRect=" + mContentRect);
	mLimitRect.inset((MOVE_LIMIT_RATE * getViewWidth()), (MOVE_LIMIT_RATE * getViewHeight()));
	mLimitSegments[0] = null;
	setupDefaultTransform();
	setState(STATE_NON);
}
 
Example 15
Source File: ShapeAppearancePathProvider.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@RequiresApi(VERSION_CODES.KITKAT)
private boolean pathOverlapsCorner(Path edgePath, int index) {
  Path cornerPath = new Path();
  cornerPaths[index].applyToPath(cornerTransforms[index], cornerPath);

  RectF bounds = new RectF();
  edgePath.computeBounds(bounds, /* exact = */ true);
  cornerPath.computeBounds(bounds, /* exact = */ true);
  edgePath.op(cornerPath, Op.INTERSECT);
  edgePath.computeBounds(bounds, /* exact = */ true);

  return !bounds.isEmpty() || (bounds.width() > 1 && bounds.height() > 1);
}
 
Example 16
Source File: ChartSeries.java    From android-DecoView-charting with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("UnusedReturnValue")
public RectF drawLabel(Canvas canvas, RectF bounds, float anglePercent) {

    if (!mVisible) {
        return null;
    }

    if (bounds == null || bounds.isEmpty()) {
        throw new IllegalArgumentException("Drawing bounds can not be null or empty");
    }
    if (mSeriesItem.getSeriesLabel() != null) {
        return mSeriesItem.getSeriesLabel().draw(canvas, bounds, anglePercent, getPositionPercent(), mPositionCurrentEnd);
    }
    return null;
}
 
Example 17
Source File: ChartSeries.java    From android-DecoView-charting with Apache License 2.0 5 votes vote down vote up
/**
 * Draw this series in the current position calculated by the ValueAnimator.
 *
 * @param canvas Canvas used to draw
 * @param bounds Bounds to be used to draw the arc
 * @return true if drawing has already been handled
 */
public boolean draw(Canvas canvas, RectF bounds) {
    if (!mVisible) {
        return true;
    }

    if (bounds == null || bounds.isEmpty()) {
        throw new IllegalArgumentException("Drawing bounds can not be null or empty");
    }

    processBoundsChange(bounds);

    if (mDrawMode == DecoEvent.EventType.EVENT_EFFECT) {
        // Delegate the drawing to the ArcEffect as required
        if (mEffect != null) {
            mEffect.draw(canvas, mBoundsInset, mPercentComplete, mAngleStart, mAngleSweep);
        }
        return true;
    }

    processRevealEffect();

    if (mColorAnimate != null) {
        mPaint.setColor(mColorAnimate.getColorCurrent(mPercentComplete));
    } else if (mPaint.getColor() != getSeriesItem().getColor()) {
        mPaint.setColor(getSeriesItem().getColor());
    }

    return false;
}
 
Example 18
Source File: ScrollBarHelper.java    From sketch with Apache License 2.0 4 votes vote down vote up
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 19
Source File: ScaleDragHelper.java    From sketch with Apache License 2.0 4 votes vote down vote up
private boolean checkMatrixBounds() {
    final RectF drawRectF = tempDisplayRectF;
    getDrawRect(drawRectF);
    if (drawRectF.isEmpty()) {
        horScrollEdge = EDGE_NONE;
        verScrollEdge = EDGE_NONE;
        return false;
    }

    final float displayHeight = drawRectF.height(), displayWidth = drawRectF.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = imageZoomer.getViewSize().getHeight();
    if ((int) displayHeight <= viewHeight) {
        switch (imageZoomer.getScaleType()) {
            case FIT_START:
                deltaY = -drawRectF.top;
                break;
            case FIT_END:
                deltaY = viewHeight - displayHeight - drawRectF.top;
                break;
            default:
                deltaY = (viewHeight - displayHeight) / 2 - drawRectF.top;
                break;
        }
    } else if ((int) drawRectF.top > 0) {
        deltaY = -drawRectF.top;
    } else if ((int) drawRectF.bottom < viewHeight) {
        deltaY = viewHeight - drawRectF.bottom;
    }

    final int viewWidth = imageZoomer.getViewSize().getWidth();
    if ((int) displayWidth <= viewWidth) {
        switch (imageZoomer.getScaleType()) {
            case FIT_START:
                deltaX = -drawRectF.left;
                break;
            case FIT_END:
                deltaX = viewWidth - displayWidth - drawRectF.left;
                break;
            default:
                deltaX = (viewWidth - displayWidth) / 2 - drawRectF.left;
                break;
        }
    } else if ((int) drawRectF.left > 0) {
        deltaX = -drawRectF.left;
    } else if ((int) drawRectF.right < viewWidth) {
        deltaX = viewWidth - drawRectF.right;
    }

    // Finally actually translate the matrix
    supportMatrix.postTranslate(deltaX, deltaY);

    if ((int) displayHeight <= viewHeight) {
        verScrollEdge = EDGE_BOTH;
    } else if ((int) drawRectF.top >= 0) {
        verScrollEdge = EDGE_START;
    } else if ((int) drawRectF.bottom <= viewHeight) {
        verScrollEdge = EDGE_END;
    } else {
        verScrollEdge = EDGE_NONE;
    }

    if ((int) displayWidth <= viewWidth) {
        horScrollEdge = EDGE_BOTH;
    } else if ((int) drawRectF.left >= 0) {
        horScrollEdge = EDGE_START;
    } else if ((int) drawRectF.right <= viewWidth) {
        horScrollEdge = EDGE_END;
    } else {
        horScrollEdge = EDGE_NONE;
    }

    return true;
}
 
Example 20
Source File: FlingRunner.java    From sketch with Apache License 2.0 4 votes vote down vote up
void fling(int velocityX, int velocityY) {
    if (!imageZoomer.isWorking()) {
        SLog.w(ImageZoomer.NAME, "not working. fling");
        return;
    }

    RectF drawRectF = new RectF();
    scaleDragHelper.getDrawRect(drawRectF);
    if (drawRectF.isEmpty()) {
        return;
    }

    Size viewSize = imageZoomer.getViewSize();
    final int imageViewWidth = viewSize.getWidth();
    final int imageViewHeight = viewSize.getHeight();

    final int startX = Math.round(-drawRectF.left);
    final int minX, maxX, minY, maxY;
    if (imageViewWidth < drawRectF.width()) {
        minX = 0;
        maxX = Math.round(drawRectF.width() - imageViewWidth);
    } else {
        minX = maxX = startX;
    }

    final int startY = Math.round(-drawRectF.top);
    if (imageViewHeight < drawRectF.height()) {
        minY = 0;
        maxY = Math.round(drawRectF.height() - imageViewHeight);
    } else {
        minY = maxY = startY;
    }

    if (SLog.isLoggable(SLog.LEVEL_DEBUG | SLog.TYPE_ZOOM)) {
        SLog.d(ImageZoomer.NAME, "fling. start=%dx %d, min=%dx%d, max=%dx%d",
                startX, startY, minX, minY, maxX, maxY);
    }

    // If we actually can move, fling the scroller
    if (startX != maxX || startY != maxY) {
        currentX = startX;
        currentY = startY;
        scroller.fling(startX, startY, velocityX, velocityY, minX,
                maxX, minY, maxY, 0, 0);
    }

    ImageView imageView = imageZoomer.getImageView();
    imageView.removeCallbacks(this);
    imageView.post(this);
}