private static int getPageHeight(android.widget.TextView widget) { // This calculation does not take into account the view transformations that // may have been applied to the child or its containers. In case of scaling or // rotation, the calculated page height may be incorrect. android.graphics.Rect rect = new android.graphics.Rect(); return widget.getGlobalVisibleRect(rect) ? rect.height() : 0; }
private Bitmap captureBitmap(I420Frame i420Frame) { YuvImage yuvImage = i420ToYuvImage(i420Frame); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Rect rect = new Rect(0, 0, yuvImage.Width, yuvImage.Height); // Compress YuvImage to jpeg yuvImage.compressToJpeg(rect, 100, stream); // Convert jpeg to Bitmap sbyte[] imageBytes = stream.toByteArray(); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.Length); Matrix matrix = new Matrix(); // Apply any needed rotation matrix.postRotate(i420Frame.rotationDegree); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true); return bitmap; }
/// <summary>Return the drawable's bounds Rect.</summary> /// <remarks> /// Return the drawable's bounds Rect. Note: for efficiency, the returned /// object may be the same object stored in the drawable (though this is not /// guaranteed), so if a persistent copy of the bounds is needed, call /// copyBounds(rect) instead. /// You should also not change the object returned by this method as it may /// be the same object stored in the drawable. /// </remarks> /// <returns> /// The bounds of the drawable (which may change later, so caller /// beware). DO NOT ALTER the returned object as it may change the /// stored bounds of this drawable. /// </returns> /// <seealso cref="copyBounds()">copyBounds()</seealso> /// <seealso cref="copyBounds(android.graphics.Rect)"></seealso> public android.graphics.Rect getBounds() { if (mBounds == ZERO_BOUNDS_RECT) { mBounds = new android.graphics.Rect(); } return mBounds; }
/// <summary> /// Returns the maximum height that is available for the popup to be /// completely shown, optionally ignoring any bottom decorations such as /// the input method. /// </summary> /// <remarks> /// Returns the maximum height that is available for the popup to be /// completely shown, optionally ignoring any bottom decorations such as /// the input method. It is recommended that this height be the maximum for /// the popup's height, otherwise it is possible that the popup will be /// clipped. /// </remarks> /// <param name="anchor">The view on which the popup window must be anchored.</param> /// <param name="yOffset">y offset from the view's bottom edge</param> /// <param name="ignoreBottomDecorations"> /// if true, the height returned will be /// all the way to the bottom of the display, ignoring any /// bottom decorations /// </param> /// <returns> /// The maximum available height for the popup to be completely /// shown. /// </returns> /// <hide>Pending API council approval.</hide> public virtual int getMaxAvailableHeight(android.view.View anchor, int yOffset, bool ignoreBottomDecorations) { android.graphics.Rect displayFrame = new android.graphics.Rect(); anchor.getWindowVisibleDisplayFrame(displayFrame); int[] anchorPos = mDrawingLocation; anchor.getLocationOnScreen(anchorPos); int bottomEdge = displayFrame.bottom; if (ignoreBottomDecorations) { android.content.res.Resources res = anchor.getContext().getResources(); bottomEdge = res.getDisplayMetrics().heightPixels; } int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset; int distanceToTop = anchorPos[1] - displayFrame.top + yOffset; // anchorPos[1] is distance from anchor to top of screen int returnedHeight = System.Math.Max(distanceToBottom, distanceToTop); if (mBackground != null) { mBackground.getPadding(mTempRect); returnedHeight -= mTempRect.top + mTempRect.bottom; } return returnedHeight; }
private void adjustDropDownSizeAndPosition() { if (mDropDownAnchor.getWidth() > 1) { android.content.res.Resources res = getContext().getResources(); int anchorPadding = mSearchPlate.getPaddingLeft(); android.graphics.Rect dropDownPadding = new android.graphics.Rect(); int iconOffset = mIconifiedByDefault ? res.getDimensionPixelSize([email protected] .dimen.dropdownitem_icon_width) + res.getDimensionPixelSize([email protected]. dimen.dropdownitem_text_padding_left) : 0; mQueryTextView.getDropDownBackground().getPadding(dropDownPadding); mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset) + anchorPadding); mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left + dropDownPadding.right + iconOffset - (anchorPadding)); } }
/// <summary>Retrieve the clip bounds.</summary> /// <remarks>Retrieve the clip bounds.</remarks> /// <returns>the clip bounds, or [0, 0, 0, 0] if the clip is empty.</returns> public android.graphics.Rect getClipBounds() { android.graphics.Rect r = new android.graphics.Rect(); getClipBounds(r); return r; }
internal NinePatchState(android.graphics.drawable.NinePatchDrawable.NinePatchState state) { mNinePatch = new android.graphics.NinePatch(state.mNinePatch); // Note we don't copy the padding because it is immutable. mPadding = state.mPadding; mDither = state.mDither; mChangingConfigurations = state.mChangingConfigurations; mTargetDensity = state.mTargetDensity; }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { base.inflate(r, parser, attrs); android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.NinePatchDrawable); int id = a.getResourceId([email protected]_src, 0); if (id == 0) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute"); } bool dither = a.getBoolean([email protected]_dither , DEFAULT_DITHER); android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory .Options(); if (dither) { options.inDither = false; } options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE; android.graphics.Rect padding = new android.graphics.Rect(); android.graphics.Bitmap bitmap = null; try { android.util.TypedValue value = new android.util.TypedValue(); java.io.InputStream @is = r.openRawResource(id, value); bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding , options); @is.close(); } catch (System.IO.IOException) { } // Ignore if (bitmap == null) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute"); } else { if (bitmap.getNinePatchChunk() == null) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid 9-patch source image"); } } setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState( new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch" ), padding, dither), r); mNinePatchState.mTargetDensity = mTargetDensity; a.recycle(); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.graphics.drawable.GradientDrawable.GradientState st = mGradientState; android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.GradientDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); int shapeType = a.getInt([email protected]_shape, RECTANGLE ); bool dither = a.getBoolean([email protected]_dither, false); if (shapeType == RING) { st.mInnerRadius = a.getDimensionPixelSize([email protected]_innerRadius , -1); if (st.mInnerRadius == -1) { st.mInnerRadiusRatio = a.getFloat([email protected]_innerRadiusRatio , 3.0f); } st.mThickness = a.getDimensionPixelSize([email protected]_thickness , -1); if (st.mThickness == -1) { st.mThicknessRatio = a.getFloat([email protected]_thicknessRatio , 9.0f); } st.mUseLevelForShape = a.getBoolean([email protected]_useLevel , true); } a.recycle(); setShape(shapeType); setDither(dither); int type; int innerDepth = parser.getDepth() + 1; int depth; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if (depth > innerDepth) { continue; } string name = parser.getName(); if (name.Equals("size")) { a = r.obtainAttributes(attrs, [email protected]); int width = a.getDimensionPixelSize([email protected]_width , -1); int height = a.getDimensionPixelSize([email protected]_height , -1); a.recycle(); setSize(width, height); } else { if (name.Equals("gradient")) { a = r.obtainAttributes(attrs, [email protected] ); int startColor = a.getColor([email protected]_startColor , 0); bool hasCenterColor = a.hasValue([email protected]_centerColor ); int centerColor = a.getColor([email protected]_centerColor , 0); int endColor = a.getColor([email protected]_endColor , 0); int gradientType = a.getInt([email protected]_type , LINEAR_GRADIENT); st.mCenterX = getFloatOrFraction(a, [email protected]_centerX , 0.5f); st.mCenterY = getFloatOrFraction(a, [email protected]_centerY , 0.5f); st.mUseLevel = a.getBoolean([email protected]_useLevel , false); st.mGradient = gradientType; if (gradientType == LINEAR_GRADIENT) { int angle = (int)a.getFloat([email protected]_angle , 0); angle %= 360; if (angle % 45 != 0) { throw new org.xmlpull.v1.XmlPullParserException(a.getPositionDescription() + "<gradient> tag requires 'angle' attribute to " + "be a multiple of 45"); } switch (angle) { case 0: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.LEFT_RIGHT; break; } case 45: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BL_TR; break; } case 90: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP; break; } case 135: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.BR_TL; break; } case 180: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.RIGHT_LEFT; break; } case 225: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TR_BL; break; } case 270: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TOP_BOTTOM; break; } case 315: { st.mOrientation = android.graphics.drawable.GradientDrawable.Orientation.TL_BR; break; } } } else { android.util.TypedValue tv = a.peekValue([email protected]_gradientRadius ); if (tv != null) { bool radiusRel = tv.type == android.util.TypedValue.TYPE_FRACTION; st.mGradientRadius = radiusRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); } else { if (gradientType == RADIAL_GRADIENT) { throw new org.xmlpull.v1.XmlPullParserException(a.getPositionDescription() + "<gradient> tag requires 'gradientRadius' " + "attribute with radial type"); } } } a.recycle(); if (hasCenterColor) { st.mColors = new int[3]; st.mColors[0] = startColor; st.mColors[1] = centerColor; st.mColors[2] = endColor; st.mPositions = new float[3]; st.mPositions[0] = 0.0f; // Since 0.5f is default value, try to take the one that isn't 0.5f st.mPositions[1] = st.mCenterX != 0.5f ? st.mCenterX : st.mCenterY; st.mPositions[2] = 1f; } else { st.mColors = new int[2]; st.mColors[0] = startColor; st.mColors[1] = endColor; } } else { if (name.Equals("solid")) { a = r.obtainAttributes(attrs, [email protected] ); int argb = a.getColor([email protected]_color, 0); a.recycle(); setColor(argb); } else { if (name.Equals("stroke")) { a = r.obtainAttributes(attrs, [email protected] ); int width = a.getDimensionPixelSize([email protected]_width , 0); int color = a.getColor([email protected]_color , 0); float dashWidth = a.getDimension([email protected]_dashWidth , 0); if (dashWidth != 0.0f) { float dashGap = a.getDimension([email protected]_dashGap , 0); setStroke(width, color, dashWidth, dashGap); } else { setStroke(width, color); } a.recycle(); } else { if (name.Equals("corners")) { a = r.obtainAttributes(attrs, [email protected]); int radius = a.getDimensionPixelSize([email protected]_radius , 0); setCornerRadius(radius); int topLeftRadius = a.getDimensionPixelSize([email protected]_topLeftRadius , radius); int topRightRadius = a.getDimensionPixelSize([email protected]_topRightRadius , radius); int bottomLeftRadius = a.getDimensionPixelSize([email protected]_bottomLeftRadius , radius); int bottomRightRadius = a.getDimensionPixelSize([email protected]_bottomRightRadius , radius); if (topLeftRadius != radius || topRightRadius != radius || bottomLeftRadius != radius || bottomRightRadius != radius) { // The corner radii are specified in clockwise order (see Path.addRoundRect()) setCornerRadii(new float[] { topLeftRadius, topLeftRadius, topRightRadius, topRightRadius , bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius }); } a.recycle(); } else { if (name.Equals("padding")) { a = r.obtainAttributes(attrs, [email protected] ); mPadding = new android.graphics.Rect(a.getDimensionPixelOffset([email protected] .styleable.GradientDrawablePadding_left, 0), a.getDimensionPixelOffset([email protected] .styleable.GradientDrawablePadding_top, 0), a.getDimensionPixelOffset([email protected] .styleable.GradientDrawablePadding_right, 0), a.getDimensionPixelOffset([email protected] .styleable.GradientDrawablePadding_bottom, 0)); a.recycle(); mGradientState.mPadding = mPadding; } else { android.util.Log.w("drawable", "Bad element under <shape>: " + name); } } } } } } } }
/// <summary>Constructor</summary> /// <param name="bounds"> /// Bounds in local coordinates of the containing view that should be mapped to /// the delegate view /// </param> /// <param name="delegateView">The view that should receive motion events</param> public TouchDelegate(android.graphics.Rect bounds, android.view.View delegateView ) { mBounds = bounds; mSlop = android.view.ViewConfiguration.get(delegateView.getContext()).getScaledTouchSlop (); mSlopBounds = new android.graphics.Rect(bounds); mSlopBounds.inset(-mSlop, -mSlop); mDelegateView = delegateView; }
/// <summary> /// Supply a Drawable that is to be rendered on top of all of the child /// views in the frame layout. /// </summary> /// <remarks> /// Supply a Drawable that is to be rendered on top of all of the child /// views in the frame layout. Any padding in the Drawable will be taken /// into account by ensuring that the children are inset to be placed /// inside of the padding area. /// </remarks> /// <param name="drawable">The Drawable to be drawn on top of the children.</param> /// <attr>ref android.R.styleable#FrameLayout_foreground</attr> public virtual void setForeground(android.graphics.drawable.Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; mForegroundPaddingLeft = 0; mForegroundPaddingTop = 0; mForegroundPaddingRight = 0; mForegroundPaddingBottom = 0; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == android.view.Gravity.FILL) { android.graphics.Rect padding = new android.graphics.Rect(); if (drawable.getPadding(padding)) { mForegroundPaddingLeft = padding.left; mForegroundPaddingTop = padding.top; mForegroundPaddingRight = padding.right; mForegroundPaddingBottom = padding.bottom; } } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
public virtual void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & android.view.Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= android.view.Gravity.START; } if ((foregroundGravity & android.view.Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= android.view.Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == android.view.Gravity.FILL && mForeground != null) { android.graphics.Rect padding = new android.graphics.Rect(); if (mForeground.getPadding(padding)) { mForegroundPaddingLeft = padding.left; mForegroundPaddingTop = padding.top; mForegroundPaddingRight = padding.right; mForegroundPaddingBottom = padding.bottom; } } else { mForegroundPaddingLeft = 0; mForegroundPaddingTop = 0; mForegroundPaddingRight = 0; mForegroundPaddingBottom = 0; } requestLayout(); } }
public LayoutParams(StackView _enclosing, android.content.Context c, android.util.AttributeSet attrs) : base(c, attrs) { this._enclosing = _enclosing; parentRect = new android.graphics.Rect(); invalidateRect = new android.graphics.Rect(); invalidateRectf = new android.graphics.RectF(); globalInvalidateRect = new android.graphics.Rect(); this.horizontalOffset = 0; this.verticalOffset = 0; this.width = 0; this.height = 0; }
internal LayoutParams(StackView _enclosing, android.view.View view) : base(0, 0) { this._enclosing = _enclosing; parentRect = new android.graphics.Rect(); invalidateRect = new android.graphics.Rect(); invalidateRectf = new android.graphics.RectF(); globalInvalidateRect = new android.graphics.Rect(); this.width = 0; this.height = 0; this.horizontalOffset = 0; this.verticalOffset = 0; this.mView = view; }
public virtual bool onLongClick(android.view.View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; } int[] screenPos = new int[2]; android.graphics.Rect displayFrame = new android.graphics.Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); android.content.Context context = getContext(); int width = getWidth(); int height = getHeight(); int midy = screenPos[1] + height / 2; int screenWidth = context.getResources().getDisplayMetrics().widthPixels; android.widget.Toast cheatSheet = android.widget.Toast.makeText(context, mItemData .getTitle(), android.widget.Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(android.view.Gravity.TOP | android.view.Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height); } else { // Show along the bottom center cheatSheet.setGravity(android.view.Gravity.BOTTOM | android.view.Gravity.CENTER_HORIZONTAL , 0, height); } cheatSheet.show(); return true; }
internal DrawableContainerState(android.graphics.drawable.DrawableContainer.DrawableContainerState orig, android.graphics.drawable.DrawableContainer owner, android.content.res.Resources res) { mOwner = owner; if (orig != null) { mChangingConfigurations = orig.mChangingConfigurations; mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations; android.graphics.drawable.Drawable[] origDr = orig.mDrawables; mDrawables = new android.graphics.drawable.Drawable[origDr.Length]; mNumChildren = orig.mNumChildren; int N = mNumChildren; { for (int i = 0; i < N; i++) { if (res != null) { mDrawables[i] = origDr[i].getConstantState().newDrawable(res); } else { mDrawables[i] = origDr[i].getConstantState().newDrawable(); } mDrawables[i].setCallback(owner); } } mCheckedConstantState = mCanConstantState = true; mVariablePadding = orig.mVariablePadding; if (orig.mConstantPadding != null) { mConstantPadding = new android.graphics.Rect(orig.mConstantPadding); } mConstantSize = orig.mConstantSize; mComputedConstantSize = orig.mComputedConstantSize; mConstantWidth = orig.mConstantWidth; mConstantHeight = orig.mConstantHeight; mHaveOpacity = orig.mHaveOpacity; mOpacity = orig.mOpacity; mHaveStateful = orig.mHaveStateful; mStateful = orig.mStateful; mDither = orig.mDither; mEnterFadeDuration = orig.mEnterFadeDuration; mExitFadeDuration = orig.mExitFadeDuration; } else { mDrawables = new android.graphics.drawable.Drawable[10]; mNumChildren = 0; mCheckedConstantState = mCanConstantState = false; } }
/// <summary> /// Sets FaceRect parameters to be drawn. /// </summary> public virtual void setFaceRect(Face[] faces, Rect zoomRect) { mFaces = faces; mZoomRect = zoomRect; }
public int addChild(android.graphics.drawable.Drawable dr) { int pos = mNumChildren; if (pos >= mDrawables.Length) { growArray(pos, pos + 10); } dr.setVisible(false, true); dr.setCallback(mOwner); mDrawables[pos] = dr; mNumChildren++; mChildrenChangingConfigurations |= dr.getChangingConfigurations(); mHaveOpacity = false; mHaveStateful = false; mConstantPadding = null; mPaddingChecked = false; mComputedConstantSize = false; return pos; }
private void computeBitmapSize() { int sdensity = mNinePatch.getDensity(); int tdensity = mTargetDensity; if (sdensity == tdensity) { mBitmapWidth = mNinePatch.getWidth(); mBitmapHeight = mNinePatch.getHeight(); } else { mBitmapWidth = android.graphics.Bitmap.scaleFromDensity(mNinePatch.getWidth(), sdensity , tdensity); mBitmapHeight = android.graphics.Bitmap.scaleFromDensity(mNinePatch.getHeight(), sdensity, tdensity); if (mNinePatchState.mPadding != null && mPadding != null) { android.graphics.Rect dest = mPadding; android.graphics.Rect src = mNinePatchState.mPadding; if (dest == src) { mPadding = dest = new android.graphics.Rect(src); } dest.left = android.graphics.Bitmap.scaleFromDensity(src.left, sdensity, tdensity ); dest.top = android.graphics.Bitmap.scaleFromDensity(src.top, sdensity, tdensity); dest.right = android.graphics.Bitmap.scaleFromDensity(src.right, sdensity, tdensity ); dest.bottom = android.graphics.Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity ); } } }
public android.graphics.Rect getConstantPadding() { if (mVariablePadding) { return null; } if (mConstantPadding != null || mPaddingChecked) { return mConstantPadding; } android.graphics.Rect r = null; android.graphics.Rect t = new android.graphics.Rect(); int N = getChildCount(); android.graphics.drawable.Drawable[] drawables = mDrawables; { for (int i = 0; i < N; i++) { if (drawables[i].getPadding(t)) { if (r == null) { r = new android.graphics.Rect(0, 0, 0, 0); } if (t.left > r.left) { r.left = t.left; } if (t.top > r.top) { r.top = t.top; } if (t.right > r.right) { r.right = t.right; } if (t.bottom > r.bottom) { r.bottom = t.bottom; } } } } mPaddingChecked = true; return (mConstantPadding = r); }
internal NinePatchState(android.graphics.NinePatch ninePatch, android.graphics.Rect rect, bool dither) { mNinePatch = ninePatch; mPadding = rect; mDither = dither; }
public override void updateCursor(android.graphics.Rect newCursor) { throw new System.NotImplementedException(); }
internal void setNinePatchState(android.graphics.drawable.NinePatchDrawable.NinePatchState state, android.content.res.Resources res) { mNinePatchState = state; mNinePatch = state.mNinePatch; mPadding = state.mPadding; mTargetDensity = res != null ? res.getDisplayMetrics().densityDpi : state.mTargetDensity; //noinspection PointlessBooleanExpression if (state.mDither != DEFAULT_DITHER) { // avoid calling the setter unless we need to, since it does a // lazy allocation of a paint setDither(state.mDither); } if (mNinePatch != null) { computeBitmapSize(); } }
public virtual void onUpdateCursor(android.graphics.Rect newCursor) { throw new System.NotImplementedException(); }
internal ShapeState(android.graphics.drawable.ShapeDrawable.ShapeState orig) { if (orig != null) { mPaint = orig.mPaint; mShape = orig.mShape; mPadding = orig.mPadding; mIntrinsicWidth = orig.mIntrinsicWidth; mIntrinsicHeight = orig.mIntrinsicHeight; mAlpha = orig.mAlpha; mShaderFactory = orig.mShaderFactory; } else { mPaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG); } }
public virtual void onFocusChanged(android.view.View view, java.lang.CharSequence sourceText, bool focused, int direction, android.graphics.Rect previouslyFocusedRect ) { }
/// <summary><p>Positions the popup window on screen.</summary> /// <remarks> /// <p>Positions the popup window on screen. When the popup window is too /// tall to fit under the anchor, a parent scroll view is seeked and scrolled /// up to reclaim space. If scrolling is not possible or not enough, the /// popup window gets moved on top of the anchor.</p> /// <p>The height must have been set on the layout parameters prior to /// calling this method.</p> /// </remarks> /// <param name="anchor">the view on which the popup window must be anchored</param> /// <param name="p">the layout parameters used to display the drop down</param> /// <returns>true if the popup is translated upwards to fit on screen</returns> private bool findDropDownPosition(android.view.View anchor, android.view.WindowManagerClass .LayoutParams p, int xoff, int yoff) { int anchorHeight = anchor.getHeight(); anchor.getLocationInWindow(mDrawingLocation); p.x = mDrawingLocation[0] + xoff; p.y = mDrawingLocation[1] + anchorHeight + yoff; bool onTop = false; p.gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP; anchor.getLocationOnScreen(mScreenLocation); android.graphics.Rect displayFrame = new android.graphics.Rect(); anchor.getWindowVisibleDisplayFrame(displayFrame); int screenY = mScreenLocation[1] + anchorHeight + yoff; android.view.View root = anchor.getRootView(); if (screenY + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth () > 0) { // if the drop down disappears at the bottom of the screen. we try to // scroll a parent scrollview or move the drop down back up on top of // the edit box if (mAllowScrollingAnchorParent) { int scrollX = anchor.getScrollX(); int scrollY = anchor.getScrollY(); android.graphics.Rect r = new android.graphics.Rect(scrollX, scrollY, scrollX + mPopupWidth + xoff, scrollY + mPopupHeight + anchor.getHeight() + yoff); anchor.requestRectangleOnScreen(r, true); } // now we re-evaluate the space available, and decide from that // whether the pop-up will go above or below the anchor. anchor.getLocationInWindow(mDrawingLocation); p.x = mDrawingLocation[0] + xoff; p.y = mDrawingLocation[1] + anchor.getHeight() + yoff; // determine whether there is more space above or below the anchor anchor.getLocationOnScreen(mScreenLocation); onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getHeight() - yoff) < (mScreenLocation[1] - yoff - displayFrame.top); if (onTop) { p.gravity = android.view.Gravity.LEFT | android.view.Gravity.BOTTOM; p.y = root.getHeight() - mDrawingLocation[1] + yoff; } else { p.y = mDrawingLocation[1] + anchor.getHeight() + yoff; } } if (mClipToScreen) { int displayFrameWidth = displayFrame.right - displayFrame.left; int right = p.x + p.width; if (right > displayFrameWidth) { p.x -= right - displayFrameWidth; } if (p.x < displayFrame.left) { p.x = displayFrame.left; p.width = System.Math.Min(p.width, displayFrameWidth); } if (onTop) { int popupTop = mScreenLocation[1] + yoff - mPopupHeight; if (popupTop < 0) { p.y += popupTop; } } else { p.y = System.Math.Max(p.y, displayFrame.top); } } p.gravity |= android.view.Gravity.DISPLAY_CLIP_VERTICAL; return onTop; }
public virtual void clearRect() { mPaint = new Paint(); mPaint.Color = Color.BLUE; mPaint.Style = Paint.Style.STROKE; mPaint.StrokeWidth = 3; mRect = new Rect(); mOffset = new Point(); mGravity = GRAVITY_START; }
/// <summary>Specify a bounding rectangle for the Drawable.</summary> /// <remarks> /// Specify a bounding rectangle for the Drawable. This is where the drawable /// will draw when its draw() method is called. /// </remarks> public virtual void setBounds(int left, int top, int right, int bottom) { android.graphics.Rect oldBounds = mBounds; if (oldBounds == ZERO_BOUNDS_RECT) { oldBounds = mBounds = new android.graphics.Rect(); } if (oldBounds.left != left || oldBounds.top != top || oldBounds.right != right || oldBounds.bottom != bottom) { mBounds.set(left, top, right, bottom); onBoundsChange(mBounds); } }
void android.text.method.TransformationMethod.onFocusChanged(android.view.View arg0, java.lang.CharSequence arg1, bool arg2, int arg3, android.graphics.Rect arg4) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.text.method.TransformationMethod_._onFocusChanged8198, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.method.TransformationMethod_.staticClass, global::android.text.method.TransformationMethod_._onFocusChanged8198, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4)); } }
/// <summary> /// Create a drawable from an inputstream, using the given resources and /// value to determine density information. /// </summary> /// <remarks> /// Create a drawable from an inputstream, using the given resources and /// value to determine density information. /// </remarks> public static android.graphics.drawable.Drawable createFromResourceStream(android.content.res.Resources res, android.util.TypedValue value, java.io.InputStream @is, string srcName, android.graphics.BitmapFactory .Options opts) { if (@is == null) { return null; } android.graphics.Rect pad = new android.graphics.Rect(); // Special stuff for compatibility mode: if the target density is not // the same as the display density, but the resource -is- the same as // the display density, then don't scale it down to the target density. // This allows us to load the system's density-correct resources into // an application in compatibility mode, without scaling those down // to the compatibility density only to have them scaled back up when // drawn to the screen. if (opts == null) { opts = new android.graphics.BitmapFactory.Options(); } opts.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE; android.graphics.Bitmap bm = android.graphics.BitmapFactory.decodeResourceStream( res, value, @is, pad, opts); if (bm != null) { byte[] np = bm.getNinePatchChunk(); if (np == null || !android.graphics.NinePatch.isNinePatchChunk(np)) { np = null; pad = null; } return drawableFromBitmap(res, bm, np, pad, srcName); } return null; }
public virtual void draw(android.graphics.Canvas canvas) { if (mState == STATE_NONE) { // No need to draw anything return; } int y = mThumbY; int viewWidth = mList.getWidth(); android.widget.FastScroller.ScrollFade scrollFade = mScrollFade; int alpha = -1; if (mState == STATE_EXIT) { alpha = scrollFade.getAlpha(); if (alpha < android.widget.FastScroller.ScrollFade.ALPHA_MAX / 2) { mThumbDrawable.setAlpha(alpha * 2); } int left = 0; switch (mPosition) { case android.view.View.SCROLLBAR_POSITION_DEFAULT: case android.view.View.SCROLLBAR_POSITION_RIGHT: { left = viewWidth - (mThumbW * alpha) / android.widget.FastScroller.ScrollFade.ALPHA_MAX; break; } case android.view.View.SCROLLBAR_POSITION_LEFT: { left = -mThumbW + (mThumbW * alpha) / android.widget.FastScroller.ScrollFade.ALPHA_MAX; break; } } mThumbDrawable.setBounds(left, 0, left + mThumbW, mThumbH); mChangedBounds = true; } if (mTrackDrawable != null) { android.graphics.Rect thumbBounds = mThumbDrawable.getBounds(); int left = thumbBounds.left; int halfThumbHeight = (thumbBounds.bottom - thumbBounds.top) / 2; int trackWidth = mTrackDrawable.getIntrinsicWidth(); int trackLeft = (left + mThumbW / 2) - trackWidth / 2; mTrackDrawable.setBounds(trackLeft, halfThumbHeight, trackLeft + trackWidth, mList .getHeight() - halfThumbHeight); mTrackDrawable.draw(canvas); } canvas.translate(0, y); mThumbDrawable.draw(canvas); canvas.translate(0, -y); // If user is dragging the scroll bar, draw the alphabet overlay if (mState == STATE_DRAGGING && mDrawOverlay) { if (mOverlayPosition == OVERLAY_AT_THUMB) { int left = 0; switch (mPosition) { case android.view.View.SCROLLBAR_POSITION_DEFAULT: case android.view.View.SCROLLBAR_POSITION_RIGHT: default: { left = System.Math.Max(0, mThumbDrawable.getBounds().left - mThumbW - mOverlaySize ); break; } case android.view.View.SCROLLBAR_POSITION_LEFT: { left = System.Math.Min(mThumbDrawable.getBounds().right + mThumbW, mList.getWidth () - mOverlaySize); break; } } int top = System.Math.Max(0, System.Math.Min(y + (mThumbH - mOverlaySize) / 2, mList .getHeight() - mOverlaySize)); android.graphics.RectF pos = mOverlayPos; pos.left = left; pos.right = pos.left + mOverlaySize; pos.top = top; pos.bottom = pos.top + mOverlaySize; if (mOverlayDrawable != null) { mOverlayDrawable.setBounds((int)pos.left, (int)pos.top, (int)pos.right, (int)pos. bottom); } } mOverlayDrawable.draw(canvas); android.graphics.Paint paint = mPaint; float descent = paint.descent(); android.graphics.RectF rectF = mOverlayPos; android.graphics.Rect tmpRect = mTmpRect; mOverlayDrawable.getPadding(tmpRect); int hOff = (tmpRect.right - tmpRect.left) / 2; int vOff = (tmpRect.bottom - tmpRect.top) / 2; canvas.drawText(mSectionText, (int)(rectF.left + rectF.right) / 2 - hOff, (int)(rectF .bottom + rectF.top) / 2 + mOverlaySize / 4 - descent - vOff, paint); } else { if (mState == STATE_EXIT) { if (alpha == 0) { // Done with exit setState(STATE_NONE); } else { if (mTrackDrawable != null) { mList.invalidate(viewWidth - mThumbW, 0, viewWidth, mList.getHeight()); } else { mList.invalidate(viewWidth - mThumbW, y, viewWidth, y + mThumbH); } } } } }
/// <summary>Return a new Rect set to the bounds of the region.</summary> /// <remarks> /// Return a new Rect set to the bounds of the region. If the region is /// empty, the Rect will be set to [0, 0, 0, 0] /// </remarks> public virtual android.graphics.Rect getBounds() { android.graphics.Rect r = new android.graphics.Rect(); nativeGetBounds(mNativeRegion, r); return r; }
public override void drawPicture(android.graphics.Picture picture, android.graphics.Rect dst) { throw new System.NotImplementedException(); }
/// <summary> /// Returns an immutable bitmap from subset of the source bitmap, /// transformed by the optional matrix. /// </summary> /// <remarks> /// Returns an immutable bitmap from subset of the source bitmap, /// transformed by the optional matrix. It is /// initialized with the same density as the original bitmap. /// </remarks> /// <param name="source">The bitmap we are subsetting</param> /// <param name="x">The x coordinate of the first pixel in source</param> /// <param name="y">The y coordinate of the first pixel in source</param> /// <param name="width">The number of pixels in each row</param> /// <param name="height">The number of rows</param> /// <param name="m">Optional matrix to be applied to the pixels</param> /// <param name="filter"> /// true if the source should be filtered. /// Only applies if the matrix contains more than just /// translation. /// </param> /// <returns>A bitmap that represents the specified subset of source</returns> /// <exception cref="System.ArgumentException"> /// if the x, y, width, height values are /// outside of the dimensions of the source bitmap. /// </exception> public static android.graphics.Bitmap createBitmap(android.graphics.Bitmap source , int x, int y, int width, int height, android.graphics.Matrix m, bool filter) { checkXYSign(x, y); checkWidthHeight(width, height); if (x + width > source.getWidth()) { throw new System.ArgumentException("x + width must be <= bitmap.width()"); } if (y + height > source.getHeight()) { throw new System.ArgumentException("y + height must be <= bitmap.height()"); } // check if we can just return our argument unchanged if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() && height == source.getHeight() && (m == null || m.isIdentity())) { return source; } int neww = width; int newh = height; android.graphics.Canvas canvas = new android.graphics.Canvas(); android.graphics.Bitmap bitmap; android.graphics.Paint paint; android.graphics.Rect srcR = new android.graphics.Rect(x, y, x + width, y + height ); android.graphics.RectF dstR = new android.graphics.RectF(0, 0, width, height); android.graphics.Bitmap.Config newConfig = android.graphics.Bitmap.Config.ARGB_8888; android.graphics.Bitmap.Config config = source.getConfig(); // GIF files generate null configs, assume ARGB_8888 if (config != null) { switch (config) { case android.graphics.Bitmap.Config.RGB_565: { newConfig = android.graphics.Bitmap.Config.RGB_565; break; } case android.graphics.Bitmap.Config.ALPHA_8: { newConfig = android.graphics.Bitmap.Config.ALPHA_8; break; } case android.graphics.Bitmap.Config.ARGB_4444: case android.graphics.Bitmap.Config.ARGB_8888: default: { //noinspection deprecation newConfig = android.graphics.Bitmap.Config.ARGB_8888; break; } } } if (m == null || m.isIdentity()) { bitmap = createBitmap(neww, newh, newConfig, source.hasAlpha()); paint = null; } else { // not needed bool transformed = !m.rectStaysRect(); android.graphics.RectF deviceR = new android.graphics.RectF(); m.mapRect(deviceR, dstR); neww = Sharpen.Util.Round(deviceR.width()); newh = Sharpen.Util.Round(deviceR.height()); bitmap = createBitmap(neww, newh, transformed ? android.graphics.Bitmap.Config.ARGB_8888 : newConfig, transformed || source.hasAlpha()); canvas.translate(-deviceR.left, -deviceR.top); canvas.concat(m); paint = new android.graphics.Paint(); paint.setFilterBitmap(filter); if (transformed) { paint.setAntiAlias(true); } } // The new bitmap was created from a known bitmap source so assume that // they use the same density bitmap.mDensity = source.mDensity; canvas.setBitmap(bitmap); canvas.drawBitmap(source, srcR, dstR, paint); canvas.setBitmap(null); return bitmap; }
internal void initializeWithState(android.graphics.drawable.GradientDrawable.GradientState state) { if (state.mHasSolidColor) { mFillPaint.setColor(state.mSolidColor); } mPadding = state.mPadding; if (state.mStrokeWidth >= 0) { mStrokePaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG); mStrokePaint.setStyle(android.graphics.Paint.Style.STROKE); mStrokePaint.setStrokeWidth(state.mStrokeWidth); mStrokePaint.setColor(state.mStrokeColor); if (state.mStrokeDashWidth != 0.0f) { android.graphics.DashPathEffect e = new android.graphics.DashPathEffect(new float [] { state.mStrokeDashWidth, state.mStrokeDashGap }, 0); mStrokePaint.setPathEffect(e); } } }