當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.drawTextOnPath方法代碼示例

本文整理匯總了Java中android.graphics.Canvas.drawTextOnPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.drawTextOnPath方法的具體用法?Java Canvas.drawTextOnPath怎麽用?Java Canvas.drawTextOnPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.drawTextOnPath方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawOutSideText

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawOutSideText(Canvas canvas) {
    Paint textPaint = new Paint();
    textPaint.setColor(this.mNormalGray);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
    int radius = getViewRadius() - this.mDividerWidth;
    Path path = new Path();
    path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
    if (this.mDividerIndicator.size() != 0) {
        String content = BaseCircle.formatNumber(this.mStartIndicator);
        canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float) radius,
                135.0f) - ((float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f,
                textPaint);
        float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
        for (IndicatorItem item : this.mDividerIndicator) {
            content = BaseCircle.formatNumber(item.end);
            canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float)
                    radius, ((item.end - this.mStartIndicator) * perAngle) + 135.0f) - (
                    (float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f, textPaint);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:CircleIndicator.java

示例2: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, Position position) {
    // as long as there is no new data, we don't need to draw anything.
    if (mStaleData) {
        return;
    }

    float lastPos = 0;
    for(int i = 0; i < mClockText.length(); i++) {
        canvas.drawTextOnPath("" + mClockText.charAt(i), mClockPath, lastPos, 0, mClockPaint);
        lastPos += mClockTextDisplacements[i];
    }

    if (mNetworkState != null) {
        canvas.drawTextOnPath(mNetworkState, mInfoPath[3], 0, 0, mInfoPaint);
    }
    canvas.drawTextOnPath(mDateText, mInfoPath[2], 0, 0, mInfoPaint);
    canvas.drawTextOnPath(mBatteryLevelReadable, mInfoPath[1], 0, 0, mInfoPaint);
    canvas.drawTextOnPath(mWifiSsid, mInfoPath[0], 0, 0, mInfoPaint);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:21,代碼來源:PieSysInfo.java

示例3: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    if(points.size() == 0) {
        points.add(getWidth() / 2.f);
        points.add(getHeight() / 2.f);
    }

    while(points.size() - currentIndex >= 6) {
        float x1 = points.get(currentIndex);
        float y1 = points.get(currentIndex + 1);

        float x2 = points.get(currentIndex + 2);
        float y2 = points.get(currentIndex + 3);

        float x3 = points.get(currentIndex + 4);
        float y3 = points.get(currentIndex + 5);

        if (currentIndex == 0) path.moveTo(x1, y1);
        path.cubicTo(x1, y1, x2, y2, x3, y3);
        currentIndex += 6;
    }

    canvas.drawColor(BACKGROUND_COLOR);
    canvas.drawPath(path, pathPaint);

    for(int i = 0; i < points.size() / 2; i++) {
        float x = points.get(i * 2    );
        float y = points.get(i * 2 + 1);
        canvas.drawPoint(x, y, pointsPaint);
    }

    canvas.drawTextOnPath("Building Android UIs with Custom Views", path, 0, 0, pathPaint);
}
 
開發者ID:PacktPublishing,項目名稱:Building-Android-UIs-with-Custom-Views,代碼行數:34,代碼來源:PrimitiveDrawer.java

示例4: drawCircleContent

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawCircleContent(Canvas canvas, IndicatorItem item, RectF oval, float perAngle,
                               float textRadius, Path path, Paint textPaint, Paint
                                       circlePaint) {
    circlePaint.setColor(item.color);
    float startAngle = 135.0f + ((item.start - this.mStartIndicator) * perAngle);
    float endAngle = perAngle * (item.end - item.start);
    canvas.drawArc(oval, startAngle, endAngle, false, circlePaint);
    Canvas canvas2 = canvas;
    canvas2.drawTextOnPath(String.valueOf(item.value), path, ViewUtils.getCirclePathLength
            (textRadius, (endAngle / 2.0f) + startAngle) - ((float) (ViewUtils.getTextWidth
            (textPaint, item.value) / 2)), 0.0f, textPaint);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:CircleIndicator.java

示例5: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
public void onDraw(Canvas canvas, int measuredWidth, int measuredHeight) {
    if (!visual || text == null) {
        return;
    }

    float actualDistance = distance + height / 2;
    calcOffset(measuredWidth, measuredHeight);

    rectPaint.setColor(backgroundColor);
    if (alpha != 0) {
        rectPaint.setAlpha(alpha);
    }

    rectStrokePaint.setColor(strokeColor);
    rectStrokePaint.setStrokeWidth(strokeWidth);

    canvas.drawPath(rectPath, rectPaint);
    canvas.drawPath(rectPath, rectStrokePaint);

    textPaint.setTextSize(textSize);
    textPaint.setColor(textColor);
    textPaint.getTextBounds(text, 0, text.length(), textBound);
    textPaint.setTypeface(Typeface.defaultFromStyle(textStyle));

    float begin_w_offset = (1.4142135f * actualDistance) / 2 - textBound.width() / 2;
    if (begin_w_offset < 0) begin_w_offset = 0;

    canvas.drawTextOnPath(text, textPath, begin_w_offset, textBound.height() / 2, textPaint);
}
 
開發者ID:open-android,項目名稱:labelview,代碼行數:30,代碼來源:LabelViewHelper.java

示例6: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    if (isRotatableSet) {
        if (rotatable.isUpdated()) {
            updatePaint();
            rotatable.setUpdated(false);
        }
        String text = currentText;
        if (rotatable.getPathIn() != null)
            canvas.drawTextOnPath(text, rotatable.getPathIn(), 0.0f, 0.0f, paint);
        if (rotatable.getPathOut() != null)
            canvas.drawTextOnPath(rotatable.getPreviousWord(), rotatable.getPathOut(), 0.0f, 0.0f, paint);
    }
}
 
開發者ID:sdsmdg,項目名稱:RotatingText,代碼行數:15,代碼來源:RotatingTextSwitcher.java

示例7: drawText

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawText(Canvas canvas, String text)
{
	this.mHeight = getHeight();
	this.mPath.moveTo(getWidth() - (2.0F * getResources().getDisplayMetrics().density), this.mHeight);
	this.mPath.lineTo(getWidth() - (2.0F * getResources().getDisplayMetrics().density), 0.0F);
	canvas.drawTextOnPath(text, this.mPath, 0.0F, 0.0F, this.mPaint);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:8,代碼來源:VerticalTextView.java

示例8: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    //計算路徑
    calculatePath(getMeasuredWidth(), getMeasuredHeight());
    canvas.drawPath(pathBackground, backgroundPaint);
    canvas.drawTextOnPath("Hot", pathText, 100, -20, textPaint);
}
 
開發者ID:guoxiaoxing,項目名稱:android-open-source-project-analysis,代碼行數:9,代碼來源:LabelImageView.java

示例9: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, Paint paint, float opacity) {
  if (mFrame == null) {
    return;
  }
  opacity *= mOpacity;
  if (opacity <= MIN_OPACITY_FOR_DRAW) {
    return;
  }
  if (!mFrame.hasKey(PROP_LINES)) {
    return;
  }
  ReadableArray linesProp = mFrame.getArray(PROP_LINES);
  if (linesProp == null || linesProp.size() == 0) {
    return;
  }

  // only set up the canvas if we have something to draw
  saveAndSetupCanvas(canvas);
  String[] lines = new String[linesProp.size()];
  for (int i = 0; i < lines.length; i++) {
    lines[i] = linesProp.getString(i);
  }
  String text = TextUtils.join("\n", lines);
  if (setupStrokePaint(paint, opacity)) {
    applyTextPropertiesToPaint(paint);
    if (mPath == null) {
      canvas.drawText(text, 0, -paint.ascent(), paint);
    } else {
      canvas.drawTextOnPath(text, mPath, 0, 0, paint);
    }
  }
  if (setupFillPaint(paint, opacity)) {
    applyTextPropertiesToPaint(paint);
    if (mPath == null) {
      canvas.drawText(text, 0, -paint.ascent(), paint);
    } else {
      canvas.drawTextOnPath(text, mPath, 0, 0, paint);
    }
  }
  restoreCanvas(canvas);
  markUpdateSeen();
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:44,代碼來源:ARTTextShadowNode.java


注:本文中的android.graphics.Canvas.drawTextOnPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。