本文整理汇总了Java中android.graphics.Rect.exactCenterY方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.exactCenterY方法的具体用法?Java Rect.exactCenterY怎么用?Java Rect.exactCenterY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Rect
的用法示例。
在下文中一共展示了Rect.exactCenterY方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawTriangle
import android.graphics.Rect; //导入方法依赖的package包/类
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
if (this.mShowArrow) {
if (this.mArrow == null) {
this.mArrow = new Path();
this.mArrow.setFillType(FillType.EVEN_ODD);
} else {
this.mArrow.reset();
}
float inset = ((float) (((int) this.mStrokeInset) / 2)) * this.mArrowScale;
float x = (float) ((this.mRingCenterRadius * Math.cos(0.0d)) + ((double) bounds.exactCenterX()));
float y = (float) ((this.mRingCenterRadius * Math.sin(0.0d)) + ((double) bounds.exactCenterY()));
this.mArrow.moveTo(0.0f, 0.0f);
this.mArrow.lineTo(((float) this.mArrowWidth) * this.mArrowScale, 0.0f);
this.mArrow.lineTo((((float) this.mArrowWidth) * this.mArrowScale) / 2.0f, ((float) this.mArrowHeight) * this.mArrowScale);
this.mArrow.offset(x - inset, y);
this.mArrow.close();
this.mArrowPaint.setColor(this.mCurrentColor);
c.rotate((startAngle + sweepAngle) - 5.0f, bounds.exactCenterX(), bounds.exactCenterY());
c.drawPath(this.mArrow, this.mArrowPaint);
}
}
示例2: revealPopupWindow
import android.graphics.Rect; //导入方法依赖的package包/类
@UiThread public static void revealPopupWindow(@NonNull PopupWindow popupWindow, @NonNull View from) {
Rect rect = ViewHelper.getLayoutPosition(from);
int x = (int) rect.exactCenterX();
int y = (int) rect.exactCenterY();
if (popupWindow.getContentView() != null) {
View view = popupWindow.getContentView();
if (view != null) {
popupWindow.showAsDropDown(from);
view.post(() -> {
if (ViewCompat.isAttachedToWindow(view)) {
Animator animator = ViewAnimationUtils.createCircularReveal(view, x, y, 0,
(float) Math.hypot(rect.width(), rect.height()));
animator.setDuration(view.getResources().getInteger(android.R.integer.config_shortAnimTime));
animator.start();
}
});
}
}
}
示例3: positionSelectorLikeFocusCompat
import android.graphics.Rect; //导入方法依赖的package包/类
protected void positionSelectorLikeFocusCompat(int position, View sel) {
boolean manageState;
boolean z = true;
Drawable selector = getSelector();
if (selector == null || position == -1) {
manageState = false;
} else {
manageState = true;
}
if (manageState) {
selector.setVisible(false, false);
}
positionSelectorCompat(position, sel);
if (manageState) {
Rect bounds = this.mSelectorRect;
float x = bounds.exactCenterX();
float y = bounds.exactCenterY();
if (getVisibility() != 0) {
z = false;
}
selector.setVisible(z, false);
DrawableCompat.setHotspot(selector, x, y);
}
}
示例4: drawTriangle
import android.graphics.Rect; //导入方法依赖的package包/类
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
if (mShowArrow) {
if (mArrow == null) {
mArrow = new android.graphics.Path();
mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD);
} else {
mArrow.reset();
}
// Adjust the position of the triangle so that it is inset as
// much as the arc, but also centered on the arc.
float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());
// Update the path each time. This works around an issue in SKIA
// where concatenating a rotation matrix to a scale matrix
// ignored a starting negative rotation. This appears to have
// been fixed as of API 21.
mArrow.moveTo(0, 0);
mArrow.lineTo((mArrowWidth) * mArrowScale, 0);
mArrow.lineTo(((mArrowWidth) * mArrowScale / 2), (mArrowHeight
* mArrowScale));
mArrow.offset(x-((mArrowWidth) * mArrowScale / 2), y);
mArrow.close();
// draw a triangle
mArrowPaint.setColor(mColors[mColorIndex]);
//when sweepAngle < 0 adjust the position of the arrow
c.rotate(startAngle + (sweepAngle<0?0:sweepAngle) - ARROW_OFFSET_ANGLE, bounds.exactCenterX(),
bounds.exactCenterY());
c.drawPath(mArrow, mArrowPaint);
}
}
示例5: drawTriangle
import android.graphics.Rect; //导入方法依赖的package包/类
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
if (mShowArrow) {
if (mArrow == null) {
mArrow = new android.graphics.Path();
mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD);
} else {
mArrow.reset();
}
// Adjust the position of the triangle so that it is inset as
// much as the arc, but also centered on the arc.
float inset = (int) mStrokeInset / 2 * mArrowScale;
float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());
// Update the path each time. This works around an issue in SKIA
// where concatenating a rotation matrix to a scale matrix
// ignored a starting negative rotation. This appears to have
// been fixed as of API 21.
mArrow.moveTo(0, 0);
mArrow.lineTo(mArrowWidth * mArrowScale, 0);
mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight
* mArrowScale));
mArrow.offset(x - inset, y);
mArrow.close();
// draw a triangle
mArrowPaint.setColor(mCurrentColor);
c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(),
bounds.exactCenterY());
c.drawPath(mArrow, mArrowPaint);
}
}
示例6: resize
import android.graphics.Rect; //导入方法依赖的package包/类
public static Rect resize(Rect rect, float mul){
float x = rect.exactCenterX();
float y = rect.exactCenterY();
float toBT = Math.abs(rect.exactCenterY()-rect.bottom)*mul;
float toLR = Math.abs(rect.exactCenterX()-rect.left)*mul;
Rect resized = new Rect(
Math.round(x-toLR),
Math.round(y-toBT),
Math.round( x+toLR),
Math.round(y+toBT)
);
return resized;
}
示例7: drawTriangle
import android.graphics.Rect; //导入方法依赖的package包/类
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
if (mShowArrow) {
if (mArrow == null) {
mArrow = new android.graphics.Path();
mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD);
} else {
mArrow.reset();
}
// Adjust the position of the triangle so that it is inset as
// much as the arc, but also centered on the arc.
float inset = (int) mStrokeInset / 2 * mArrowScale;
float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());
// Update the path each time. This works around an issue in SKIA
// where concatenating a rotation matrix to a scale matrix
// ignored a starting negative rotation. This appears to have
// been fixed as of API 21.
mArrow.moveTo(0, 0);
mArrow.lineTo(mArrowWidth * mArrowScale, 0);
mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight
* mArrowScale));
mArrow.offset(x - inset, y);
mArrow.close();
// draw a triangle
mArrowPaint.setColor(mColors[mColorIndex]);
c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(),
bounds.exactCenterY());
c.drawPath(mArrow, mArrowPaint);
}
}
示例8: draw
import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public void draw(@NonNull Canvas canvas) {
Rect bounds = getBounds();
float cx = bounds.exactCenterX();
float cy = bounds.exactCenterY();
canvas.drawCircle(cx, cy, Math.min(cx, cy), mPaint);
}
示例9: drawTriangle
import android.graphics.Rect; //导入方法依赖的package包/类
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
if (mShowArrow) {
if (mArrow == null) {
mArrow = new android.graphics.Path();
mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD);
} else {
mArrow.reset();
}
// Adjust the position of the triangle so that it is inset as
// much as the arc, but also centered on the arc.
float inset = (int) mStrokeInset / 2 * mArrowScale;
float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());
// Update the path each time. This works around an issue in SKIA
// where concatenating a rotation matrix to a scale matrix
// ignored a starting negative rotation. This appears to have
// been fixed as of API 21.
mArrow.moveTo(0, 0);
mArrow.lineTo(mArrowWidth * mArrowScale, 0);
mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight
* mArrowScale));
mArrow.offset(x - inset, y);
mArrow.close();
// draw a triangle
mArrowPaint.setColor(mCurrentColor);
//将alpha设置到画笔中
mArrowPaint.setAlpha(mAlpha);
c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(),
bounds.exactCenterY());
c.drawPath(mArrow, mArrowPaint);
}
}
示例10: getCenterClickedView
import android.graphics.Rect; //导入方法依赖的package包/类
private int[] getCenterClickedView(ViewGroup from) {
Rect clickedViewRect = new Rect();
clickedView.getDrawingRect(clickedViewRect);
from.offsetDescendantRectToMyCoords(clickedView, clickedViewRect);
return new int[] {(int) clickedViewRect.exactCenterX(), (int) clickedViewRect.exactCenterY()};
}