Esempio n. 1
3
File: n.java Progetto: KilFer/miband
 protected final void draw(Canvas paramCanvas, RectF paramRectF, float paramFloat) {
   paramCanvas.save();
   RectF localRectF = new RectF(paramRectF);
   paramRectF.right -= this.mPaddingRight;
   paramCanvas.clipRect(localRectF);
   Rect localRect = new Rect();
   while (true) {
     synchronized (StatisticChartOld.a(this.b)) {
       Iterator localIterator = StatisticChartOld.a(this.b).iterator();
       if (!localIterator.hasNext()) {
         paramCanvas.restore();
         return;
       }
       StatisticChartOld.DateItem localDateItem =
           (StatisticChartOld.DateItem) localIterator.next();
       if ((localDateItem.a > 1 + this.offset) || (localDateItem.a < -8 + this.offset)) continue;
       float f1 =
           paramRectF.right
               - this.mPaddingRight
               + (-1 + localDateItem.a) * StatisticChartOld.a()
               + this.mScroll;
       float f2 = paramRectF.top;
       if (f1 <= this.mRect.right - this.mPaddingRight - 2.0F * StatisticChartOld.a()) {
         this.a.setTextSize(8.0F * this.mDensity);
         this.a.getTextBounds(localDateItem.b, 0, localDateItem.b.length(), localRect);
         float f3 = f1 + (StatisticChartOld.a() - localRect.width()) / 2.0F;
         float f4 = f2 + (this.stroke + localRect.height()) / 2.0F;
         paramCanvas.drawText(localDateItem.b, f3, f4, this.a);
       }
     }
     this.a.setTextSize(10.0F * this.mDensity);
   }
 }
  @Override
  public void onChildDrawOver(
      Canvas c,
      RecyclerView recyclerView,
      RecyclerView.ViewHolder viewHolder,
      float dX,
      float dY,
      int actionState,
      boolean isCurrentlyActive) {
    super.onChildDrawOver(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);

    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
      View itemView = viewHolder.itemView;

      c.save();
      if (dX > 0) {
        c.clipRect(
            itemView.getLeft(), itemView.getTop(), itemView.getLeft() + dX, itemView.getBottom());
        c.translate(itemView.getLeft(), itemView.getTop());
      } else {
        c.clipRect(
            itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom());
        c.translate(itemView.getRight() + dX, itemView.getTop());
      }

      mAdapter.onItemSwiping(c, viewHolder, dX, dY, isCurrentlyActive);
      c.restore();
    }
  }
Esempio n. 3
0
  @Override
  protected void onTileReadyToDraw(
      final Canvas c, final Drawable currentMapTile, final Rect tileRect) {

    // Get the offsets for where to draw the tiles relative to where the minimap is located
    final int xOffset = (tileRect.left - mTileArea.left) + (mMiniMapCanvasRect.left);
    final int yOffset = (tileRect.top - mTileArea.top) + (mMiniMapCanvasRect.top);

    // Set the drawable's location
    currentMapTile.setBounds(
        xOffset, yOffset, xOffset + tileRect.width(), yOffset + tileRect.height());

    // Save the current clipping bounds
    final Rect oldClip = c.getClipBounds();

    // Check to see if the drawing area intersects with the minimap area
    if (mIntersectionRect.setIntersect(oldClip, mMiniMapCanvasRect)) {
      // If so, then clip that area
      c.clipRect(mIntersectionRect);

      // Draw the tile, which will be appropriately clipped
      currentMapTile.draw(c);

      // Restore the original clipping bounds
      c.clipRect(oldClip);
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    int save;

    if (!mPathValid) {
      generatePath();
    }

    final float primaryLeftPoint = mHoriz.convertToPoint(mPrimaryLeft);
    final float primaryRightPoint = mHoriz.convertToPoint(mPrimaryRight);

    if (mEstimateVisible) {
      save = canvas.save();
      canvas.clipRect(0, 0, getWidth(), getHeight());
      canvas.drawPath(mPathEstimate, mPaintEstimate);
      canvas.restoreToCount(save);
    }

    save = canvas.save();
    canvas.clipRect(0, 0, primaryLeftPoint, getHeight());
    canvas.drawPath(mPathFill, mPaintFillSecondary);
    canvas.restoreToCount(save);

    save = canvas.save();
    canvas.clipRect(primaryRightPoint, 0, getWidth(), getHeight());
    canvas.drawPath(mPathFill, mPaintFillSecondary);
    canvas.restoreToCount(save);

    save = canvas.save();
    canvas.clipRect(primaryLeftPoint, 0, primaryRightPoint, getHeight());
    canvas.drawPath(mPathFill, mPaintFill);
    canvas.drawPath(mPathStroke, mPaintStroke);
    canvas.restoreToCount(save);
  }
Esempio n. 5
0
 /** 绘制焦点框 */
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (Style.RECTANGLE == mStyle) {
     mFocusPath.addRect(mFocusRect, Path.Direction.CCW);
     canvas.save();
     canvas.clipRect(0, 0, getWidth(), getHeight());
     canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
     canvas.drawColor(mMaskColor);
     canvas.restore();
   } else if (Style.CIRCLE == mStyle) {
     float radius =
         Math.min(
             (mFocusRect.right - mFocusRect.left) / 2, (mFocusRect.bottom - mFocusRect.top) / 2);
     mFocusPath.addCircle(mFocusMidPoint.x, mFocusMidPoint.y, radius, Path.Direction.CCW);
     canvas.save();
     canvas.clipRect(0, 0, getWidth(), getHeight());
     canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
     canvas.drawColor(mMaskColor);
     canvas.restore();
   }
   mBorderPaint.setColor(mBorderColor);
   mBorderPaint.setStyle(Paint.Style.STROKE);
   mBorderPaint.setStrokeWidth(mBorderWidth);
   mBorderPaint.setAntiAlias(true);
   canvas.drawPath(mFocusPath, mBorderPaint);
   mFocusPath.reset();
 }
Esempio n. 6
0
  private void drawFlippingHalf(Canvas canvas) {
    canvas.save();
    mCamera.save();

    final float degreesFlipped = getDegreesFlipped();

    if (degreesFlipped > 90) {
      canvas.clipRect(isFlippingVertically() ? mTopRect : mLeftRect);
      if (mIsFlippingVertically) {
        mCamera.rotateX(degreesFlipped - 180);
      } else {
        mCamera.rotateY(180 - degreesFlipped);
      }
    } else {
      canvas.clipRect(isFlippingVertically() ? mBottomRect : mRightRect);
      if (mIsFlippingVertically) {
        mCamera.rotateX(degreesFlipped);
      } else {
        mCamera.rotateY(-degreesFlipped);
      }
    }

    mCamera.getMatrix(mMatrix);

    positionMatrix();
    canvas.concat(mMatrix);

    setDrawWithLayer(mCurrentPage.v, true);
    drawChild(canvas, mCurrentPage.v, 0);

    drawFlippingShadeShine(canvas);

    mCamera.restore();
    canvas.restore();
  }
Esempio n. 7
0
  @Override
  public void draw(Canvas canvas) {
    if (mDrawables.size() == 1) {
      mDrawables.get(0).draw(canvas);
      return;
    }
    int width = getBounds().width();
    int height = getBounds().height();

    canvas.save();
    canvas.clipRect(0, 0, width, height);

    if (mDrawables.size() == 2 || mDrawables.size() == 3) {
      // Paint left half
      canvas.save();
      canvas.clipRect(0, 0, width / 2, height);
      canvas.translate(-width / 4, 0);
      mDrawables.get(0).draw(canvas);
      canvas.restore();
    }
    if (mDrawables.size() == 2) {
      // Paint right half
      canvas.save();
      canvas.clipRect(width / 2, 0, width, height);
      canvas.translate(width / 4, 0);
      mDrawables.get(1).draw(canvas);
      canvas.restore();
    } else {
      // Paint top right
      canvas.save();
      canvas.scale(.5f, .5f);
      canvas.translate(width, 0);
      mDrawables.get(1).draw(canvas);

      // Paint bottom right
      canvas.translate(0, height);
      mDrawables.get(2).draw(canvas);
      canvas.restore();
    }

    if (mDrawables.size() >= 4) {
      // Paint top left
      canvas.save();
      canvas.scale(.5f, .5f);
      mDrawables.get(0).draw(canvas);

      // Paint bottom left
      canvas.translate(0, height);
      mDrawables.get(3).draw(canvas);
      canvas.restore();
    }

    canvas.restore();
  }
Esempio n. 8
0
  @Override
  public void draw(Canvas canvas) {
    // Draw the bounding boxes
    drawBoundingBoxes(canvas);

    // Set the right values for the paint
    operatorPaint.setColor(getColor());
    operatorPaint.setTextSize(findTextSize());

    // Get our operator bounding boxes
    Rect[] operatorBounding = this.getOperatorBoundingBoxes();

    // Draws the operator
    canvas.save();
    Rect textBounding = new Rect();
    operatorPaint.getTextBounds(type.getName(), 0, type.getName().length(), textBounding);
    canvas.translate(
        (operatorBounding[0].width() - textBounding.width()) / 2,
        (operatorBounding[0].height() - textBounding.height()) / 2);
    canvas.drawText(
        type.getName(),
        operatorBounding[0].left - textBounding.left,
        operatorBounding[0].top - textBounding.top,
        operatorPaint);
    canvas.restore();

    // Use stroke style for the parentheses
    operatorPaint.setStyle(Paint.Style.STROKE);

    // Draw the left bracket
    canvas.save();
    canvas.clipRect(operatorBounding[1], Region.Op.INTERSECT);
    RectF bracket = new RectF(operatorBounding[1]);
    bracket.inset(0, -operatorPaint.getStrokeWidth());
    bracket.offset(bracket.width() / 4, 0);
    canvas.drawArc(bracket, 100.0f, 160.0f, false, operatorPaint);
    canvas.restore();

    // Draw the right bracket
    canvas.save();
    canvas.clipRect(operatorBounding[2], Region.Op.INTERSECT);
    bracket = new RectF(operatorBounding[2]);
    bracket.inset(0, -operatorPaint.getStrokeWidth());
    bracket.offset(-bracket.width() / 4, 0);
    canvas.drawArc(bracket, -80.0f, 160.0f, false, operatorPaint);
    canvas.restore();

    // Set the paint back to fill style
    operatorPaint.setStyle(Paint.Style.FILL);

    // Draw the children
    drawChildren(canvas);
  }
  private void drawScrim(Canvas canvas, View child) {
    final int baseAlpha = (mScrimColor & 0xff000000) >>> 24;
    final int alpha = (int) (baseAlpha * mScrimOpacity);
    final int color = alpha << 24 | (mScrimColor & 0xffffff);

    if ((mTrackingEdge & EDGE_LEFT) != 0) {
      canvas.clipRect(0, 0, child.getLeft(), getHeight());
    } else if ((mTrackingEdge & EDGE_RIGHT) != 0) {
      canvas.clipRect(child.getRight(), 0, getRight(), getHeight());
    } else if ((mTrackingEdge & EDGE_BOTTOM) != 0) {
      canvas.clipRect(child.getLeft(), child.getBottom(), getRight(), getHeight());
    }
    canvas.drawColor(color);
  }
  @Override
  protected void drawItems(Canvas canvas) {
    canvas.save();
    int w = getMeasuredWidth();
    int h = getMeasuredHeight();
    int iw = getItemDimension();

    // resetting intermediate bitmap and recreating canvases
    mSpinBitmap.eraseColor(0);
    Canvas c = new Canvas(mSpinBitmap);
    Canvas cSpin = new Canvas(mSpinBitmap);

    int left = (mCurrentItemIdx - mFirstItemIdx) * iw + (iw - getWidth()) / 2;
    c.translate(-left + mScrollingOffset, mItemsPadding);
    mItemsLayout.draw(c);

    mSeparatorsBitmap.eraseColor(0);
    Canvas cSeparators = new Canvas(mSeparatorsBitmap);

    if (mSelectionDivider != null) {
      // draw the top divider
      int leftOfLeftDivider = (getWidth() - iw - mSelectionDividerWidth) / 2;
      int rightOfLeftDivider = leftOfLeftDivider + mSelectionDividerWidth;
      cSeparators.save();
      // On Gingerbread setBounds() is ignored resulting in an ugly visual bug.
      cSeparators.clipRect(leftOfLeftDivider, 0, rightOfLeftDivider, h);
      mSelectionDivider.setBounds(leftOfLeftDivider, 0, rightOfLeftDivider, h);
      mSelectionDivider.draw(cSeparators);
      cSeparators.restore();

      cSeparators.save();
      // draw the bottom divider
      int leftOfRightDivider = leftOfLeftDivider + iw;
      int rightOfRightDivider = rightOfLeftDivider + iw;
      // On Gingerbread setBounds() is ignored resulting in an ugly visual bug.
      cSeparators.clipRect(leftOfRightDivider, 0, rightOfRightDivider, h);
      mSelectionDivider.setBounds(leftOfRightDivider, 0, rightOfRightDivider, h);
      mSelectionDivider.draw(cSeparators);
      cSeparators.restore();
    }

    cSpin.drawRect(0, 0, w, h, mSelectorWheelPaint);
    cSeparators.drawRect(0, 0, w, h, mSeparatorsPaint);

    canvas.drawBitmap(mSpinBitmap, 0, 0, null);
    canvas.drawBitmap(mSeparatorsBitmap, 0, 0, null);
    canvas.restore();
  }
Esempio n. 11
0
 private void drawBg(Canvas paramCanvas) {
   int i = paramCanvas.save();
   paramCanvas.clipRect(
       0, getTopMargin(), this.standardLayout.width, getTopMargin() + getThisHeight());
   paramCanvas.drawColor(-1);
   paramCanvas.restoreToCount(i);
 }
Esempio n. 12
0
  private void drawBlurBackground(Canvas canvas) {
    if (mBlurredView != null) {
      if (prepare()) {
        if (mBlurredBackgroundColor != 0) {
          mBitmapToBlur.eraseColor(mBlurredBackgroundColor);
        }
        mBlurredView.draw(mBlurringCanvas);
        blur();

        NiceTabLayout tabLayout = (NiceTabLayout) getParent();

        if (tabLayout != null) {
          final int pPaddingLeft = tabLayout.getPaddingLeft();
          final int pPaddingRight = tabLayout.getPaddingRight();

          canvas.save();

          if (tabLayout.getPaddingLeft() != 0 || tabLayout.getPaddingRight() != 0) {
            // allow drawing out of bounds
            Rect clipBounds = canvas.getClipBounds();
            clipBounds.inset(-(pPaddingLeft + pPaddingRight), 0);
            canvas.clipRect(clipBounds, Region.Op.REPLACE);
          }

          canvas.translate(
              mBlurredView.getLeft() - getLeft() + tabLayout.getScrollX(),
              mBlurredView.getTop() - getTop());
          canvas.scale(mDownSampleFactor, mDownSampleFactor);
          canvas.drawBitmap(mBlurredBitmap, 0, 0, null);
          canvas.drawColor(mOverlayColor);
          canvas.restore();
        }
      }
    }
  }
  @Override
  protected void drawIndicator(Canvas canvas) {
    if (mActiveView != null && mActiveView.getParent() != null) {
      Integer position = (Integer) mActiveView.getTag(R.id.mdActiveViewPosition);
      final int pos = position == null ? 0 : position;

      if (pos == mActivePosition) {
        final int menuHeight = mMenuSize;
        final int indicatorHeight = mActiveIndicator.getHeight();

        mActiveView.getDrawingRect(mActiveRect);
        offsetDescendantRectToMyCoords(mActiveView, mActiveRect);
        final int indicatorWidth = mActiveIndicator.getWidth();

        final int indicatorTop = menuHeight - indicatorHeight;
        if (mIndicatorAnimating) {
          final int finalLeft = mActiveRect.left + ((mActiveRect.width() - indicatorWidth) / 2);
          final int startLeft = mIndicatorStartPos;
          final int diff = finalLeft - startLeft;
          final int startOffset = (int) (diff * mIndicatorOffset);
          mIndicatorLeft = startLeft + startOffset;
        } else {
          mIndicatorLeft = mActiveRect.left + ((mActiveRect.width() - indicatorWidth) / 2);
        }

        canvas.save();
        canvas.clipRect(mIndicatorLeft, indicatorTop, mIndicatorLeft + indicatorWidth, menuHeight);
        canvas.drawBitmap(mActiveIndicator, mIndicatorLeft, indicatorTop, null);
        canvas.restore();
      }
    }
  }
  @Override
  public void draw(Canvas canvas) {
    final Drawable background = mBackground;
    if (background != null) {
      final int scrollX = mScrollX;
      final int scrollY = mScrollY;

      if (mBackgroundSizeChanged) {
        background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
        mBackgroundSizeChanged = false;
      }

      if ((scrollX | scrollY) == 0) {
        background.draw(canvas);
      } else {
        canvas.translate(scrollX, scrollY);
        background.draw(canvas);
        canvas.translate(-scrollX, -scrollY);
      }
    }
    // We enhance the shadow by drawing the shadow twice
    getPaint().setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
    super.draw(canvas);
    canvas.save(Canvas.CLIP_SAVE_FLAG);
    canvas.clipRect(
        mScrollX,
        mScrollY + getExtendedPaddingTop(),
        mScrollX + getWidth(),
        mScrollY + getHeight(),
        Region.Op.INTERSECT);
    getPaint().setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
    super.draw(canvas);
    canvas.restore();
  }
 @Override
 protected void dispatchDraw(Canvas canvas) {
   if (mShouldClip) {
     canvas.clipRect(new Rect(getLeft(), getTop(), getRight(), getBottom() + mOffset));
   }
   super.dispatchDraw(canvas);
 }
Esempio n. 16
0
  public void onDrawLinkedLines(Canvas canvas) {
    canvas.save();
    int startX = 0;
    int startY = 0;
    if (fixedCol > 0) startX = cellX[fixedCol];
    if (fixedRow > 0) startY = cellY[fixedRow];

    canvas.clipRect(startX, startY, this.getWidth(), this.getHeight());
    painter.setStrokeWidth(2 * this.getContext().getResources().getDisplayMetrics().density);
    for (int i = 0; i < linkedCells.size() - 1; i++) {
      Cell c1 = linkedCells.get(i);
      Cell c2 = linkedCells.get(i + 1);
      if (c2.row - c1.row == 1) {
        if (c1.ballColor != null) {
          painter.setColor(c1.ballColor);
        } else if (c1.bgColor != null) {
          painter.setColor(c1.bgColor);
        }
        Rect r1 = this.getCellRectInView(c1);
        Rect r2 = this.getCellRectInView(c2);
        canvas.drawLine(
            (r1.left + r1.right) / 2,
            (r1.top + r1.bottom) / 2,
            (r2.left + r2.right) / 2,
            (r2.top + r2.bottom) / 2,
            painter);
      }
    }
    canvas.restore();
  }
  @Override
  public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int count = mPagesCount;
    if (count == 0) {
      return;
    }
    float cx = canvas.getWidth() >> 1;
    float cy = canvas.getHeight() >> 1;
    int totalCount = 2 * count - 1;
    int halfCount = totalCount / 2;
    float itemWithOffset = mIndicatorElementSize + mIndicatorElementSpacing;
    float halfItemWithOffset = mIndicatorElementSize / 2 + mIndicatorElementSpacing;
    float halfSize = mIndicatorElementSize / 2f;
    float halfSpacing = mIndicatorElementSpacing / 2f;
    float startX = cx - halfCount * (mIndicatorElementSize + mIndicatorElementSpacing);
    float top = cy - halfSize;
    float bottom = cy + halfSize;
    // if we have odd elements - need to set indicators in center
    if (totalCount % 2 != 0) {
      startX -= halfSize + halfSpacing;
    }

    int i;
    for (i = 0; i < totalCount; i++) {
      // skip empty spaces
      if (i % 2 != 0) {
        continue;
      }
      float left = startX + (mIndicatorElementSize + mIndicatorElementSpacing) * i;
      float right = left + mIndicatorElementSize;
      mElementBounds.set(left, top, right, bottom);
      mRenderer.draw(canvas, mElementBounds, mIndicatorPaint, false);
    }

    // multiply on 2 because there are spaces between elements
    float activeItemOffset = (mSelectedPosition + mScrolledOffset) * 2;
    float left = startX + (mIndicatorElementSize + mIndicatorElementSpacing) * activeItemOffset;
    float right = left + mIndicatorElementSize;
    mElementBounds.set(left, top, right, bottom);

    canvas.clipRect(mClipBounds);

    canvas.save();
    canvas.rotate(ANGLE_360 * mScrolledOffset, mElementBounds.centerX(), mElementBounds.centerY());
    mRenderer.draw(canvas, mElementBounds, mIndicatorSelectedPaint, true);
    canvas.restore();

    if (mIsInfiniteScroll && mSelectedPosition == mPagesCount - 1) { // isInfinite && isEnd
      activeItemOffset = (1f - mScrolledOffset) * 2;
      left = mClipBounds.left - itemWithOffset * activeItemOffset + halfItemWithOffset;
      right = left + mIndicatorElementSize;
      mElementBounds.set(left, top, right, bottom);
      canvas.save();
      canvas.rotate(
          ANGLE_360 * mScrolledOffset, mElementBounds.centerX(), mElementBounds.centerY());
      mRenderer.draw(canvas, mElementBounds, mIndicatorSelectedPaint, true);
      canvas.restore();
    }
  }
  private void drawLeftIndicator(Canvas canvas) {
    if (mLeftActiveView != null && isViewDescendant(mLeftActiveView)) {
      Integer position = (Integer) mLeftActiveView.getTag(R.id.tplActiveViewPosition);
      final int pos = position == null ? 0 : position;

      if (pos == mLeftActivePosition) {

        mLeftActiveView.getDrawingRect(mLeftActiveRect);
        offsetDescendantRectToMyCoords(mLeftActiveView, mLeftActiveRect);

        if (mLeftIndicatorAnimating) {
          final int indicatorFinalTop =
              mLeftActiveRect.top
                  + ((mLeftActiveRect.height() - mLeftActiveIndicator.getHeight()) / 2);
          final int indicatorStartTop = mLeftIndicatorStartPos;
          final int diff = indicatorFinalTop - indicatorStartTop;
          final int startOffset = (int) (diff * mLeftIndicatorOffset);
          mLeftIndicatorTop = indicatorStartTop + startOffset;
        } else {
          mLeftIndicatorTop =
              mLeftActiveRect.top
                  + ((mLeftActiveRect.height() - mLeftActiveIndicator.getHeight()) / 2);
        }
        final int right = (int) (mMiddlePane.getLeft() + Math.floor(mMiddlePane.getTranslationX()));
        final int left = right - mLeftActiveIndicator.getWidth();

        canvas.save();
        canvas.clipRect(left, 0, right, getHeight());
        canvas.drawBitmap(mLeftActiveIndicator, left, mLeftIndicatorTop, null);
        canvas.restore();
      }
    }
  }
Esempio n. 19
0
  private void drawAreaColors(Canvas canvas, int row, int col) {
    int colorNumber = puzzle.getAreaColor(row, col);
    int color = theme.getAreaColor(colorNumber, puzzle.getNumberOfAreaColors());

    canvas.clipRect(0, 0, cellWidth, cellHeight);
    canvas.drawColor(color);
  }
Esempio n. 20
0
  private void onDraw0(Canvas canvas) {
    if (Constants.LOG_V) Log.v(TAG, "onDraw(" + canvas.getClipBounds() + ")");

    canvas.save();
    canvas.translate(offsetX, offsetY);
    canvas.clipRect(0, 0, size * cellWidth, size * cellHeight);

    Rect clipBounds = canvas.getClipBounds();

    if (theme.isDrawAreaColors(puzzle.getPuzzleType())) drawAreaColors(canvas, clipBounds);
    else drawBackground(canvas);

    drawExtraRegions(canvas, clipBounds);

    if (puzzle.isSolved()) drawCongrats(canvas);
    else if (paused) drawPaused(canvas);
    else {
      drawHighlightedCells(canvas, clipBounds);

      drawMarkedPosition(canvas);
    }

    if (!preview && puzzle.hasErrors()) drawErrors(canvas, clipBounds);

    drawValues(canvas, clipBounds);

    drawGrid(canvas);

    drawRegionBorders(canvas, clipBounds);

    canvas.restore();

    drawOuterBorder(canvas);
  }
 protected void onDraw(Canvas paramCanvas)
 {
   if (m != null) {
     paramCanvas.clipRect(m);
   }
   super.onDraw(paramCanvas);
 }
 @Override
 public void drawTo(Canvas drawCanvas, float left, float top, Paint paint, boolean onlyDirty) {
   final Rect src = new Rect(0, 0, mTileSize, mTileSize);
   final Rect dst = new Rect(0, 0, mTileSize, mTileSize);
   drawCanvas.save();
   drawCanvas.translate(-left, -top);
   drawCanvas.clipRect(0, 0, mWidth, mHeight);
   for (int j = 0; j < mTilesY; j++) {
     for (int i = 0; i < mTilesX; i++) {
       dst.offsetTo(i * mTileSize, j * mTileSize);
       final int p = j * mTilesX + i;
       final Tile tile = mTiles[p];
       if (!onlyDirty || tile.dirty) {
         drawCanvas.drawBitmap(tile.getBitmap(), src, dst, paint);
         tile.dirty = false;
         if (mDebug) {
           mDrawCount++;
           dbgPaint.setColor(DEBUG_COLORS[tile.top % DEBUG_COLORS.length]);
           // drawCanvas.drawRect(dst, (mDrawCount % 2 == 0) ? dbgPaint1 : dbgPaint2);
           drawCanvas.drawRect(dst, dbgPaint);
           // drawCanvas.drawRect(dst, dbgStroke);
           drawCanvas.drawText(
               String.format("%d,%d v%d", tile.x, tile.y, tile.top),
               dst.left + 4,
               dst.bottom - 4,
               dbgTextPaint);
         }
       }
     }
   }
   drawCanvas.restore();
 }
Esempio n. 23
0
  private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) {
    int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right;
    int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom;

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    final Canvas canvas = new Canvas(bitmap);

    if (shadow != null) {
      shadow.setBounds(0, 0, width, height);
      shadow.draw(canvas);
    }

    final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG);
    // NOTE: Explicitly set clipping rect. This is required on Gingerbread.
    canvas.clipRect(
        mShadowPadding.left,
        mShadowPadding.top,
        width - mShadowPadding.right,
        height - mShadowPadding.bottom);
    canvas.translate(mShadowPadding.left, mShadowPadding.top);
    v.draw(canvas);
    canvas.restoreToCount(savedCount);

    return bitmap;
  }
    @Override
    public void dispatchDraw(Canvas canvas) {
      canvas.save();
      if (divider != null) {
        divider.setBounds(0, 0, dividerWidth, dividerHeight);
      }

      final int len = views.size();
      for (int i = 0; i < len; i++) {
        View v = views.get(i);

        canvas.save();
        canvas.clipRect(0, 0, getWidth(), v.getMeasuredHeight());
        v.draw(canvas);
        canvas.restore();

        if (divider != null) {
          divider.draw(canvas);
          canvas.translate(0, dividerHeight);
        }

        canvas.translate(0, v.getMeasuredHeight());
      }

      canvas.restore();
    }
  @Override
  protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);

    if (mPinnedSection != null) {

      // prepare variables
      int pLeft = getListPaddingLeft();
      int pTop = getListPaddingTop();
      View view = mPinnedSection.view;

      // draw child
      canvas.save();

      int clipHeight =
          view.getHeight()
              + (mShadowDrawable == null ? 0 : Math.min(mShadowHeight, mSectionsDistanceY));
      canvas.clipRect(pLeft, pTop, pLeft + view.getWidth(), pTop + clipHeight);

      canvas.translate(pLeft, pTop + mTranslateY);
      drawChild(canvas, mPinnedSection.view, getDrawingTime());

      if (mShadowDrawable != null && mSectionsDistanceY > 0) {
        mShadowDrawable.setBounds(
            mPinnedSection.view.getLeft(),
            mPinnedSection.view.getBottom(),
            mPinnedSection.view.getRight(),
            mPinnedSection.view.getBottom() + mShadowHeight);
        mShadowDrawable.draw(canvas);
      }

      canvas.restore();
    }
  }
Esempio n. 26
0
 @Override
 public void tbsPaint(Canvas canvas, Rect rect) {
   canvas.translate(-rect.getLeft(), -rect.getTop());
   float contentsScale = mBS.getContentsScale();
   LinearGradient mLinearGradient =
       new LinearGradient(
           0,
           0,
           500 * contentsScale,
           500 * contentsScale,
           new int[] {
             android.graphics.Color.RED,
             android.graphics.Color.GREEN,
             android.graphics.Color.BLUE,
             android.graphics.Color.WHITE
           },
           null,
           Shader.TileMode.REPEAT);
   Paint paint = new Paint();
   paint.setShader(mLinearGradient);
   canvas.clipRect(rect.getLeft(), rect.getTop(), rect.getRight(), rect.getBottom());
   canvas.drawRect(
       mContentsRect.getLeft() * contentsScale,
       mContentsRect.getTop() * contentsScale,
       mContentsRect.getRight() * contentsScale,
       mContentsRect.getBottom() * contentsScale,
       paint);
 }
  @Override
  public void draw(Canvas canvas) {
    mBounds = getBounds();
    canvas.clipRect(mBounds);

    // new turn
    if (mNewTurn) {
      mColorsIndex = decrementColor(mColorsIndex);
      mNewTurn = false;

      if (isFinishing()) {
        mStartSection++;

        if (mStartSection > mSectionsCount) {
          stop();
          return;
        }
      }
      if (mCurrentSections < mSectionsCount) {
        mCurrentSections++;
      }
    }

    if (mUseGradients) drawGradient(canvas);

    drawStrokes(canvas);
  }
  private void generateBitmap(float fraction) {
    mBitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(mBitmap);

    canvas.clipRect(0, (int) (64 * fraction), 64, 0);
    canvas.drawARGB(255, 255, 255, 255);
  }
Esempio n. 29
0
 private void drawBg(Canvas paramCanvas) {
   if ((isItemPressed()) && (this.mSelectedIndex == 0)) {
     int i = paramCanvas.save();
     paramCanvas.clipRect(0, 0, this.itemLayout.width, this.mItemHeight);
     paramCanvas.drawColor(SkinManager.getItemHighlightMaskColor_new());
     paramCanvas.restoreToCount(i);
   }
 }
Esempio n. 30
0
 protected void onDraw(Canvas canvas) {
   canvas.clipRect(0, 0, getWidth(), getHeight());
   b.reset();
   b.addCircle(
       getWidth() / 2, getHeight() / 2, getWidth() / 2 + 1, android.graphics.Path.Direction.CW);
   canvas.clipPath(b, android.graphics.Region.Op.REPLACE);
   super.onDraw(canvas);
 }