本文整理匯總了Java中android.graphics.PathMeasure類的典型用法代碼示例。如果您正苦於以下問題:Java PathMeasure類的具體用法?Java PathMeasure怎麽用?Java PathMeasure使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PathMeasure類屬於android.graphics包,在下文中一共展示了PathMeasure類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PathInterpolatorGingerbread
import android.graphics.PathMeasure; //導入依賴的package包/類
public PathInterpolatorGingerbread(Path path) {
final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);
final float pathLength = pathMeasure.getLength();
final int numPoints = (int) (pathLength / PRECISION) + 1;
mX = new float[numPoints];
mY = new float[numPoints];
final float[] position = new float[2];
for (int i = 0; i < numPoints; ++i) {
final float distance = (i * pathLength) / (numPoints - 1);
pathMeasure.getPosTan(distance, position, null /* tangent */);
mX[i] = position[0];
mY[i] = position[1];
}
}
示例2: onDraw
import android.graphics.PathMeasure; //導入依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.translate(x, y);
for (int i = 0; i < pathMeasures.size(); i++) {
Path path1 = new Path();
PathMeasure pathMeasure = pathMeasures.get(i);
MyPath path = paths.get(i);
if (!isReverse) {
pathMeasure.getSegment(0, pathMeasure.getLength() * animatorValue, path1, true);
canvas.drawPath(path1, linePaint);
} else {
pathMeasure.getSegment(0, pathMeasure.getLength() * (1 - animatorValue), path1, true);
canvas.drawPath(path1, linePaint);
}
drawCircles(radiusArray.get(i), canvas, path.endPoint, path.endDirection, i);
}
drawCenterCircle(canvas);
// drawCircles(radiusArray.get(0),canvas, paths.get(0).endPoint, paths.get(0).endDirection);
}
示例3: FreshDownloadView
import android.graphics.PathMeasure; //導入依賴的package包/類
public FreshDownloadView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
circular_edge = getResources().getDimension(R.dimen.edge);
bounds = new Rect();
mTempBounds = new RectF();
publicPaint = new Paint();
path1 = new Path();
path2 = new Path();
path3 = new Path();
pathMeasure1 = new PathMeasure();
pathMeasure2 = new PathMeasure();
pathMeasure3 = new PathMeasure();
textBounds = new Rect();
parseAttrs(context.obtainStyledAttributes(attrs, R.styleable.FreshDownloadView));
initPaint();
}
示例4: initData
import android.graphics.PathMeasure; //導入依賴的package包/類
private void initData() {
defaultPadding = 2 * radius + dp2px(2);
defaultPaddingBottom = 2 * radius + dp2px(15);
defaultWidth = (int) (2 * defaultPadding + dp2px(200));
defaultHeight = (int) (defaultPadding + defaultPaddingBottom + dp2px(80));
paint = new Paint[ballCount];
for (int i = 0; i < paint.length; i++) {
paint[i] = new Paint(Paint.ANTI_ALIAS_FLAG);
paint[i].setColor(ballColor);
paint[i].setStyle(Paint.Style.FILL);
}
path = new Path();
pathMeasure = new PathMeasure();
randomBallColors = new int[ballCount];
randomRadius = new float[ballCount];
randomTransRatioX = new float[ballCount];
randomTransRatioY = new float[ballCount];
translateFraction = new float[ballCount];
translateAnim = new ValueAnimator[ballCount];
}
示例5: initRoomTempPath
import android.graphics.PathMeasure; //導入依賴的package包/類
private void initRoomTempPath(float[] data) {
mRoomTempPath.reset();
// Path path = new Path();
float pointX;
float pointY;
// 橫向
mRoomTempPath.moveTo(Xpoint + xFirstPointOffset,
getDataY(data[0], Ylabel));
mRoomTempPath.moveTo(Xpoint + xFirstPointOffset,
getDataY(data[0], Ylabel));
for (int i = 0; i < Xlabel.length; i++) {
float startX = Xpoint + i * Xscale + xFirstPointOffset;
// 繪製數據連線
if (i != 0) {
pointX = Xpoint + (i - 1) * Xscale + xFirstPointOffset;
pointY = getDataY(data[i - 1], Ylabel);
mRoomTempPath.lineTo(pointX, pointY);
}
if (i == Xlabel.length - 1) {
pointX = startX;
pointY = getDataY(data[i], Ylabel);
mRoomTempPath.lineTo(pointX, pointY);
}
}
mRoomTempPathMeasure = new PathMeasure(mRoomTempPath, false);
}
示例6: initTargetTempPath
import android.graphics.PathMeasure; //導入依賴的package包/類
/**
* 獲取target temp繪線Path數據
*
* @param data target temp繪線Path數據
*/
private void initTargetTempPath(float[] data) {
mTargetTempPath.reset();
float pointX;
float pointY;
// 橫向
mTargetTempPath.moveTo(Xpoint + xFirstPointOffset,
getDataY(data[0], Ylabel));
for (int i = 0; i < Xlabel.length; i++) {
float startX = Xpoint + i * Xscale + xFirstPointOffset;
// 繪製數據連線
if (i != 0) {
pointX = Xpoint + (i - 1) * Xscale + xFirstPointOffset;
pointY = getDataY(data[i - 1], Ylabel);
mTargetTempPath.lineTo(pointX, pointY);
}
if (i == Xlabel.length - 1) {
pointX = startX;
pointY = getDataY(data[i], Ylabel);
mTargetTempPath.lineTo(pointX, pointY);
}
}
mTargetTempPathMeasure = new PathMeasure(mTargetTempPath, false);
}
示例7: matchVertsToPath
import android.graphics.PathMeasure; //導入依賴的package包/類
public void matchVertsToPath(Path path, float bottomCoord, float extraOffset) {
PathMeasure pm = new PathMeasure(path, false);
for (int i = 0; i < staticVerts.length / 2; i++) {
float yIndexValue = staticVerts[i * 2 + 1];
float xIndexValue = staticVerts[i * 2];
float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
percentOffsetX2 += pathOffsetPercent;
pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);
if (yIndexValue == 0) {
setXY(drawingVerts, i, coords[0], coords2[1]);
} else {
float desiredYCoord = bottomCoord;
setXY(drawingVerts, i, coords[0], desiredYCoord);
}
}
}
示例8: matchVertsToPath
import android.graphics.PathMeasure; //導入依賴的package包/類
public void matchVertsToPath(Path path, float extraOffset) {
PathMeasure pm = new PathMeasure(path, false);
int index = 0;
for (int i = 0; i < staticVerts.length / 2; i++) {
float yIndexValue = staticVerts[i * 2 + 1];
float xIndexValue = staticVerts[i * 2];
float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
percentOffsetX2 += pathOffsetPercent;
pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);
if (yIndexValue == 0) {
setXY(drawingVerts, i, coords[0], coords2[1] + verticalOffset);
} else {
float desiredYCoord = Math.max(coords2[1], coords2[1] + easedFoamCoords[Math.min(easedFoamCoords.length - 1, index)]);
setXY(drawingVerts, i, coords[0], desiredYCoord + verticalOffset);
index += 1;
}
}
}
示例9: getValue
import android.graphics.PathMeasure; //導入依賴的package包/類
@Override public PointF getValue(Keyframe<PointF> keyframe, float keyframeProgress) {
PathKeyframe pathKeyframe = (PathKeyframe) keyframe;
Path path = pathKeyframe.getPath();
if (path == null) {
return keyframe.startValue;
}
if (pathMeasureKeyframe != pathKeyframe) {
pathMeasure = new PathMeasure(path, false);
pathMeasureKeyframe = pathKeyframe;
}
pathMeasure.getPosTan(keyframeProgress * pathMeasure.getLength(), pos, null);
point.set(pos[0], pos[1]);
return point;
}
示例10: SunnyType
import android.graphics.PathMeasure; //導入依賴的package包/類
public SunnyType(Context context, ShortWeatherInfo info) {
super(context);
mPathFront = new Path();
mPathRear = new Path();
sunPath = new Path();
mPaint = new Paint();
pos = new float[2];
tan = new float[2];
mMatrix = new Matrix();
measure = new PathMeasure();
sunMeasure = new PathMeasure();
currentSunPosition = TimeUtils.getTimeDiffPercent(info.getSunrise(), info.getSunset());
currentMoonPosition = TimeUtils.getTimeDiffPercent(info.getMoonrise(), info.getMoonset());
if (currentSunPosition >= 0 && currentSunPosition <= 1) {
setColor(colorDay);
boat = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ic_boat_day);
} else {
setColor(colorNight);
boat = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ic_boat_night);
}
cloud = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ic_cloud);
}
示例11: RainType
import android.graphics.PathMeasure; //導入依賴的package包/類
public RainType(Context context, @RainLevel int rainLevel, @WindLevel int windLevel) {
super(context);
setColor(0xFF6188DA);
this.rainLevel = rainLevel;
this.windLevel = windLevel;
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(Color.WHITE);
mPaint.setStrokeWidth(5);
mPaint.setStyle(Paint.Style.STROKE);
mRains = new ArrayList<>();
mSnows = new ArrayList<>();
matrix = new Matrix();
bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_rain_ground);
mDstFlash1 = new Path();
flashPathMeasure1 = new PathMeasure();
mDstFlash2 = new Path();
flashPathMeasure2 = new PathMeasure();
mDstFlash3 = new Path();
flashPathMeasure3 = new PathMeasure();
}
示例12: setPos
import android.graphics.PathMeasure; //導入依賴的package包/類
/**
* 用來給每一個button設置一個中心點
*
* @param orbit 一個特定角度的path
*/
private void setPos(Path orbit) {
PathMeasure measure = new PathMeasure(orbit, false);
TextLableView tv;
for (int i = 0; i < mButtons.size(); i++) {
PopupButton pp = mButtons.get(i);
tv = kvs.get(pp);
float[] coords = new float[]{0f, 0f};
int length = (int) ((i) * measure.getLength() / mButtons.size());
measure.getPosTan(length, coords, null);
int px = (int) coords[0] - pp.getMeasuredWidth() / 2;
int py = (int) coords[1] - pp.getMeasuredHeight() / 2;
int tvx = (int) coords[0] - tv.getMeasuredWidth() / 2;
tv.x = tvx;
tv.y = py - 60;
pp.x = px;
pp.y = py;
}
}
示例13: PathInterpolatorDonut
import android.graphics.PathMeasure; //導入依賴的package包/類
public PathInterpolatorDonut(Path path) {
final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);
final float pathLength = pathMeasure.getLength();
final int numPoints = (int) (pathLength / PRECISION) + 1;
mX = new float[numPoints];
mY = new float[numPoints];
final float[] position = new float[2];
for (int i = 0; i < numPoints; ++i) {
final float distance = (i * pathLength) / (numPoints - 1);
pathMeasure.getPosTan(distance, position, null /* tangent */);
mX[i] = position[0];
mY[i] = position[1];
}
}
示例14: init
import android.graphics.PathMeasure; //導入依賴的package包/類
private void init() {
borderPaint = new Paint();
borderPaint.setColor(borderColor);
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setStrokeWidth(borderWidth);
rectPaint = new Paint();
rectPaint.setColor(rectColor);
rectPaint.setStyle(Paint.Style.FILL);
linePaint = new Paint();
linePaint.setAntiAlias(true);
linePaint.setColor(lineColor);
linePaint.setStyle(Paint.Style.STROKE);
linePaint.setStrokeWidth(lineWidth);
linePaint.setStrokeJoin(Paint.Join.ROUND);
textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setColor(textColor);
textPaint.setTextSize(textSize);
fm = textPaint.getFontMetrics();
path = new Path();
pathDst = new Path();
pm = new PathMeasure();
selectedIndex = -1;
}
示例15: init
import android.graphics.PathMeasure; //導入依賴的package包/類
private void init(int selectedBgColor, float pointStrokeWidth, int pathColor, float pathWidth) {
pointPaint = new Paint();
pointPaint.setAntiAlias(true);
pointPaint.setColor(pointColor);
pointPaint.setStrokeWidth(pointStrokeWidth);
pointPaint.setStyle(Paint.Style.STROKE);
pathPaint = new Paint();
pathPaint.setAntiAlias(true);
pathPaint.setColor(pathColor);
pathPaint.setStrokeWidth(pathWidth);
pathPaint.setStyle(Paint.Style.STROKE);
selectedBgPaint = new Paint();
selectedBgPaint.setAntiAlias(true);
selectedBgPaint.setColor(selectedBgColor);
selectedBgPaint.setStrokeWidth(0);
selectedBgPaint.setStyle(Paint.Style.FILL);
selectedBgPaint.setAlpha(100);
path = new Path();
pathDst = new Path();
pm = new PathMeasure();
rectOval = new RectF();
selectedIndex = -1;
}