當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。