当前位置: 首页>>代码示例>>Java>>正文


Java PathMeasure.getSegment方法代码示例

本文整理汇总了Java中android.graphics.PathMeasure.getSegment方法的典型用法代码示例。如果您正苦于以下问题:Java PathMeasure.getSegment方法的具体用法?Java PathMeasure.getSegment怎么用?Java PathMeasure.getSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.PathMeasure的用法示例。


在下文中一共展示了PathMeasure.getSegment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
    }
 
开发者ID:yangjingsong,项目名称:AndroidRelationshipView,代码行数:23,代码来源:RelationshipView.java

示例2: drawTick

import android.graphics.PathMeasure; //导入方法依赖的package包/类
public void drawTick(Canvas canvas) {
    mBgPaint.setColor(mProgressColor);
    canvas.drawRoundRect(mOvalRect, mRadius, mRadius, mBgPaint);

    //draw left
    mLeftPath.moveTo(mWidth / 2, mHeight * 3 / 4);
    mLeftPath.lineTo(mWidth / 2 - mHeight / 4, mHeight * 3 / 5);

    mLeftPathMeasure = new PathMeasure(mLeftPath, true);
    Path leftDst = new Path();
    float leftStop = mLeftPathMeasure.getLength() * mAnimationValue;
    mLeftPathMeasure.getSegment(0, leftStop, leftDst, true);
    canvas.drawPath(leftDst, mTickPaint);


    //draw right
    mRightPath.moveTo(mWidth / 2, mHeight * 3 / 4);
    mRightPath.lineTo(mWidth / 2 + mHeight / 4, mHeight / 4);

    mRightPathMeasure = new PathMeasure(mRightPath, true);
    Path rightDst = new Path();
    float rightStop = mRightPathMeasure.getLength() * mAnimationValue;
    mRightPathMeasure.getSegment(0, rightStop, rightDst, true);
    canvas.drawPath(rightDst, mTickPaint);


    //some devices do not support pathmeasure
    if (mIsDone) {
        canvas.drawPath(mLeftPath, mTickPaint);
        canvas.drawPath(mRightPath, mTickPaint);
    }


}
 
开发者ID:arjinmc,项目名称:AndroidButtonLib,代码行数:35,代码来源:DownloadButton.java

示例3: drawLine

import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
 * 绘制曲线
 *
 * @param canvas
 */
private void drawLine(Canvas canvas) {
    if (isPlayAnim) {
        Path dst = new Path();
        PathMeasure measure = new PathMeasure(linePath, false);
        measure.getSegment(0, currentValue * measure.getLength(), dst, true);
        canvas.drawPath(dst, linePaint);
    } else {
        canvas.drawPath(linePath, linePaint);
    }
}
 
开发者ID:jeanboydev,项目名称:Android-LineChart,代码行数:16,代码来源:LineChartView.java

示例4: run

import android.graphics.PathMeasure; //导入方法依赖的package包/类
public void run() {
	
	System.out.println("Stroke nums:"+vp.size());
	for(int i=0;i<vp.size();++i)
	{
	
	//	System.out.println("Haha");
	//	seg.set(vp.get(i));
		
		
		PathMeasure pm=new PathMeasure(vp.get(i),false);
	    float len=pm.getLength();
	    System.out.println("Len:"+len);
	    float start=0.0f,end;
	    float delta=1.0f;
	        while(start<len)
	    	{
	    	   end=min(start+delta,len);
	    	   seg.reset();
	    	   pm.getSegment(start, end, seg,true);
				matrix.reset();
			//	matrix.setScale(sx, sy);
				//matrix.postScale(sx, sy, dx,dy);
				seg.transform(matrix);
				mCanvas.drawPath(seg, mPaint);
	    	    start+=delta;
	    	    
	    	//   System.out.println("hello")
	    	    			    	   try{
				   Message msg=handler.obtainMessage();
	    			msg.arg1=0;
	    	        handler.sendMessage(msg);
		    	   Thread.sleep(30);
		    	   }
		    	   catch(Exception e){

		    	   }
		    	   finally{
		    		   
		    	   }
	    	}

	}


}
 
开发者ID:limitfan,项目名称:Simple-Japanese-Gojuon,代码行数:47,代码来源:ActKana.java

示例5: onDraw

import android.graphics.PathMeasure; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mPaint.setColor(getResources().getColor(R.color.colorAccent));
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(10);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setAntiAlias(true);

    canvas.save();
    canvas.translate(mWidth / 2, mHeight / 2);

    // Path 直线操作
    Path path = new Path();
    path.lineTo(200, 200);
    path.setLastPoint(200, 100);
    path.lineTo(200, 0);
    path.close();
    path.moveTo(400, 200);
    path.lineTo(400, 0);
    path.addRect(-300, -300, 300, 300, Path.Direction.CCW);
    path.setLastPoint(-400, 400);

    canvas.drawPath(path, mPaint);

    // Path 基本图形操作
    mPaint.setColor(getResources().getColor(R.color.colorPrimary));
    Path path1 = new Path();
    Path path2 = new Path();
    path1.addRect(-100, -100, 100, 100, Path.Direction.CW);
    path2.addCircle(0, 0, 100, Path.Direction.CW);
    path1.addPath(path2, 0, -100);

    canvas.drawPath(path1, mPaint);

    // Path 弧线操作
    RectF rectF = new RectF(0, -400, 100, -300);
    Path path3 = new Path();
    path3.moveTo(0, -300);
    path3.lineTo(100, -200);
    path3.arcTo(rectF, 180, 180, true);

    canvas.drawPath(path3, mPaint);

    Path path4 = new Path();
    Path path5 = new Path();
    path4.addCircle(0, -600, 100, Path.Direction.CW);
    path5.addRect(-100, -700, 100, -500, Path.Direction.CW);
    path4.offset(100, 0, path5); // offset(float dx, float dy, Path dst) 中的 dx 和 dy 是偏移量,不是绝对量

    canvas.drawPath(path4, mPaint);
    mPaint.setColor(getResources().getColor(R.color.colorAccent));
    canvas.drawPath(path5, mPaint);

    Path path6 = new Path();
    path6.addCircle(0, 0, 300, Path.Direction.CW);
    PathMeasure pathMeasure = new PathMeasure();
    pathMeasure.setPath(path6, false);
    Path dst = new Path();
    pathMeasure.getSegment(pathMeasure.getLength() * 1.2f, pathMeasure.getLength() * 1.5f, dst, true);
    canvas.drawPath(dst, mPaint);

}
 
开发者ID:Codpoe,项目名称:Learn,代码行数:64,代码来源:LearnView.java

示例6: drawText

import android.graphics.PathMeasure; //导入方法依赖的package包/类
protected void drawText(float scaledWidth, Path mainPath, GISDisplay display) {
    if (TextUtils.isEmpty(mText) || mainPath == null)
        return;

    Paint textPaint = new Paint();
    textPaint.setColor(mOutColor);
    textPaint.setAntiAlias(true);
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setStrokeCap(Paint.Cap.ROUND);
    textPaint.setStrokeWidth(scaledWidth);

    float textSize = 12 * scaledWidth;
    textPaint.setTextSize(textSize);
    float textWidth = textPaint.measureText(mText);
    float vOffset = (float) (textSize / 2.7);

    // draw text along the main path
    PathMeasure pm = new PathMeasure(mainPath, false);
    float length = pm.getLength();
    float gap = textPaint.measureText("_");
    float period = textWidth + gap;
    float startD = gap;
    float stopD = startD + period;

    Path textPath = new Path();

    while (stopD < length) {
        textPath.reset();
        pm.getSegment(startD, stopD, textPath, true);
        textPath.rLineTo(0, 0); // workaround for API <= 19

        display.drawTextOnPath(mText, textPath, 0, vOffset, textPaint);

        startD += period;
        stopD += period;
    }

    stopD = startD;
    float rest = length - stopD;

    if (rest > gap * 2) {
        stopD = length - gap;

        textPath.reset();
        pm.getSegment(startD, stopD, textPath, true);
        textPath.rLineTo(0, 0); // workaround for API <= 19

        display.drawTextOnPath(mText, textPath, 0, vOffset, textPaint);
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:51,代码来源:SimpleLineStyle.java

示例7: getRestLength

import android.graphics.PathMeasure; //导入方法依赖的package包/类
private float getRestLength(Path path, float startD) {
    Path tempPath = new Path();
    PathMeasure pathMeasure = new PathMeasure(path, false);

    pathMeasure.getSegment(startD, pathMeasure.getLength(), tempPath, true);

    pathMeasure.setPath(tempPath, false);

    return pathMeasure.getLength();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:CircleBroodLoadingRenderer.java

示例8: testGetSegment

import android.graphics.PathMeasure; //导入方法依赖的package包/类
private void testGetSegment(Canvas canvas, boolean startWithMoveTo) {

        Path path = new Path();                                     // 创建Path并添加了一个矩形
        path.addRect(-200, -200, 200, 200, Path.Direction.CW);

        Path dst = new Path();                                      // 创建用于存储截取后内容的 Path
        dst.lineTo(-300, -300);                                     // <--- 在 dst 中添加一条线段

        PathMeasure measure = new PathMeasure(path, false);         // 将 Path 与 PathMeasure 关联

        measure.getSegment(200, 600, dst, startWithMoveTo);                   // 截取一部分 并使用 moveTo 保持截取得到的 Path 第一个点的位置不变

        canvas.drawPath(dst, mDeafultPaint);
    }
 
开发者ID:luhaoaimama1,项目名称:zone-sdk,代码行数:15,代码来源:PathMeasureView.java


注:本文中的android.graphics.PathMeasure.getSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。