protected internal override void onDraw(android.graphics.Canvas canvas) { base.onDraw(canvas); bool changed = mChanged; if (changed) { mChanged = false; } int availableWidth = mRight - mLeft; int availableHeight = mBottom - mTop; int x = availableWidth / 2; int y = availableHeight / 2; android.graphics.drawable.Drawable dial = mDial; int w = dial.getIntrinsicWidth(); int h = dial.getIntrinsicHeight(); bool scaled = false; if (availableWidth < w || availableHeight < h) { scaled = true; float scale = System.Math.Min((float)availableWidth / (float)w, (float)availableHeight / (float)h); canvas.save(); canvas.scale(scale, scale, x, y); } if (changed) { dial.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } dial.draw(canvas); canvas.save(); canvas.rotate(mHour / 12.0f * 360.0f, x, y); android.graphics.drawable.Drawable hourHand = mHourHand; if (changed) { w = hourHand.getIntrinsicWidth(); h = hourHand.getIntrinsicHeight(); hourHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } hourHand.draw(canvas); canvas.restore(); canvas.save(); canvas.rotate(mMinutes / 60.0f * 360.0f, x, y); android.graphics.drawable.Drawable minuteHand = mMinuteHand; if (changed) { w = minuteHand.getIntrinsicWidth(); h = minuteHand.getIntrinsicHeight(); minuteHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } minuteHand.draw(canvas); canvas.restore(); if (scaled) { canvas.restore(); } }
public override void draw(android.graphics.Canvas canvas, android.graphics.Paint paint) { canvas.save(); canvas.scale(mScaleX, mScaleY); canvas.drawPath(mPath, paint); canvas.restore(); }
public override void draw(android.graphics.Canvas canvas) { if (mPicture != null) { android.graphics.Rect bounds = getBounds(); canvas.save(); canvas.clipRect(bounds); canvas.translate(bounds.left, bounds.top); canvas.drawPicture(mPicture); canvas.restore(); } }
public virtual void draw(android.graphics.Canvas canvas) { if (mDrawable == null) { return; } canvas.save(android.graphics.Canvas.MATRIX_SAVE_FLAG); canvas.translate(mTranslationX, mTranslationY); canvas.scale(mScaleX, mScaleY); canvas.translate(-0.5f * getWidth(), -0.5f * getHeight()); mDrawable.setAlpha((int)Sharpen.Util.Round(mAlpha * 255f)); mDrawable.draw(canvas); canvas.restore(); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public void onDraw(final android.graphics.Canvas canv) public override void onDraw(Canvas canv) { if (null == mOfficeLayout || null == mRenderUtil) { Log.w(TAG, "Tried to render empty office"); return; } foreach (OfficeThing thing in mOfficeLayout.ThingsBottomUp) { Bitmap thingBitmap = mRenderUtil.getBitmap(thing); //TODO: reimplement glow rendering // // If it's the selected thing, make it GLOW! // if (thing.getKey().equals(mSelectedThingKey)) { // thingBitmap = mRenderUtil.getGlowingBitmap(thing); // } // Draw furniture canv.drawBitmap(thingBitmap, modelToScreen(thing.Left), modelToScreen(thing.Top), DEFAULT_PAINT); // Draw desk label if (thing.Type.Equals("desk") && thing.Name != null) { // TODO: these offset numbers were empirically determined. Calculate them instead float centerX = modelToScreen(thing.Left) + 102; float centerY = modelToScreen(thing.Top) + 70; canv.save(); // TODO: OMG this is so hacky. Fix it. These numbers were empirically determined if (thing.Rotation == 180) { canv.rotate(-thing.Rotation, centerX, centerY - 10); } else if (thing.Rotation == 90) { canv.rotate(-thing.Rotation, centerX, centerY + 45); } else if (thing.Rotation == 270) { canv.rotate(-thing.Rotation, centerX - 40, centerY); } canv.drawText(thing.Name, centerX, centerY, DESK_LABEL_PAINT); canv.restore(); } } }
public override void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { applyCustomTypeFace(paint, type); paint.getTextBounds(icon, 0, 1, TEXT_BOUNDS); canvas.save(); if (rotate) { float rotation = (DateTimeHelperClass.CurrentUnixTimeMillis() - rotationStartTime) / (float)ROTATION_DURATION * 360f; float centerX = x + TEXT_BOUNDS.width() / 2f; float centerY = y - TEXT_BOUNDS.height() / 2f + TEXT_BOUNDS.height() * BASELINE_RATIO; canvas.rotate(rotation, centerX, centerY); } canvas.drawText(icon, x - TEXT_BOUNDS.left, y - TEXT_BOUNDS.bottom + TEXT_BOUNDS.height() * BASELINE_RATIO, paint); canvas.restore(); }
protected internal override void onDraw(android.graphics.Canvas canvas) { lock (this) { base.onDraw(canvas); if (mThumb != null) { canvas.save(); // Translate the padding. For the x, we need to allow the thumb to // draw in its extra space canvas.translate(mPaddingLeft - mThumbOffset, mPaddingTop); mThumb.draw(canvas); canvas.restore(); } } }
/// <summary>Draw this object to the canvas using the properties defined in this class. /// </summary> /// <remarks>Draw this object to the canvas using the properties defined in this class. /// </remarks> /// <param name="canvas">canvas to draw into</param> public virtual void draw(android.graphics.Canvas canvas) { float threshold = 1.0f / 256.0f; // contribution less than 1 LSB of RGB byte if (mAlpha <= threshold) { // don't bother if it won't show up return; } canvas.save(android.graphics.Canvas.MATRIX_SAVE_FLAG); canvas.translate(mX, mY); canvas.scale(mScaleX, mScaleY); canvas.translate(-0.5f * getWidth(), -0.5f * getHeight()); mDrawable.setAlpha((int)Sharpen.Util.Round(mAlpha * 255f)); mDrawable.draw(canvas); canvas.restore(); }
protected internal override void onDraw(android.graphics.Canvas canvas) { base.onDraw(canvas); // Draw the switch int switchLeft = mSwitchLeft; int switchTop = mSwitchTop; int switchRight = mSwitchRight; int switchBottom = mSwitchBottom; mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); mTrackDrawable.draw(canvas); canvas.save(); mTrackDrawable.getPadding(mTempRect); int switchInnerLeft = switchLeft + mTempRect.left; int switchInnerTop = switchTop + mTempRect.top; int switchInnerRight = switchRight - mTempRect.right; int switchInnerBottom = switchBottom - mTempRect.bottom; canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom); mThumbDrawable.getPadding(mTempRect); int thumbPos = (int)(mThumbPosition + 0.5f); int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right; mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); mThumbDrawable.draw(canvas); // mTextColors should not be null, but just in case if (mTextColors != null) { mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors. getDefaultColor())); } mTextPaint.drawableState = getDrawableState(); android.text.Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout; canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2); switchText.draw(canvas); canvas.restore(); }
public override void draw(android.graphics.Canvas canvas) { if (mClipState.mDrawable.getLevel() == 0) { return; } android.graphics.Rect r = mTmpRect; android.graphics.Rect bounds = getBounds(); int level = getLevel(); int w = bounds.width(); int iw = 0; //mClipState.mDrawable.getIntrinsicWidth(); if ((mClipState.mOrientation & HORIZONTAL) != 0) { w -= (w - iw) * (10000 - level) / 10000; } int h = bounds.height(); int ih = 0; //mClipState.mDrawable.getIntrinsicHeight(); if ((mClipState.mOrientation & VERTICAL) != 0) { h -= (h - ih) * (10000 - level) / 10000; } int layoutDirection = getResolvedLayoutDirectionSelf(); android.view.Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection); if (w > 0 && h > 0) { canvas.save(); canvas.clipRect(r); mClipState.mDrawable.draw(canvas); canvas.restore(); } }