本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}