当前位置: 首页>>代码示例>>Java>>正文


Java Rect.centerY方法代码示例

本文整理汇总了Java中android.graphics.Rect.centerY方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.centerY方法的具体用法?Java Rect.centerY怎么用?Java Rect.centerY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Rect的用法示例。


在下文中一共展示了Rect.centerY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleAccessibleDrop

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * @param clickedTarget the actual view that was clicked
 * @param dropLocation relative to {@param clickedTarget}. If provided, its center is used
 * as the actual drop location otherwise the views center is used.
 */
public void handleAccessibleDrop(View clickedTarget, Rect dropLocation,
        String confirmation) {
    if (!isInAccessibleDrag()) return;

    int[] loc = new int[2];
    if (dropLocation == null) {
        loc[0] = clickedTarget.getWidth() / 2;
        loc[1] = clickedTarget.getHeight() / 2;
    } else {
        loc[0] = dropLocation.centerX();
        loc[1] = dropLocation.centerY();
    }

    mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc);
    mLauncher.getDragController().completeAccessibleDrag(loc);

    if (!TextUtils.isEmpty(confirmation)) {
        announceConfirmation(confirmation);
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:26,代码来源:LauncherAccessibilityDelegate.java

示例2: offsetIfNeeded

import android.graphics.Rect; //导入方法依赖的package包/类
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
    Rect padding = fab.mShadowPadding;
    if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
        LayoutParams lp = (LayoutParams) fab.getLayoutParams();
        int offsetTB = 0;
        int offsetLR = 0;
        if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
            offsetLR = padding.right;
        } else if (fab.getLeft() <= lp.leftMargin) {
            offsetLR = -padding.left;
        }
        if (fab.getBottom() >= parent.getBottom() - lp.bottomMargin) {
            offsetTB = padding.bottom;
        } else if (fab.getTop() <= lp.topMargin) {
            offsetTB = -padding.top;
        }
        fab.offsetTopAndBottom(offsetTB);
        fab.offsetLeftAndRight(offsetLR);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:FloatingActionButton.java

示例3: onBoundsChange

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);

    rimRadius = Math.min(bounds.width(), bounds.height()) / 2f - rimPaint.getStrokeWidth();
    faceRadius = rimRadius - rimPaint.getStrokeWidth();
    screwRadius = rimPaint.getStrokeWidth() * 2;
    float hourHandLength = (float) (0.5 * faceRadius);
    float minuteHandLength = (float) (0.7 * faceRadius);
    float top = bounds.centerY() - screwRadius;

    hourHandPath.reset();
    hourHandPath.moveTo(bounds.centerX(), bounds.centerY());
    hourHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - hourHandLength, Direction.CCW);
    hourHandPath.close();

    minuteHandPath.reset();
    minuteHandPath.moveTo(bounds.centerX(), bounds.centerY());
    minuteHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - minuteHandLength, Direction.CCW);
    minuteHandPath.close();
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:22,代码来源:ClockDrawable.java

示例4: findClosestRow

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Returns the row (0 indexed) closest to previouslyFocusedRect or center if null.
 */
private int findClosestRow(@Nullable Rect previouslyFocusedRect) {
    if (previouslyFocusedRect == null) {
        return 3;
    } else {
        int centerY = previouslyFocusedRect.centerY();

        final TextPaint p = mDayPaint;
        final int headerHeight = mMonthHeight + mDayOfWeekHeight;
        final int rowHeight = mDayHeight;

        // Text is vertically centered within the row height.
        final float halfLineHeight = (p.ascent() + p.descent()) / 2f;
        final int rowCenter = headerHeight + rowHeight / 2;

        centerY -= rowCenter - halfLineHeight;
        int row = Math.round(centerY / (float) rowHeight);
        final int maxDay = findDayOffset() + mDaysInMonth;
        final int maxRows = (maxDay / DAYS_IN_WEEK) - ((maxDay % DAYS_IN_WEEK == 0) ? 1 : 0);

        row = mathConstrain(row, 0, maxRows);
        return row;
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:27,代码来源:SimpleMonthView.java

示例5: scaleRectAboutCenter

import android.graphics.Rect; //导入方法依赖的package包/类
public static void scaleRectAboutCenter(Rect r, float scale) {
    if (scale != 1.0f) {
        int cx = r.centerX();
        int cy = r.centerY();
        r.offset(-cx, -cy);

        r.left = (int) (r.left * scale + 0.5f);
        r.top = (int) (r.top * scale + 0.5f);
        r.right = (int) (r.right * scale + 0.5f);
        r.bottom = (int) (r.bottom * scale + 0.5f);

        r.offset(cx, cy);
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:15,代码来源:Utilities.java

示例6: makeErrorPath

import android.graphics.Rect; //导入方法依赖的package包/类
private void makeErrorPath() {
    final Rect bounds = this.bounds;
    final int w2 = bounds.centerX();
    final int h2 = bounds.centerY();
    path1.reset();
    path1.moveTo((float) (w2 - Math.cos(Math.toRadians(45)) * getRadius()), (float) (h2 - Math.sin(Math.toRadians(45)) * getRadius()));
    path1.lineTo((float) (w2 + Math.cos(Math.toRadians(45)) * getRadius()), (float) (h2 + Math.sin(Math.toRadians(45)) * getRadius()));
    pathMeasure1.setPath(path1, false);
    mErrorPathLengthLeft = pathMeasure1.getLength();
    path1.reset();
    path1.moveTo((float) (w2 + Math.cos(Math.toRadians(45)) * getRadius()), (float) (h2 - Math.sin(Math.toRadians(45)) * getRadius()));
    path1.lineTo((float) (w2 - Math.cos(Math.toRadians(45)) * getRadius()), (float) (h2 + Math.sin(Math.toRadians(45)) * getRadius()));
    pathMeasure2.setPath(path1, false);
    mErrorPathLengthRight = pathMeasure2.getLength();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:FreshDownloadView.java

示例7: getDirectionVectorForDrop

import android.graphics.Rect; //导入方法依赖的package包/类
private void getDirectionVectorForDrop(int dragViewCenterX, int dragViewCenterY, int spanX,
        int spanY, View dragView, int[] resultDirection) {
    int[] targetDestination = new int[2];

    findNearestArea(dragViewCenterX, dragViewCenterY, spanX, spanY, targetDestination);
    Rect dragRect = new Rect();
    regionToRect(targetDestination[0], targetDestination[1], spanX, spanY, dragRect);
    dragRect.offset(dragViewCenterX - dragRect.centerX(), dragViewCenterY - dragRect.centerY());

    Rect dropRegionRect = new Rect();
    getViewsIntersectingRegion(targetDestination[0], targetDestination[1], spanX, spanY,
            dragView, dropRegionRect, mIntersectingViews);

    int dropRegionSpanX = dropRegionRect.width();
    int dropRegionSpanY = dropRegionRect.height();

    regionToRect(dropRegionRect.left, dropRegionRect.top, dropRegionRect.width(),
            dropRegionRect.height(), dropRegionRect);

    int deltaX = (dropRegionRect.centerX() - dragViewCenterX) / spanX;
    int deltaY = (dropRegionRect.centerY() - dragViewCenterY) / spanY;

    if (dropRegionSpanX == mCountX || spanX == mCountX) {
        deltaX = 0;
    }
    if (dropRegionSpanY == mCountY || spanY == mCountY) {
        deltaY = 0;
    }

    if (deltaX == 0 && deltaY == 0) {
        // No idea what to do, give a random direction.
        resultDirection[0] = 1;
        resultDirection[1] = 0;
    } else {
        computeDirectionVector(deltaX, deltaY, resultDirection);
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:38,代码来源:CellLayout.java

示例8: drawDiscreteInterval

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Draws discrete interval, its thick marks depending on the current {@link #mDiscreteIntervalRatio}
 * value.
 *
 * @param canvas Canvas on which to draw discrete interval.
 */
private void drawDiscreteInterval(Canvas canvas) {
	if (mDiscreteIntervalRatio == 0 || mProgressDrawable == null) {
		return;
	}

	final Rect trackBounds = mProgressDrawable.getBounds();
	final int trackLeft = getPaddingLeft();
	final int cy = trackBounds.centerY();
	float trackWidth = trackBounds.width();
	final float discreteInterval = mDiscreteIntervalRatio * trackWidth;
	trackWidth += DISCRETE_INTERVAL_TICK_MARK_INFO.radius;
	final Rect thumbBounds = mThumb != null ? mThumb.getBounds() : null;
	final int thumbOffset = getThumbOffset();

	float cx = 0;
	while (cx <= trackWidth) {
		// Ensure to not draw over thumb if it is not expected behaviour.
		final boolean isAtThumbPosition = thumbBounds != null &&
				trackLeft + cx >= thumbBounds.left + thumbOffset &&
				trackLeft + cx <= thumbBounds.right + thumbOffset;
		if (CAN_DRAW_DISCRETE_INTERVAL_OVER_THUMB || !isAtThumbPosition) {
			canvas.drawCircle(
					trackLeft + cx,
					cy,
					DISCRETE_INTERVAL_TICK_MARK_INFO.radius,
					DISCRETE_INTERVAL_TICK_MARK_INFO.paint
			);
		}
		cx += discreteInterval;
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:38,代码来源:SeekBarWidget.java

示例9: getDrawRect

import android.graphics.Rect; //导入方法依赖的package包/类
public Rect getDrawRect() {
    Rect original = getBounds();
    int cX = original.centerX(), cY = original.centerY();
    rect.left = cX - (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.right = cX + (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.top = cY - (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.bottom = cY + (fullSize ? bigImgSize : drawImgSize) / 2;
    return rect;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:10,代码来源:Emoji.java

示例10: PopupLayer

import android.graphics.Rect; //导入方法依赖的package包/类
public PopupLayer(Activity context, int radius) {
    super(context);
    mRadius = radius;
    mContext = context;
    Display display = context.getWindow().getWindowManager().getDefaultDisplay();
    mRectWindowRange = new Rect();
    btTempRect = new Rect();
    display.getRectSize(mRectWindowRange);
    mWindowCenterPoint = new Point(mRectWindowRange.centerX(), mRectWindowRange.centerY());
    mShadowView = new View(context);
    mShadowView.setBackgroundColor(Color.parseColor("#66000000"));
    mShadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    addView(mShadowView);
}
 
开发者ID:panshen,项目名称:PopupCircleMenu,代码行数:15,代码来源:PopupLayer.java

示例11: IntroductoryOverlay

import android.graphics.Rect; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public IntroductoryOverlay(Builder builder, AttributeSet attrs, int defStyleAttr) {
    super(builder.mContext, attrs, defStyleAttr);
    mIsSingleTime = builder.mSingleTime;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.ccl_intro_overlay, this);
    mButton = (Button) findViewById(R.id.button);
    mTitleText = (TextView) findViewById(R.id.textTitle);
    mSubtitleText = (TextView) findViewById(R.id.textSubtitle);
    TypedArray typedArray = getContext().getTheme()
            .obtainStyledAttributes(attrs, R.styleable.CCLIntroOverlay,
                    R.attr.CCLIntroOverlayStyle, R.style.CCLIntroOverlay);
    if (builder.mOverlayColor != 0) {
        mOverlayColorId = builder.mOverlayColor;
    } else {
        mOverlayColorId = typedArray
                .getColor(R.styleable.CCLIntroOverlay_ccl_IntroBackgroundColor,
                        Color.argb(0, 0, 0, 0));
    }
    mFocusRadius = builder.mRadius;
    mListener = builder.mListener;
    if (mFocusRadius == 0) {
        mFocusRadius = typedArray
                .getDimension(R.styleable.CCLIntroOverlay_ccl_IntroFocusRadius, 0);
    }
    View view = builder.mView;
    Rect rect = new Rect();
    view.getGlobalVisibleRect(rect);
    mCenterX = rect.centerX();
    mCenterY = rect.centerY();
    setFitsSystemWindows(true);
    setupHolePaint();
    setText(builder.mTitleText, builder.mSubtitleText);

    setButton(builder.mButtonText, typedArray);
    typedArray.recycle();
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:38,代码来源:IntroductoryOverlay.java

示例12: clipSquare

import android.graphics.Rect; //导入方法依赖的package包/类
public static Rect clipSquare(Rect rect) {
    int w = rect.width();
    int h = rect.height();
    int min = Math.min(w, h);
    int cx = rect.centerX();
    int cy = rect.centerY();
    int r = min / 2;
    return new Rect(
            cx - r,
            cy - r,
            cx + r,
            cy + r
    );
}
 
开发者ID:liuwei1993,项目名称:AndroidAnimationTools,代码行数:15,代码来源:ShapeUtils.java

示例13: offsetIfNeeded

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Pre-Lollipop we use padding so that the shadow has enough space to be drawn. This method
     * offsets our layout position so that we're positioned correctly if we're on one of
     * our parent's edges.
 */
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
  final Rect padding = fab.mShadowPadding;

  if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) fab.getLayoutParams();

    int offsetTB = 0, offsetLR = 0;

    if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
      // If we're on the right edge, shift it the right
      offsetLR = padding.right;
    } else if (fab.getLeft() <= lp.leftMargin) {
      // If we're on the left edge, shift it the left
      offsetLR = -padding.left;
    }
    if (fab.getBottom() >= parent.getHeight() - lp.bottomMargin) {
      // If we're on the bottom edge, shift it down
      offsetTB = padding.bottom;
    } else if (fab.getTop() <= lp.topMargin) {
      // If we're on the top edge, shift it up
      offsetTB = -padding.top;
    }

    if (offsetTB != 0) {
      ViewCompat.offsetTopAndBottom(fab, offsetTB);
    }
    if (offsetLR != 0) {
      ViewCompat.offsetLeftAndRight(fab, offsetLR);
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:38,代码来源:FloatingActionButton.java

示例14: drawDiscreteIndicator

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Draws discrete indicator of this SeekBarWidget at its current position updated by
 * {@link #updateDiscreteIndicatorPosition(int, int)} according to the current progress.
 *
 * @param canvas Canvas on which to draw discrete indicator's drawable.
 */
private void drawDiscreteIndicator(Canvas canvas) {
	if (mDiscreteIndicatorHeight == 0) {
		return;
	}
	// todo: draw according to LTR/RTL layout direction.
	mDiscreteIndicator.draw(canvas);

	// Draw current progress over indicator's graphics.
	final Rect indicatorBounds = mDiscreteIndicator.getBounds();
	final Paint textPaint = DISCRETE_INDICATOR_TEXT_INFO.paint;
	textPaint.getTextBounds("0", 0, 1, mRect);
	final float textSize = mRect.height();
	final Rect textPadding = DISCRETE_INDICATOR_TEXT_INFO.padding;
	final int absoluteTextGravity = WidgetGravity.getAbsoluteGravity(
			DISCRETE_INDICATOR_TEXT_INFO.gravity,
			ViewCompat.getLayoutDirection(this)
	);

	final float textX, textY;
	// Resolve horizontal text position according to the requested gravity.
	switch (absoluteTextGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
		case Gravity.CENTER_HORIZONTAL:
			textPaint.setTextAlign(Paint.Align.CENTER);
			textX = indicatorBounds.centerX();
			break;
		case Gravity.RIGHT:
			textPaint.setTextAlign(Paint.Align.RIGHT);
			textX = indicatorBounds.right - textPadding.right;
			break;
		case Gravity.LEFT:
		default:
			textPaint.setTextAlign(Paint.Align.LEFT);
			textX = indicatorBounds.left + textPadding.left;
			break;
	}
	// Resolve vertical text position according to the requested gravity.
	switch (absoluteTextGravity & Gravity.VERTICAL_GRAVITY_MASK) {
		case Gravity.CENTER_VERTICAL:
			textY = indicatorBounds.centerY() + textSize / 2f;
			break;
		case Gravity.BOTTOM:
			textY = indicatorBounds.bottom - textPadding.bottom;
			break;
		case Gravity.TOP:
		default:
			textY = indicatorBounds.top + textSize + textPadding.top;
			break;
	}
	canvas.drawText(Integer.toString(getProgress()), textX, textY, textPaint);
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:57,代码来源:SeekBarWidget.java

示例15: getHit

import android.graphics.Rect; //导入方法依赖的package包/类
public int getHit(float x, float y) {

        Rect r = computeLayout();
        final float hysteresis = 20F;
        int retval = GROW_NONE;

        if (mCircle) {
            float distX = x - r.centerX();
            float distY = y - r.centerY();
            int distanceFromCenter =
                    (int) Math.sqrt(distX * distX + distY * distY);
            int radius = mDrawRect.width() / 2;
            int delta = distanceFromCenter - radius;
            if (Math.abs(delta) <= hysteresis) {
                if (Math.abs(distY) > Math.abs(distX)) {
                    if (distY < 0) {
                        retval = GROW_TOP_EDGE;
                    } else {
                        retval = GROW_BOTTOM_EDGE;
                    }
                } else {
                    if (distX < 0) {
                        retval = GROW_LEFT_EDGE;
                    } else {
                        retval = GROW_RIGHT_EDGE;
                    }
                }
            } else if (distanceFromCenter < radius) {
                retval = MOVE;
            } else {
                retval = GROW_NONE;
            }
        } else {
            // verticalCheck makes sure the position is between the top and
            // the bottom edge (with some tolerance). Similar for horizCheck.
            boolean verticalCheck = (y >= r.top - hysteresis)
                    && (y < r.bottom + hysteresis);
            boolean horizCheck = (x >= r.left - hysteresis)
                    && (x < r.right + hysteresis);

            // Check whether the position is near some edge(s).
            if ((Math.abs(r.left - x) < hysteresis) && verticalCheck) {
                retval |= GROW_LEFT_EDGE;
            }
            if ((Math.abs(r.right - x) < hysteresis) && verticalCheck) {
                retval |= GROW_RIGHT_EDGE;
            }
            if ((Math.abs(r.top - y) < hysteresis) && horizCheck) {
                retval |= GROW_TOP_EDGE;
            }
            if ((Math.abs(r.bottom - y) < hysteresis) && horizCheck) {
                retval |= GROW_BOTTOM_EDGE;
            }

            // Not near any edge but inside the rectangle: move.
            if (retval == GROW_NONE && r.contains((int) x, (int) y)) {
                retval = MOVE;
            }
        }
        return retval;
    }
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:62,代码来源:HighlightView.java


注:本文中的android.graphics.Rect.centerY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。