Пример #1
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (currentMessageObject == null) {
      return;
    }

    if (currentMessageObject.isOutOwner()) {
      timePaint.setColor(theme.ChatMusicCell_timePaint_color);
    } else {
      timePaint.setColor(theme.ChatMusicCell_timePaint_color_2);
    }
    radialProgress.draw(canvas);

    canvas.save();
    canvas.translate(timeX + titleX, AndroidUtilities.dp(12) + namesOffset);
    titleLayout.draw(canvas);
    canvas.restore();

    canvas.save();
    if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) {
      canvas.translate(seekBarX, seekBarY);
      seekBar.draw(canvas);
    } else {
      canvas.translate(timeX + authorX, AndroidUtilities.dp(32) + namesOffset);
      authorLayout.draw(canvas);
    }
    canvas.restore();

    canvas.save();
    canvas.translate(timeX, AndroidUtilities.dp(52) + namesOffset);
    timeLayout.draw(canvas);
    canvas.restore();
  }
  @Override
  public void onDrawIndicator(Canvas canvas) {
    int height = mPageIndicator.getHeight();

    for (int i = 0; i < mPageIndicator.getTotalPages(); i++) {
      if (i == mPageIndicator.getActualPosition() + 1) {
        int x = mConversionUtils.getPixelsFromDp(4) + mConversionUtils.getPixelsFromDp(16 * i);

        canvas.save();
        canvas.rotate(90 * mPageIndicator.getPositionOffset(), x, height / 2);
      } else if (i == mPageIndicator.getActualPosition()) {
        int x = mConversionUtils.getPixelsFromDp(4) + mConversionUtils.getPixelsFromDp(16 * i);

        canvas.save();
        canvas.rotate(90 + (90 * mPageIndicator.getPositionOffset()), x, height / 2);
      } else {
        canvas.save();
      }
      int x = mConversionUtils.getPixelsFromDp(0) + mConversionUtils.getPixelsFromDp(16 * i);
      int twoDp = mConversionUtils.getPixelsFromDp(3);
      int sixDp = mConversionUtils.getPixelsFromDp(5);
      int heightDp = mConversionUtils.getPixelsFromDp(8);
      canvas.drawRect(x, twoDp, x + heightDp, sixDp, mPaint);
      canvas.restore();
    }
  }
Пример #3
0
  /** Draws the overscroll edge glow effect on the left and right sides of the horizontal list */
  private void drawEdgeGlow(Canvas canvas) {
    if (mEdgeGlowLeft != null && !mEdgeGlowLeft.isFinished() && isEdgeGlowEnabled()) {
      // The Edge glow is meant to come from the top of the screen, so rotate it to draw on the left
      // side.
      final int restoreCount = canvas.save();
      final int height = getHeight();

      canvas.rotate(-90, 0, 0);
      canvas.translate(-height + getPaddingBottom(), 0);

      mEdgeGlowLeft.setSize(getRenderHeight(), getRenderWidth());
      if (mEdgeGlowLeft.draw(canvas)) {
        invalidate();
      }

      canvas.restoreToCount(restoreCount);
    } else if (mEdgeGlowRight != null && !mEdgeGlowRight.isFinished() && isEdgeGlowEnabled()) {
      // The Edge glow is meant to come from the top of the screen, so rotate it to draw on the
      // right side.
      final int restoreCount = canvas.save();
      final int width = getWidth();

      canvas.rotate(90, 0, 0);
      canvas.translate(getPaddingTop(), -width);
      mEdgeGlowRight.setSize(getRenderHeight(), getRenderWidth());
      if (mEdgeGlowRight.draw(canvas)) {
        invalidate();
      }

      canvas.restoreToCount(restoreCount);
    }
  }
Пример #4
0
    private void drawRightTopArc(Canvas canvas) {
      canvas.save();

      canvas.translate(0, -radius * 3); // the center of the circle in the rightTop
      canvas.drawArc(oval, -22.5f, -135, true, arcPaint);

      arcPaint.setStyle(Paint.Style.STROKE);
      arcPaint.setColor(Color.WHITE);
      canvas.drawArc(
          oval, -22.5f, -135, false,
          arcPaint); // @param useCenter: useCenter If true, include the center of the oval in the
                     // arc, and close it if it is being stroked. This will draw a wedge

      // ======== draw arc text ==========
      canvas.save();
      canvas.rotate(-135 / 2); // 到正中间

      for (int i = 0; i < 135; i += 33.75) { // 33.75 * 4 = 135;
        canvas.save();
        canvas.rotate(i);
        canvas.drawText("Item", 0, -width * 5 / 32, textPaint);
        canvas.restore();
      }

      canvas.restore();
      // ======== draw arc text ==========

      canvas.restore();
    }
    @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();
    }
Пример #6
0
  /**
   * Draws value and label layout.
   *
   * @param canvas the canvas for drawing
   */
  private void drawValue(Canvas canvas) {
    valuePaint.setColor(valueTextColor);
    valuePaint.drawableState = getDrawableState();

    labelPaint.setColor(labelTextColor);
    labelPaint.drawableState = getDrawableState();

    Rect bounds = new Rect();
    itemsLayout.getLineBounds(visibleItems / 2, bounds);

    // draw label
    if (labelLayout != null) {
      canvas.save();
      canvas.translate(itemsLayout.getWidth() + LABEL_OFFSET, bounds.top);
      labelLayout.draw(canvas);
      canvas.restore();
    }

    // draw current value
    if (valueLayout != null) {
      canvas.save();
      canvas.translate(0, bounds.top + scrollingOffset);
      valueLayout.draw(canvas);
      canvas.restore();
    }
  }
Пример #7
0
  private void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
    final QuadPoint c = tileBox.getCenterPixelPoint();
    synchronized (this) {
      if (bufferBitmap != null && !bufferBitmap.isRecycled()) {
        canvas.save();
        canvas.rotate(tileBox.getRotate(), c.x, c.y);
        drawBasemap(canvas);
        canvas.restore();
      }
    }

    for (int i = 0; i < layers.size(); i++) {
      try {
        OsmandMapLayer layer = layers.get(i);
        canvas.save();
        // rotate if needed
        if (!layer.drawInScreenPixels()) {
          canvas.rotate(tileBox.getRotate(), c.x, c.y);
        }
        layer.onDraw(canvas, tileBox, drawSettings);
        canvas.restore();
      } catch (IndexOutOfBoundsException e) {
        // skip it
      }
    }
    if (showMapPosition) {
      canvas.drawCircle(c.x, c.y, 3 * dm.density, paintCenter);
      canvas.drawCircle(c.x, c.y, 7 * dm.density, paintCenter);
    }
  }
    @Override
    protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);

      canvas.drawARGB(255, 255, 255, 255);

      canvas.save();
      canvas.translate(120.0f, 50.0f);
      canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mColorMatrixPaint);

      canvas.translate(0.0f, 50.0f + mBitmap1.getHeight());
      canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mLightingPaint);

      canvas.translate(0.0f, 50.0f + mBitmap1.getHeight());
      canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBlendPaint);
      canvas.restore();

      canvas.save();
      canvas.translate(120.0f + mBitmap1.getWidth() + 120.0f, 50.0f);
      canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mColorMatrixPaint);

      canvas.translate(0.0f, 50.0f + mBitmap2.getHeight());
      canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mLightingPaint);

      canvas.translate(0.0f, 50.0f + mBitmap2.getHeight());
      canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mBlendPaint);
      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();
    }
  }
Пример #10
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();
 }
  private void drawEdges(Canvas canvas) {

    if (mEdgeGlowLeft != null) {

      final int width = getWidth();
      final int height = getHeight() - getPaddingTop() - getPaddingBottom();

      if (!mEdgeGlowLeft.isFinished()) {
        final int restoreCount = canvas.save();

        canvas.rotate(270);
        canvas.translate(-height + getPaddingTop(), 0);
        mEdgeGlowLeft.setSize(height, width);
        if (mEdgeGlowLeft.draw(canvas)) {
          postInvalidate();
        }
        canvas.restoreToCount(restoreCount);
      }

      if (!mEdgeGlowRight.isFinished()) {
        final int restoreCount = canvas.save();

        canvas.rotate(90);
        canvas.translate(-getPaddingTop(), -(mTouchX + width));
        mEdgeGlowRight.setSize(height, width);

        if (mEdgeGlowRight.draw(canvas)) {
          postInvalidate();
        }
        canvas.restoreToCount(restoreCount);
      }
    }
  }
  @Override
  public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    boolean needsInvalidate = false;

    if (mTopGlow != null && !mTopGlow.isFinished()) {
      final int restore = c.save();
      if (getClipToPadding(parent)) {
        c.translate(parent.getPaddingLeft(), parent.getPaddingTop());
      }
      //noinspection ConstantConditions
      needsInvalidate |= mTopGlow.draw(c);
      c.restoreToCount(restore);
    }

    if (mBottomGlow != null && !mBottomGlow.isFinished()) {
      final int restore = c.save();
      c.rotate(180);
      if (getClipToPadding(parent)) {
        c.translate(
            -parent.getWidth() + parent.getPaddingRight(),
            -parent.getHeight() + parent.getPaddingBottom());
      } else {
        c.translate(-parent.getWidth(), -parent.getHeight());
      }
      needsInvalidate |= mBottomGlow.draw(c);
      c.restoreToCount(restore);
    }

    if (needsInvalidate) {
      ViewCompat.postInvalidateOnAnimation(parent);
    }
  }
  @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);
  }
Пример #14
0
  @Override
  protected void onDraw(final Canvas canvas) {
    if (recycled) return;

    final int canvasSave = canvas.save();

    canvas.translate(getPaddingLeft(), getPaddingTop());
    canvas.scale(scale, scale);

    canvas.drawBitmap(genBackgroundBitmap, 0, 0, bitmapPaint);

    final boolean drawSignal = signalMin != null && signalMax != null;
    if (drawSignal) {
      signalTextPaint.setTextAlign(Align.LEFT);
      canvas.drawText(
          String.format("– %s", signalText), coordFW(9, relW), coordFH(130, relH), signalTextPaint);
      signalTextPaint.setTextAlign(Align.RIGHT);
      canvas.drawText(
          Integer.toString(signalMin), coordFW(72, relW), coordFH(195, relH), signalTextPaint);
      canvas.drawText(
          Integer.toString(signalMax), coordFW(72, relW), coordFH(58, relH), signalTextPaint);
    }

    canvas.drawBitmap(gridBitmap, gridX, gridY, bitmapPaint);

    final int canvasSave2 = canvas.save();
    canvas.translate(graphX, graphY);

    for (final GraphService graph : graphs) graph.draw(canvas);

    canvas.restoreToCount(canvasSave2);

    canvas.restoreToCount(canvasSave);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    if (user == null && chat == null && encryptedChat == null) {
      return;
    }

    if (cellLayout == null) {
      requestLayout();
      return;
    }

    if (useSeparator) {
      int h = getMeasuredHeight();
      if (!usePadding) {
        canvas.drawLine(0, h - 1, getMeasuredWidth(), h - 1, linePaint);
      } else {
        canvas.drawLine(
            AndroidUtilities.dp(11),
            h - 1,
            getMeasuredWidth() - AndroidUtilities.dp(11),
            h - 1,
            linePaint);
      }
    }

    if (drawAlpha != 1) {
      canvas.saveLayerAlpha(
          0,
          0,
          canvas.getWidth(),
          canvas.getHeight(),
          (int) (255 * drawAlpha),
          Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
    }

    if (cellLayout.drawNameLock) {
      setDrawableBounds(lockDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      lockDrawable.draw(canvas);
    } else if (cellLayout.drawNameGroup) {
      setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      groupDrawable.draw(canvas);
    } else if (cellLayout.drawNameBroadcast) {
      setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
      broadcastDrawable.draw(canvas);
    }

    canvas.save();
    canvas.translate(cellLayout.nameLeft, cellLayout.nameTop);
    cellLayout.nameLayout.draw(canvas);
    canvas.restore();

    if (cellLayout.onlineLayout != null) {
      canvas.save();
      canvas.translate(cellLayout.onlineLeft, cellLayout.onlineTop);
      cellLayout.onlineLayout.draw(canvas);
      canvas.restore();
    }

    avatarImage.draw(canvas);
  }
Пример #16
0
  @Override
  public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);
    if (leftGlow != null) {
      final int scrollX = getScrollX();
      if (!leftGlow.isFinished()) {
        final int restoreCount = canvas.save();
        final int height = getHeight() - getPaddingTop() - getPaddingBottom();

        canvas.rotate(270);
        canvas.translate(-height + getPaddingTop(), Math.min(0, scrollX));
        leftGlow.setSize(height, getWidth());
        if (leftGlow.draw(canvas)) {
          postInvalidate();
        }
        canvas.restoreToCount(restoreCount);
      }
      if (!rightGlow.isFinished()) {
        final int restoreCount = canvas.save();
        final int width = getWidth();
        final int height = getHeight() - getPaddingTop() - getPaddingBottom();

        canvas.rotate(90);
        canvas.translate(-getPaddingTop(), -(Math.max(getScrollRange(), scrollX) + width));
        rightGlow.setSize(height, width);
        if (rightGlow.draw(canvas)) {
          postInvalidate();
        }
        canvas.restoreToCount(restoreCount);
      }
    }
  }
Пример #17
0
  public void draw(Canvas canvas) {
    ArrayList<Point> points = mPointCloud;
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    canvas.scale(mScale, mScale, mCenterX, mCenterY);
    for (int i = 0; i < points.size(); i++) {
      Point point = points.get(i);
      final float pointSize = interp(MAX_POINT_SIZE, MIN_POINT_SIZE, point.radius / mOuterRadius);
      final float px = point.x + mCenterX;
      final float py = point.y + mCenterY;
      int alpha = getAlphaForPoint(point);

      if (alpha == 0) continue;

      if (mDrawable != null) {
        canvas.save(Canvas.MATRIX_SAVE_FLAG);
        final float cx = mDrawable.getIntrinsicWidth() * 0.5f;
        final float cy = mDrawable.getIntrinsicHeight() * 0.5f;
        final float s = pointSize / MAX_POINT_SIZE;
        canvas.scale(s, s, px, py);
        canvas.translate(px - cx, py - cy);
        mDrawable.setAlpha(alpha);
        mDrawable.draw(canvas);
        canvas.restore();
      } else {
        mPaint.setAlpha(alpha);
        canvas.drawCircle(px, py, pointSize, mPaint);
      }
    }
    canvas.restore();
  }
Пример #18
0
  protected void onDraw(Canvas canvas) {
    mCalendar = Calendar.getInstance();
    super.onDraw(canvas);
    int minute = mCalendar.get(Calendar.MINUTE); // 得到当前分钟数
    int hour = mCalendar.get(Calendar.HOUR); // 得到当前小时数
    int sec = mCalendar.get(Calendar.SECOND); // 得到当前秒数

    float minuteDegree = minute / 60f * 360; // 得到分针旋转的角度
    canvas.save();
    canvas.rotate(minuteDegree, width / 2, height / 2);
    canvas.drawLine(width / 2, height / 2 - 250, width / 2, height / 2 + 40, mPaintMinute);
    canvas.restore();

    float hourDegree = (hour * 60 + minute) / 12f / 60 * 360; // 得到时钟旋转的角度
    canvas.save();
    canvas.rotate(hourDegree, width / 2, height / 2);
    canvas.drawLine(width / 2, height / 2 - 200, width / 2, height / 2 + 30, mPaintHour);
    canvas.restore();

    float secDegree = sec / 60f * 360; // 得到秒针旋转的角度
    canvas.save();
    canvas.rotate(secDegree, width / 2, height / 2);
    canvas.drawLine(width / 2, height / 2 - 300, width / 2, height / 2 + 40, mPaintSec);
    canvas.restore();
  }
    @Override
    protected void onDraw(Canvas canvas) {

      canvas.translate(20, 100);
      int source = canvas.save();
      canvas.drawBitmap(def, 0, 0, null);
      canvas.translate(320, 0);
      canvas.drawBitmap(one, 0, 0, null);
      canvas.translate(120, 0);
      canvas.drawBitmap(two, 0, 0, null);
      canvas.translate(120, 0);
      canvas.drawBitmap(three, 0, 0, null);
      canvas.translate(120, 0);
      canvas.drawBitmap(four, 0, 0, null);
      canvas.restoreToCount(source);

      canvas.translate(0, 320);
      source = canvas.save();
      for (int i = 0; i < bs.length; i++) {
        if (bs[i] != null) {
          final Bitmap b = bs[i];
          canvas.drawBitmap(b, i * (200 + 20), 0, null);
        }
      }
      canvas.restoreToCount(source);
      canvas.translate(0, 220);
      source = canvas.save();
      canvas.drawBitmap(sum, 0, 0, null);
    }
  private void drawEdges(Canvas canvas) {

    if (mEdgeGlowLeft != null) {
      if (!mEdgeGlowLeft.isFinished()) {
        final int restoreCount = canvas.save();
        final int height = getHeight();

        canvas.rotate(-90);
        canvas.translate(-height / 1.5f, 0);
        mEdgeGlowLeft.setSize((int) (height / 2.5f), height / 5);

        if (mEdgeGlowLeft.draw(canvas)) {
          invalidate();
        }
        canvas.restoreToCount(restoreCount);
      }
      if (!mEdgeGlowRight.isFinished()) {
        final int restoreCount = canvas.save();
        final int width = getWidth();
        final int height = getHeight();

        canvas.translate(getScrollX() + width, height / 3f);
        canvas.rotate(90);
        mEdgeGlowRight.setSize((int) (height / 2.5f), height / 5);
        if (mEdgeGlowRight.draw(canvas)) {
          invalidate();
        }
        canvas.restoreToCount(restoreCount);
      }
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    final int width = getWidth();
    final int height = getHeight() - getPaddingBottom();

    final Drawable secondary = mSecondary;
    if (secondary != null) {
      final int secondaryHeight = secondary.getIntrinsicHeight();

      final float[] vertTicks = mVert.getTickPoints();
      for (float y : vertTicks) {
        final int bottom = (int) Math.min(y + secondaryHeight, height);
        secondary.setBounds(0, (int) y, width, bottom);
        secondary.draw(canvas);
      }
    }

    final Drawable primary = mPrimary;
    if (primary != null) {
      final int primaryWidth = primary.getIntrinsicWidth();
      final int primaryHeight = primary.getIntrinsicHeight();

      final float[] horizTicks = mHoriz.getTickPoints();
      for (float x : horizTicks) {
        final int right = (int) Math.min(x + primaryWidth, width);
        primary.setBounds((int) x, 0, right, height);
        primary.draw(canvas);
      }
    }

    mBorder.setBounds(0, 0, width, height);
    mBorder.draw(canvas);

    final int padding = mLabelStart != null ? mLabelStart.getHeight() / 8 : 0;

    final Layout start = mLabelStart;
    if (start != null) {
      final int saveCount = canvas.save();
      canvas.translate(0, height + padding);
      start.draw(canvas);
      canvas.restoreToCount(saveCount);
    }

    final Layout mid = mLabelMid;
    if (mid != null) {
      final int saveCount = canvas.save();
      canvas.translate((width - mid.getWidth()) / 2, height + padding);
      mid.draw(canvas);
      canvas.restoreToCount(saveCount);
    }

    final Layout end = mLabelEnd;
    if (end != null) {
      final int saveCount = canvas.save();
      canvas.translate(width - end.getWidth(), height + padding);
      end.draw(canvas);
      canvas.restoreToCount(saveCount);
    }
  }
Пример #22
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    measureRect();

    if (mDragHandlerPaint == null) {
      return;
    }
    if (mMarginPaint == null) {
      return;
    }
    if (INNER_RECT) {
      canvas.save();
      canvas.drawLine(
          mBitmapRectPoints[0],
          mBitmapRectPoints[1],
          mBitmapRectPoints[2],
          mBitmapRectPoints[3],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[4],
          mBitmapRectPoints[5],
          mBitmapRectPoints[6],
          mBitmapRectPoints[7],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[0],
          mBitmapRectPoints[1],
          mBitmapRectPoints[4],
          mBitmapRectPoints[5],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[2],
          mBitmapRectPoints[3],
          mBitmapRectPoints[6],
          mBitmapRectPoints[7],
          mMarginPaint);
      canvas.drawCircle(mBitmapRectPoints[0], mBitmapRectPoints[1], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[2], mBitmapRectPoints[3], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[4], mBitmapRectPoints[5], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[6], mBitmapRectPoints[7], mRadius, mDragHandlerPaint);
      canvas.restore();
    } else {
      canvas.save();
      canvas.drawRect(mMarginRectF, mMarginPaint);
      canvas.drawCircle(mMarginRectF.left, mMarginRectF.top, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.right, mMarginRectF.top, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.left, mMarginRectF.bottom, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.right, mMarginRectF.bottom, mRadius, mDragHandlerPaint);
      canvas.restore();
    }

    if (!(mDragPoint.x == INVALID_POINT && mDragPoint.y == INVALID_POINT)) {
      canvas.save();
      canvas.drawCircle(mMarginRectF.centerX(), mMarginRectF.centerY(), mRadius, mDragHandlerPaint);
      canvas.restore();
    }
  }
  @Override
  public void draw(Canvas canvas, Matrix matrix, float currentZoom, float currentRotateDegrees) {
    canvas.save();
    if (this.isVisible && this.currentPosition != null) {
      float goal[] = {currentPosition.x, currentPosition.y};
      matrix.mapPoints(goal);

      canvas.drawCircle(goal[0], goal[1], defaultLocationCircleRadius, locationPaint);

      if (currentMode == MODE_COMPASS) {
          /*
          for (int i = 0; i < 360 / COMPASS_DELTA_ANGLE; i++)
          {
              canvas.save();
              canvas.rotate(COMPASS_DELTA_ANGLE * i, goal[0], goal[1]);

              if (i % (90 / COMPASS_DELTA_ANGLE) == 0)
              {
                  canvas.drawLine(goal[0], goal[1] - compassRadius + compassLocationCircleRadius, goal[0], goal[1] - compassRadius + compassLocationCircleRadius - compassLineLength, compassLinePaint);
              }
              else
              {
                  canvas.drawCircle(goal[0], goal[1] - compassRadius, compassLocationCircleRadius, new Paint());
              }
              canvas.restore();
          }*/
        if (compassIndicatorArrowBitmap != null) {
          canvas.save();
          canvas.rotate(this.compassIndicatorArrowRotateDegree, goal[0], goal[1]);
          canvas.drawBitmap(
              compassIndicatorArrowBitmap,
              goal[0] - compassIndicatorArrowBitmap.getWidth() / 2,
              goal[1] - defaultLocationCircleRadius - compassIndicatorGap,
              new Paint());
          canvas.restore();
          /*
          if (360 - (this.compassIndicatorArrowRotateDegree - this.compassIndicatorCircleRotateDegree) > 180)
          {
              canvas.drawArc(new RectF(goal[0] - compassRadius, goal[1] - compassRadius, goal[0] + compassRadius, goal[1] + compassRadius), -90 + this.compassIndicatorCircleRotateDegree, (this.compassIndicatorArrowRotateDegree - this.compassIndicatorCircleRotateDegree), false,
                      indicatorArcPaint);
          }
          else
          {
              canvas.drawArc(new RectF(goal[0] - compassRadius, goal[1] - compassRadius, goal[0] + compassRadius, goal[1] + compassRadius), -90 + this.compassIndicatorArrowRotateDegree, 360 - (this.compassIndicatorArrowRotateDegree - this.compassIndicatorCircleRotateDegree), false,
                      indicatorArcPaint);
          }*/

        }
        canvas.save();
        canvas.rotate(compassIndicatorCircleRotateDegree, goal[0], goal[1]);
        // canvas.drawCircle(goal[0], goal[1] - compassRadius, compassIndicatorCircleRadius,
        // indicatorCirclePaint);
        canvas.restore();
      }
    }
    canvas.restore();
  }
Пример #24
0
 protected final int i(int paramInt, Object... paramVarArgs) {
   switch (paramInt) {
   }
   for (; ; ) {
     return 0;
     return 168;
     return 168;
     Canvas localCanvas = (Canvas) paramVarArgs[0];
     paramVarArgs = (Looper) paramVarArgs[1];
     Object localObject1 = c.d(paramVarArgs);
     Object localObject2 = c.c(paramVarArgs);
     Paint localPaint1 = c.g(paramVarArgs);
     localPaint1.setFlags(385);
     localPaint1.setStyle(Paint.Style.FILL);
     Paint localPaint2 = c.g(paramVarArgs);
     localPaint2.setFlags(385);
     localPaint2.setStyle(Paint.Style.STROKE);
     localPaint1.setColor(-16777216);
     localPaint2.setStrokeWidth(1.0F);
     localPaint2.setStrokeCap(Paint.Cap.BUTT);
     localPaint2.setStrokeJoin(Paint.Join.MITER);
     localPaint2.setStrokeMiter(4.0F);
     localPaint2.setPathEffect(null);
     c.a(localPaint2, paramVarArgs).setStrokeWidth(1.0F);
     localPaint1 = c.a(localPaint1, paramVarArgs);
     localPaint1.setColor(-9473160);
     localCanvas.save();
     localObject2 = c.a((float[]) localObject2, 1.0F, 0.0F, 51.0F, 0.0F, 1.0F, 39.0F);
     ((Matrix) localObject1).reset();
     ((Matrix) localObject1).setValues((float[]) localObject2);
     localCanvas.concat((Matrix) localObject1);
     localCanvas.save();
     localObject1 = c.a(localPaint1, paramVarArgs);
     localObject2 = c.h(paramVarArgs);
     ((Path) localObject2).moveTo(31.624044F, 90.34997F);
     ((Path) localObject2)
         .cubicTo(32.383965F, 91.14044F, 33.629753F, 91.13373F, 34.386406F, 90.3389F);
     ((Path) localObject2).cubicTo(34.386406F, 90.3389F, 66.0F, 58.57656F, 66.0F, 33.461914F);
     ((Path) localObject2).cubicTo(66.0F, 14.90092F, 51.225395F, 0.0F, 33.47826F, 0.0F);
     ((Path) localObject2).cubicTo(14.774603F, 0.0F, 0.0F, 14.90092F, 0.0F, 33.461914F);
     ((Path) localObject2).cubicTo(0.0F, 58.57656F, 31.624044F, 90.34997F, 31.624044F, 90.34997F);
     ((Path) localObject2).close();
     ((Path) localObject2).moveTo(33.0F, 44.30819F);
     ((Path) localObject2).cubicTo(39.07513F, 44.30819F, 44.0F, 39.348827F, 44.0F, 33.231144F);
     ((Path) localObject2).cubicTo(44.0F, 27.113459F, 39.07513F, 22.154095F, 33.0F, 22.154095F);
     ((Path) localObject2).cubicTo(26.924868F, 22.154095F, 22.0F, 27.113459F, 22.0F, 33.231144F);
     ((Path) localObject2).cubicTo(22.0F, 39.348827F, 26.924868F, 44.30819F, 33.0F, 44.30819F);
     ((Path) localObject2).close();
     WeChatSVGRenderC2Java.setFillType((Path) localObject2, 2);
     localCanvas.drawPath((Path) localObject2, (Paint) localObject1);
     localCanvas.restore();
     localCanvas.restore();
     c.f(paramVarArgs);
   }
 }
Пример #25
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();
  }
Пример #26
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);
  }
Пример #27
0
 protected void onDraw(Canvas canvas)
 {
     super.onDraw(canvas);
     if (getBackground() != null)
     {
         if (mShader != null && mShaderMatrix != null)
         {
             int i = mShaderWidth / 2;
             int l = getPositionFromValue(mCurrentValue);
             mShaderMatrix.setTranslate(l - i, 0.0F);
             mShader.setLocalMatrix(mShaderMatrix);
             canvas.drawRect(mEdgeOffset, 0.0F, (float)getWidth() - mEdgeOffset, getHeight(), mLinesPaint);
         }
         canvas.translate(0.0F, mHeightDiff);
         mShadowBottom.draw(canvas);
         canvas.translate(0.0F, -mHeightDiff);
         if (debugPaint != null)
         {
             debugPaint.setColor(-1);
             debugPaint.setAlpha(127);
             canvas.drawLine(mMinX, 0.0F, mMinX, getHeight(), debugPaint);
             canvas.drawLine(mMaxX, 0.0F, mMaxX, getHeight(), debugPaint);
             canvas.drawLine(getWidth() / 2, 0.0F, getWidth() / 2, getHeight(), debugPaint);
         }
         if (mEdgeLeft != null)
         {
             if (!mEdgeLeft.isFinished())
             {
                 int j = canvas.save();
                 canvas.concat(mEdgeMatrixLeft);
                 if (mEdgeLeft.draw(canvas))
                 {
                     postInvalidate();
                 }
                 canvas.restoreToCount(j);
             }
             if (!mEdgeRight.isFinished())
             {
                 int k = canvas.save();
                 canvas.concat(mEdgeMatrixRight);
                 if (mEdgeRight.draw(canvas))
                 {
                     postInvalidate();
                 }
                 canvas.restoreToCount(k);
                 return;
             }
         }
     }
 }
 private void drawShadow(Canvas canvas) {
   float f = -mCornerRadius - mShadowSize;
   float f1 = mCornerRadius + (float) mInsetShadow + mRawShadowSize / 2.0F;
   int i;
   boolean flag;
   int j;
   if (mCardBounds.width() - 2.0F * f1 > 0.0F) {
     i = 1;
   } else {
     i = 0;
   }
   if (mCardBounds.height() - 2.0F * f1 > 0.0F) {
     flag = true;
   } else {
     flag = false;
   }
   j = canvas.save();
   canvas.translate(mCardBounds.left + f1, mCardBounds.top + f1);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (i != 0) {
     canvas.drawRect(0.0F, f, mCardBounds.width() - 2.0F * f1, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(j);
   j = canvas.save();
   canvas.translate(mCardBounds.right - f1, mCardBounds.bottom - f1);
   canvas.rotate(180F);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (i != 0) {
     float f2 = mCardBounds.width();
     float f3 = -mCornerRadius;
     canvas.drawRect(0.0F, f, f2 - 2.0F * f1, mShadowSize + f3, mEdgeShadowPaint);
   }
   canvas.restoreToCount(j);
   i = canvas.save();
   canvas.translate(mCardBounds.left + f1, mCardBounds.bottom - f1);
   canvas.rotate(270F);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (flag) {
     canvas.drawRect(0.0F, f, mCardBounds.height() - 2.0F * f1, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(i);
   i = canvas.save();
   canvas.translate(mCardBounds.right - f1, mCardBounds.top + f1);
   canvas.rotate(90F);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (flag) {
     canvas.drawRect(0.0F, f, mCardBounds.height() - 2.0F * f1, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(i);
 }
Пример #29
0
 private void drawShadow(Canvas canvas) {
   final float edgeShadowTop = -mCornerRadius - mShadowSize;
   final float inset = mCornerRadius + mInsetShadow + mRawShadowSize / 2;
   final boolean drawHorizontalEdges = mCardBounds.width() - 2 * inset > 0;
   final boolean drawVerticalEdges = mCardBounds.height() - 2 * inset > 0;
   // LT
   int saved = canvas.save();
   canvas.translate(mCardBounds.left + inset, mCardBounds.top + inset);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (drawHorizontalEdges) {
     canvas.drawRect(
         0, edgeShadowTop, mCardBounds.width() - 2 * inset, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(saved);
   // RB
   saved = canvas.save();
   canvas.translate(mCardBounds.right - inset, mCardBounds.bottom - inset);
   canvas.rotate(180f);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (drawHorizontalEdges) {
     canvas.drawRect(
         0,
         edgeShadowTop,
         mCardBounds.width() - 2 * inset,
         -mCornerRadius + mShadowSize,
         mEdgeShadowPaint);
   }
   canvas.restoreToCount(saved);
   // LB
   saved = canvas.save();
   canvas.translate(mCardBounds.left + inset, mCardBounds.bottom - inset);
   canvas.rotate(270f);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (drawVerticalEdges) {
     canvas.drawRect(
         0, edgeShadowTop, mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(saved);
   // RT
   saved = canvas.save();
   canvas.translate(mCardBounds.right - inset, mCardBounds.top + inset);
   canvas.rotate(90f);
   canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
   if (drawVerticalEdges) {
     canvas.drawRect(
         0, edgeShadowTop, mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint);
   }
   canvas.restoreToCount(saved);
 }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onDraw(android.graphics.Canvas)
   */
  @Override
  protected void onDraw(final Canvas canvas) {

    // All of our positions are using our internal coordinate system.
    // Instead of translating
    // them we let Canvas do the work for us.
    canvas.translate(mTranslationOffsetX, mTranslationOffsetY);

    final float progressRotation = getCurrentRotation();

    // draw the background
    if (!mOverrdraw) {
      canvas.drawArc(mCircleBounds, 270, -(360 - progressRotation), false, mBackgroundColorPaint);
    }

    // draw the progress or a full circle if overdraw is true
    canvas.drawArc(
        mCircleBounds, 270, mOverrdraw ? 360 : progressRotation, false, mProgressColorPaint);

    // draw the marker at the correct rotated position
    if (mIsMarkerEnabled) {
      final float markerRotation = getMarkerRotation();

      canvas.save();
      canvas.rotate(markerRotation - 90);
      canvas.drawLine(
          (float) (mThumbPosX + mThumbRadius / 2 * 1.4),
          mThumbPosY,
          (float) (mThumbPosX - mThumbRadius / 2 * 1.4),
          mThumbPosY,
          mMarkerColorPaint);
      canvas.restore();
    }

    if (isThumbEnabled()) {
      // draw the thumb square at the correct rotated position
      canvas.save();
      canvas.rotate(progressRotation - 90);
      // rotate the square by 45 degrees
      canvas.rotate(45, mThumbPosX, mThumbPosY);
      mSquareRect.left = mThumbPosX - mThumbRadius / 3;
      mSquareRect.right = mThumbPosX + mThumbRadius / 3;
      mSquareRect.top = mThumbPosY - mThumbRadius / 3;
      mSquareRect.bottom = mThumbPosY + mThumbRadius / 3;
      canvas.drawRect(mSquareRect, mThumbColorPaint);
      canvas.restore();
    }
  }