List of usage examples for android.graphics Canvas rotate
public void rotate(float degrees)
From source file:com.ruesga.timelinechart.TimelineChartView.java
private void drawEdgeEffects(Canvas c) { boolean needsInvalidate = false; if (mEdgeEffectLeft != null && !mEdgeEffectLeft.isFinished()) { final int restoreCount = c.save(); c.rotate(270); c.translate(-mGraphArea.height() - mGraphArea.top, mGraphArea.left); mEdgeEffectLeft.setSize((int) mGraphArea.height(), (int) mGraphArea.width()); needsInvalidate = mEdgeEffectLeft.draw(c); c.restoreToCount(restoreCount);/* w ww .jav a 2s. c om*/ } if (mEdgeEffectRight != null && !mEdgeEffectRight.isFinished()) { final int restoreCount = c.save(); c.rotate(90); c.translate(mGraphArea.top, -getWidth() + (getWidth() - mGraphArea.right)); mEdgeEffectRight.setSize((int) mGraphArea.height(), (int) mGraphArea.width()); needsInvalidate |= mEdgeEffectRight.draw(c); c.restoreToCount(restoreCount); } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }
From source file:com.iangclifton.auid.horizontaliconview.HorizontalIconView.java
@Override protected void onDraw(Canvas canvas) { if (mDrawables == null || mDrawables.isEmpty()) { return;/*from ww w . ja v a 2 s . com*/ } final int width = getWidth(); final int paddingBottom = getPaddingBottom(); final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); // Determine edges of visible content final int leftEdge = getScrollX(); final int rightEdge = leftEdge + width; int left = paddingLeft; int top = paddingTop; mSkippedIconCount = 0; final int iconCount = mDrawables.size(); for (int i = 0; i < iconCount; i++) { if (left + mIconSize < leftEdge) { // Icon is too far left to be seen left = left + mIconSize + mIconSpacing; mSkippedIconCount++; continue; } if (left > rightEdge) { // All remaining icons are right of the view break; } // Get a reference to the icon to be drawn final Drawable icon = mDrawables.get(i); icon.setBounds(left, top, left + mIconSize, top + mIconSize); icon.draw(canvas); // Icon was drawn, so track position final int drawnPosition = i - mSkippedIconCount; if (drawnPosition + 1 > mIconPositions.size()) { final Rect rect = icon.copyBounds(); mIconPositions.add(rect); } else { final Rect rect = mIconPositions.get(drawnPosition); icon.copyBounds(rect); } // Update left position left = left + mIconSize + mIconSpacing; } if (mEdgeEffectLeft != null) { if (!mEdgeEffectLeft.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - paddingTop - paddingBottom; canvas.rotate(270); canvas.translate(-height + paddingTop, Math.min(0, leftEdge)); mEdgeEffectLeft.setSize(height, getWidth()); if (mEdgeEffectLeft.draw(canvas)) { postInvalidateOnAnimation(); } canvas.restoreToCount(restoreCount); } if (!mEdgeEffectRight.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - paddingTop - paddingBottom; canvas.rotate(90); canvas.translate(-paddingTop, -(Math.max(mScrollRange, leftEdge) + width)); mEdgeEffectRight.setSize(height, width); if (mEdgeEffectRight.draw(canvas)) { postInvalidateOnAnimation(); } canvas.restoreToCount(restoreCount); } } }
From source file:com.hippo.widget.BothScrollView.java
@SuppressWarnings("SuspiciousNameCombination") @Override//from ww w . j a va 2 s . c o m public void draw(Canvas canvas) { super.draw(canvas); if (mEdgeGlowLeft != null) { final int scrollX = getScrollX(); final int scrollY = getScrollY(); final int width = getWidth(); final int height = getHeight(); if (!mEdgeGlowLeft.isFinished()) { final int restoreCount = canvas.save(); canvas.rotate(270); canvas.translate(-height - scrollY, Math.min(0, scrollX)); mEdgeGlowLeft.setSize(height, width); if (mEdgeGlowLeft.draw(canvas)) { ViewCompat.postInvalidateOnAnimation(this); } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowRight.isFinished()) { final int restoreCount = canvas.save(); canvas.rotate(90); canvas.translate(scrollY, -(Math.max(getHorizontalScrollRange(), scrollX) + width)); mEdgeGlowRight.setSize(height, width); if (mEdgeGlowRight.draw(canvas)) { ViewCompat.postInvalidateOnAnimation(this); } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowTop.isFinished()) { final int restoreCount = canvas.save(); canvas.translate(scrollX, Math.min(0, scrollY)); mEdgeGlowTop.setSize(width, height); if (mEdgeGlowTop.draw(canvas)) { ViewCompat.postInvalidateOnAnimation(this); } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowBottom.isFinished()) { final int restoreCount = canvas.save(); canvas.translate(-width + scrollX, Math.max(getVerticalScrollRange(), scrollY) + height); canvas.rotate(180, width, 0); mEdgeGlowBottom.setSize(width, height); if (mEdgeGlowBottom.draw(canvas)) { ViewCompat.postInvalidateOnAnimation(this); } canvas.restoreToCount(restoreCount); } } }
From source file:com.chenglong.muscle.ui.LazyViewPager.java
@Override public void draw(Canvas canvas) { super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mLeftEdge.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(270); canvas.translate(-height + getPaddingTop(), 0); mLeftEdge.setSize(height, getWidth()); needsInvalidate |= mLeftEdge.draw(canvas); canvas.restoreToCount(restoreCount); }//w ww .j a v a 2 s.com if (!mRightEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(90); canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin); mRightEdge.setSize(height, width); needsInvalidate |= mRightEdge.draw(canvas); canvas.restoreToCount(restoreCount); } } else { mLeftEdge.finish(); mRightEdge.finish(); } if (needsInvalidate) { // Keep animating invalidate(); } }
From source file:de.andacaydin.bidirectionalviewpagerlibrary.BiDirectionalViewPager.java
@Override public void draw(Canvas canvas) { super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mLeftEdge.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); final int width = getWidth(); canvas.rotate(270); canvas.translate(-height + getPaddingTop(), mFirstOffset * width); mLeftEdge.setSize(height, width); needsInvalidate |= mLeftEdge.draw(canvas); canvas.restoreToCount(restoreCount); }/* w w w. j a va 2 s .c om*/ if (!mRightEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(90); canvas.translate(-getPaddingTop(), -(mLastOffset + 1) * width); mRightEdge.setSize(height, width); needsInvalidate |= mRightEdge.draw(canvas); canvas.restoreToCount(restoreCount); } } else { mLeftEdge.finish(); mRightEdge.finish(); } if (needsInvalidate) { // Keep animating ViewCompat.postInvalidateOnAnimation(this); } }
From source file:org.immopoly.android.widget.ViewPager.java
@Override public void draw(Canvas canvas) { super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mLeftEdge.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(270); canvas.translate(-height + getPaddingTop(), 0); mLeftEdge.setSize(height, getWidth()); needsInvalidate |= mLeftEdge.draw(canvas); canvas.restoreToCount(restoreCount); }/* ww w . j a va 2 s .co m*/ if (!mRightEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = forcedChildWidth > 0 ? forcedChildWidth : getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(90); canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin); mRightEdge.setSize(height, width); needsInvalidate |= mRightEdge.draw(canvas); canvas.restoreToCount(restoreCount); } } else { mLeftEdge.finish(); mRightEdge.finish(); } if (needsInvalidate) { // Keep animating invalidate(); } }
From source file:beichen.douban.ui.view.LazyViewPager.java
@Override public void draw(Canvas canvas) { super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mLeftEdge.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(270); canvas.translate(-height + getPaddingTop(), 0); mLeftEdge.setSize(height, getWidth()); needsInvalidate |= mLeftEdge.draw(canvas); canvas.restoreToCount(restoreCount); }//from www . ja v a2 s . c o m if (!mRightEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(90); canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin); mRightEdge.setSize(height, width); needsInvalidate |= mRightEdge.draw(canvas); canvas.restoreToCount(restoreCount); } } else { mLeftEdge.finish(); mRightEdge.finish(); } if (needsInvalidate) { // Keep animating invalidate(); } }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
@Override public void draw(Canvas canvas) { // XXX ?//ww w. j a v a 2 s .co m super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mTopEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); canvas.rotate(270); canvas.translate(-width + getPaddingLeft(), 0); mTopEdge.setSize(width, getHeight()); needsInvalidate |= mTopEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); final int height = getHeight(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(180); canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin); mBottomEdge.setSize(width, height); needsInvalidate |= mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ } else { mTopEdge.finish(); mBottomEdge.finish(); } /* end of if */ if (needsInvalidate) { // Keep animating invalidate(); } /* end of if */ }
From source file:com.lanou.mirror.tool.VerticalViewPager.java
@Override public void draw(Canvas canvas) { // XXX //from ww w . j a va2 s .c o m super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mTopEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); canvas.rotate(270); canvas.translate(-width + getPaddingLeft(), 0); mTopEdge.setSize(width, getHeight()); needsInvalidate |= mTopEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); final int height = getHeight(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(180); canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin); mBottomEdge.setSize(width, height); needsInvalidate |= mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ } else { mTopEdge.finish(); mBottomEdge.finish(); } /* end of if */ if (needsInvalidate) { // Keep animating invalidate(); } /* end of if */ }
From source file:com.bluetoothlamp.tiny.view.verticalview.VerticalViewPager.java
@Override public void draw(Canvas canvas) { // XXX ??/*from ww w. j av a 2 s. c o m*/ super.draw(canvas); boolean needsInvalidate = false; final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { if (!mTopEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); canvas.rotate(270); canvas.translate(-width + getPaddingLeft(), 0); mTopEdge.setSize(width, getHeight()); needsInvalidate |= mTopEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); final int height = getHeight(); final int itemCount = mAdapter != null ? mAdapter.getCount() : 1; canvas.rotate(180); canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin); mBottomEdge.setSize(width, height); needsInvalidate |= mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); } /* end of if */ } else { mTopEdge.finish(); mBottomEdge.finish(); } /* end of if */ if (needsInvalidate) { // Keep animating invalidate(); } /* end of if */ }