android.graphics.RectF#isEmpty ( )源码实例Demo

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

源代码1 项目: PinchImageView   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码2 项目: leafpicrevived   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码3 项目: leafpicrevived   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码4 项目: PinchImageView   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码5 项目: sketch   文件: ScaleDragHelper.java
@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);
        }
    }
}
 
源代码6 项目: Reader   文件: PDFPageView.java
@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());
    }
}
 
源代码7 项目: AcgClub   文件: PinchImageView.java
/**
 * 与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;
  }
}
 
源代码8 项目: AcgClub   文件: PinchImageView.java
/**
 * 与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;
  }
}
 
源代码9 项目: ImagePicker   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码10 项目: ImagePicker   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码11 项目: SmallGdufe-Android   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码12 项目: SmallGdufe-Android   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码13 项目: FaceT   文件: PinchImageView.java
/**
 * 与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;
    }
}
 
源代码14 项目: libcommon   文件: ViewTransformDelegater.java
/**
 * 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);
}
 
@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);
}
 
源代码16 项目: android-DecoView-charting   文件: ChartSeries.java
@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;
}
 
源代码17 项目: android-DecoView-charting   文件: ChartSeries.java
/**
 * 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;
}
 
源代码18 项目: sketch   文件: ScrollBarHelper.java
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);
    }
}
 
源代码19 项目: sketch   文件: ScaleDragHelper.java
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;
}
 
源代码20 项目: sketch   文件: FlingRunner.java
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);
}