本文整理汇总了Java中android.graphics.RectF.height方法的典型用法代码示例。如果您正苦于以下问题:Java RectF.height方法的具体用法?Java RectF.height怎么用?Java RectF.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.RectF
的用法示例。
在下文中一共展示了RectF.height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pointToHue
import android.graphics.RectF; //导入方法依赖的package包/类
private float pointToHue(float y){
final RectF rect = mHueRect;
float height = rect.height();
if (y < rect.top){
y = 0f;
}
else if(y > rect.bottom){
y = height;
}
else{
y = y - rect.top;
}
return 360f - (y * 360f / height);
}
示例2: center
import android.graphics.RectF; //导入方法依赖的package包/类
protected void center() {
final Bitmap bitmap = bitmapDisplayed.getBitmap();
if (bitmap == null) {
return;
}
Matrix m = getImageViewMatrix();
RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
m.mapRect(rect);
float height = rect.height();
float width = rect.width();
float deltaX = 0, deltaY = 0;
deltaY = centerVertical(rect, height, deltaY);
deltaX = centerHorizontal(rect, width, deltaX);
postTranslate(deltaX, deltaY);
setImageMatrix(getImageViewMatrix());
}
示例3: add
import android.graphics.RectF; //导入方法依赖的package包/类
public void add(MediaItem item, int faceIndex) {
Path path = item.getPath();
mPaths.add(path);
Face[] faces = item.getFaces();
if (faces != null) {
Face face = faces[faceIndex];
if (mCoverItem == null) {
mCoverItem = item;
mCoverRegion = face.getPosition();
mCoverFaceIndex = faceIndex;
} else {
RectF region = face.getPosition();
if (mCoverRegion.width() < region.width() &&
mCoverRegion.height() < region.height()) {
mCoverItem = item;
mCoverRegion = face.getPosition();
mCoverFaceIndex = faceIndex;
}
}
}
}
示例4: fling
import android.graphics.RectF; //导入方法依赖的package包/类
public void fling(int viewWidth, int viewHeight, int velocityX,
int velocityY) {
final RectF rect = getDisplayRect();
if (rect == null) {
return;
}
final int startX = Math.round(-rect.left);
final int minX, maxX, minY, maxY;
if (viewWidth < rect.width()) {
minX = 0;
maxX = Math.round(rect.width() - viewWidth);
} else {
minX = maxX = startX;
}
final int startY = Math.round(-rect.top);
if (viewHeight < rect.height()) {
minY = 0;
maxY = Math.round(rect.height() - viewHeight);
} else {
minY = maxY = startY;
}
mCurrentX = startX;
mCurrentY = startY;
// If we actually can move, fling the scroller
if (startX != maxX || startY != maxY) {
mScroller.fling(startX, startY, velocityX, velocityY, minX,
maxX, minY, maxY, 0, 0);
}
}
示例5: pointToHue
import android.graphics.RectF; //导入方法依赖的package包/类
private float pointToHue(float y) {
final RectF rect = mHueRect;
float height = rect.height();
if (y < rect.top) {
y = 0f;
} else if (y > rect.bottom) {
y = height;
} else {
y = y - rect.top;
}
return 360f - (y * 360f / height);
}
示例6: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@Override public boolean onSingleTapConfirmed(MotionEvent e) {
if (mAttacher == null) {
return false;
}
DraweeView<GenericDraweeHierarchy> draweeView = mAttacher.getDraweeView();
if (draweeView == null) {
return false;
}
if (mAttacher.getOnPhotoTapListener() != null) {
final RectF displayRect = mAttacher.getDisplayRect();
if (null != displayRect) {
final float x = e.getX(), y = e.getY();
if (displayRect.contains(x, y)) {
float xResult = (x - displayRect.left) / displayRect.width();
float yResult = (y - displayRect.top) / displayRect.height();
mAttacher.getOnPhotoTapListener().onPhotoTap(draweeView, xResult, yResult);
return true;
}
}
}
if (mAttacher.getOnViewTapListener() != null) {
mAttacher.getOnViewTapListener().onViewTap(draweeView, e.getX(), e.getY());
return true;
}
return false;
}
示例7: limitTransAndScale
import android.graphics.RectF; //导入方法依赖的package包/类
/**
* limits the maximum scale and X translation of the given matrix
*
* @param matrix
*/
public void limitTransAndScale(Matrix matrix, RectF content) {
matrix.getValues(matrixBuffer);
float curTransX = matrixBuffer[Matrix.MTRANS_X];
float curScaleX = matrixBuffer[Matrix.MSCALE_X];
float curTransY = matrixBuffer[Matrix.MTRANS_Y];
float curScaleY = matrixBuffer[Matrix.MSCALE_Y];
// min scale-x is 1f
mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX);
// min scale-y is 1f
mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY);
float width = 0f;
float height = 0f;
if (content != null) {
width = content.width();
height = content.height();
}
float maxTransX = -width * (mScaleX - 1f);
mTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);
float maxTransY = height * (mScaleY - 1f);
mTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);
matrixBuffer[Matrix.MTRANS_X] = mTransX;
matrixBuffer[Matrix.MSCALE_X] = mScaleX;
matrixBuffer[Matrix.MTRANS_Y] = mTransY;
matrixBuffer[Matrix.MSCALE_Y] = mScaleY;
matrix.setValues(matrixBuffer);
}
示例8: getCenter
import android.graphics.RectF; //导入方法依赖的package包/类
protected RectF getCenter(Matrix supportMatrix, boolean horizontal, boolean vertical) {
final Drawable drawable = getDrawable();
if (drawable == null) {
return new RectF(0, 0, 0, 0);
}
mCenterRect.set(0, 0, 0, 0);
RectF rect = getBitmapRect(supportMatrix);
float height = rect.height();
float width = rect.width();
float deltaX = 0, deltaY = 0;
if (vertical) {
if (height < mViewPort.height()) {
deltaY = (mViewPort.height() - height) / 2 - (rect.top - mViewPort.top);
} else if (rect.top > mViewPort.top) {
deltaY = -(rect.top - mViewPort.top);
} else if (rect.bottom < mViewPort.bottom) {
deltaY = mViewPort.bottom - rect.bottom;
}
}
if (horizontal) {
if (width < mViewPort.width()) {
deltaX = (mViewPort.width() - width) / 2 - (rect.left - mViewPort.left);
} else if (rect.left > mViewPort.left) {
deltaX = -(rect.left - mViewPort.left);
} else if (rect.right < mViewPort.right) {
deltaX = mViewPort.right - rect.right;
}
}
mCenterRect.set(deltaX, deltaY, 0, 0);
return mCenterRect;
}
示例9: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
public final boolean onSingleTapConfirmed(MotionEvent e) {
ImageView imageView = getImageView();
if (null != imageView) {
if (null != mPhotoTapListener) {
final RectF displayRect = getDisplayRect();
if (null != displayRect) {
final float x = e.getX(), y = e.getY();
// Check to see if the user tapped on the photo
if (displayRect.contains(x, y)) {
float xResult = (x - displayRect.left) / displayRect.width();
float yResult = (y - displayRect.top) / displayRect.height();
mPhotoTapListener.onPhotoTap(imageView, xResult, yResult);
return true;
}
}
}
if (null != mViewTapListener) {
mViewTapListener.onViewTap(imageView, e.getX(), e.getY());
}
}
return false;
}
示例10: checkBorderAndCenterWhenScale
import android.graphics.RectF; //导入方法依赖的package包/类
/**
* 在缩放时,进行图片显示范围的控制
*/
private void checkBorderAndCenterWhenScale() {
RectF rect = getMatrixRectF();
float deltaX = 0;
float deltaY = 0;
int width = getWidth();
int height = getHeight();
// 如果宽或高大于屏幕,则控制范围
if (rect.width() >= width) {
if (rect.left > 0) {
deltaX = -rect.left;
}
if (rect.right < width) {
deltaX = width - rect.right;
}
}
if (rect.height() >= height) {
if (rect.top > 0) {
deltaY = -rect.top;
}
if (rect.bottom < height) {
deltaY = height - rect.bottom;
}
}
// 如果宽或高小于屏幕,则让其居中
if (rect.width() < width) {
deltaX = width * 0.5f - rect.right + 0.5f * rect.width();
}
if (rect.height() < height) {
deltaY = height * 0.5f - rect.bottom + 0.5f * rect.height();
}
Log.e(TAG, "deltaX = " + deltaX + " , deltaY = " + deltaY);
mScaleMatrix.postTranslate(deltaX, deltaY);
}
示例11: postScale
import android.graphics.RectF; //导入方法依赖的package包/类
@Override
protected void postScale(float scale, float centerX, float centerY) {
if (mOverlayViews.size() > 0) {
Iterator<MyHighlightView> iterator = mOverlayViews.iterator();
Matrix oldMatrix = new Matrix(getImageViewMatrix());
super.postScale(scale, centerX, centerY);
while (iterator.hasNext()) {
MyHighlightView view = iterator.next();
if (view.isSelected() == false || view.isLock()) {
continue;
}
if (!mScaleWithContent) {
RectF cropRect = view.getCropRectF();
RectF rect1 = view.getDisplayRect(oldMatrix, view.getCropRectF());
RectF rect2 = view.getDisplayRect(getImageViewMatrix(), view.getCropRectF());
float[] mvalues = new float[9];
getImageViewMatrix().getValues(mvalues);
final float currentScale = mvalues[Matrix.MSCALE_X];
cropRect.offset((rect1.left - rect2.left) / currentScale, (rect1.top - rect2.top) / currentScale);
cropRect.right += -(rect2.width() - rect1.width()) / currentScale;
cropRect.bottom += -(rect2.height() - rect1.height()) / currentScale;
view.getMatrix().set(getImageMatrix());
view.getCropRectF().set(cropRect);
} else {
view.getMatrix().set(getImageMatrix());
}
view.invalidate();
}
} else {
super.postScale(scale, centerX, centerY);
}
}
示例12: calculateRectTranslateMatrix
import android.graphics.RectF; //导入方法依赖的package包/类
/**
* 计算两个矩形之间的变换矩阵
*
* unknownMatrix.mapRect(to, from)
* 已知from矩形和to矩形,求unknownMatrix
*
* @param from
* @param to
* @param result unknownMatrix
*/
public static void calculateRectTranslateMatrix(RectF from, RectF to, Matrix result) {
if (from == null || to == null || result == null) {
return;
}
if (from.width() == 0 || from.height() == 0) {
return;
}
result.reset();
result.postTranslate(-from.left, -from.top);
result.postScale(to.width() / from.width(), to.height() / from.height());
result.postTranslate(to.left, to.top);
}
示例13: chooseDisplayModeGetter
import android.graphics.RectF; //导入方法依赖的package包/类
private IDisplayModeGetter chooseDisplayModeGetter(RectF pic) {
final float aspectRatio = pic.width()/pic.height();
if (aspectRatio<getOverHighAspectRatioThreshold())
return highPicDisplayModeGetter;
else if (aspectRatio>getOverWideAspectRatioThreshold())
return widePicDisplayModeGetter;
else
return normalPicDisplayModeGetter;
}
示例14: getStackScale
import android.graphics.RectF; //导入方法依赖的package包/类
private float getStackScale(RectF stackRect) {
return mCurrentMode == Orientation.PORTRAIT
? stackRect.width() / mLayout.getWidth()
: stackRect.height() / mLayout.getHeightMinusBrowserControls();
}
示例15: checkMatrixBounds
import android.graphics.RectF; //导入方法依赖的package包/类
private boolean checkMatrixBounds() {
final ImageView imageView = getImageView();
if (null == imageView) {
return false;
}
final RectF rect = getDisplayRect(getDrawMatrix());
if (null == rect) {
return false;
}
final float height = rect.height(), width = rect.width();
float deltaX = 0, deltaY = 0;
final int viewHeight = getImageViewHeight(imageView);
if (height <= viewHeight) {
switch (mScaleType) {
case FIT_START:
deltaY = -rect.top;
break;
case FIT_END:
deltaY = viewHeight - height - rect.top;
break;
default:
deltaY = (viewHeight - height) / 2 - rect.top;
break;
}
} else if (rect.top > 0) {
deltaY = -rect.top;
} else if (rect.bottom < viewHeight) {
deltaY = viewHeight - rect.bottom;
}
final int viewWidth = getImageViewWidth(imageView);
if (width <= viewWidth) {
switch (mScaleType) {
case FIT_START:
deltaX = -rect.left;
break;
case FIT_END:
deltaX = viewWidth - width - rect.left;
break;
default:
deltaX = (viewWidth - width) / 2 - rect.left;
break;
}
mScrollEdge = EDGE_BOTH;
} else if (rect.left > 0) {
mScrollEdge = EDGE_LEFT;
deltaX = -rect.left;
} else if (rect.right < viewWidth) {
deltaX = viewWidth - rect.right;
mScrollEdge = EDGE_RIGHT;
} else {
mScrollEdge = EDGE_NONE;
}
// Finally actually translate the matrix
mSuppMatrix.postTranslate(deltaX, deltaY);
return true;
}