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


Java Path.lineTo方法代码示例

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


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

示例1: drawPolygon

import android.graphics.Path; //导入方法依赖的package包/类
private void drawPolygon(Canvas canvas) {
    Path path = new Path();
    for (int i = 0; i < loopCount; i++) {
        path.reset();
        //依据最大半径和角度来判断每一层点的位置
        float rate = computeRate(i + 1, loopCount);
        for (int j = 0; j < eageCount; j++) {
            float currentX = maxPointXList.get(j) * rate;
            float currentY = maxPointYList.get(j) * rate;
            if (j == 0) {
                path.moveTo(currentX, currentY);
            } else {
                path.lineTo(currentX, currentY);
            }
        }
        path.close();
        canvas.drawPath(path, eagePaint);
    }
}
 
开发者ID:TotoroXkf,项目名称:MyPolygonView,代码行数:20,代码来源:PolygonView.java

示例2: generatePath

import android.graphics.Path; //导入方法依赖的package包/类
public static Path generatePath(RectF rect, float topLeftDiameter, float topRightDiameter, float bottomRightDiameter, float bottomLeftDiameter){
    final Path path = new Path();

    topLeftDiameter = topLeftDiameter < 0 ? 0 : topLeftDiameter;
    topRightDiameter = topRightDiameter < 0 ? 0 : topRightDiameter;
    bottomLeftDiameter = bottomLeftDiameter < 0 ? 0 : bottomLeftDiameter;
    bottomRightDiameter = bottomRightDiameter < 0 ? 0 : bottomRightDiameter;

    path.moveTo(rect.left + topLeftDiameter/2 ,rect.top);
    path.lineTo(rect.right - topRightDiameter/2,rect.top);
    path.quadTo(rect.right, rect.top, rect.right, rect.top + topRightDiameter/2);
    path.lineTo(rect.right ,rect.bottom - bottomRightDiameter/2);
    path.quadTo(rect.right ,rect.bottom, rect.right - bottomRightDiameter/2, rect.bottom);
    path.lineTo(rect.left + bottomLeftDiameter/2,rect.bottom);
    path.quadTo(rect.left,rect.bottom,rect.left, rect.bottom - bottomLeftDiameter/2);
    path.lineTo(rect.left,rect.top + topLeftDiameter/2);
    path.quadTo(rect.left,rect.top, rect.left + topLeftDiameter/2, rect.top);
    path.close();

    return path;
}
 
开发者ID:florent37,项目名称:MyLittleCanvas,代码行数:22,代码来源:RoundRect.java

示例3: Swipte

import android.graphics.Path; //导入方法依赖的package包/类
public void Swipte(int x1,int y1,int x2,int y2,int time){
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
            Log.e(TAG,"Swipte");

            GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
            Path path = new Path();
            path.moveTo(x1,y1);
            path.lineTo(x2,y2);
//            if (event.getText() != null && event.getText().toString().contains("1")) {
//                //Swipe left
//                path.moveTo(rightSizeOfScreen, middleYValue);
//                path.lineTo(leftSideOfScreen, middleYValue);
//            } else {
//                //Swipe right
//                path.moveTo(leftSideOfScreen, middleYValue);
//                path.lineTo(rightSizeOfScreen, middleYValue);
//            }

            gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, time));
            dispatchGesture(gestureBuilder.build(), new GestureResultCallback() {
                @Override
                public void onCompleted(GestureDescription gestureDescription) {

                    super.onCompleted(gestureDescription);
                }
            }, null);
        }

    }
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:30,代码来源:HelpService.java

示例4: buildFiguresUsingTriangles

import android.graphics.Path; //导入方法依赖的package包/类
private void buildFiguresUsingTriangles(List<PointF> angles, double startAngle, double distanceFromCenter) {
    for (int i = 0; i < angles.size(); i++) {

        double angle1 = startAngle + i * (360.0 / numberOfAngles);
        double angle2 = startAngle + (i + 1) * (360.0 / numberOfAngles);
        double angle = (angle1 + angle2) / 2;
        float newCenterX = (float) (distanceFromCenter * Math.cos(Math.toRadians(angle)));
        float newCenterY = (float) (distanceFromCenter * Math.sin(Math.toRadians(angle)));

        Path path = new Path();
        path.moveTo(newCenterX + center.x, newCenterY + center.y);
        path.lineTo(newCenterX + angles.get(i).x, newCenterY + angles.get(i).y);
        if (i >= (angles.size() - 1)) {
            path.lineTo(newCenterX + angles.get(0).x, newCenterY + angles.get(0).y);
        } else {
            path.lineTo(newCenterX + angles.get(i + 1).x, newCenterY + angles.get(i + 1).y);
        }
        path.lineTo(newCenterX + center.x, newCenterY + center.y);
        path.close();

        figures.add(new Figure(path, color, isInEditMode() ? (int) (25.0 + i * (230.0 / numberOfAngles)) : 0));
    }
}
 
开发者ID:vbohush,项目名称:geometric-progress-view,代码行数:24,代码来源:GeometricProgressView.java

示例5: onSizeChanged

import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    int value = outLineWidth / 2;
    mOuterRectF.set(value, value, w - value, h - value);
    int gap = lineWidth / 2 + outLineWidth + gapWidth;

    mRectF.set(mOuterRectF.left + gap,
            mOuterRectF.top + gap,
            mOuterRectF.right - gap,
            mOuterRectF.bottom - gap);

    centerX = mRectF.centerX();
    centerY = mRectF.centerY();

    mPointerPath = new Path();
    mPointerPath.moveTo(centerX + pointRadius, centerY - 7);
    mPointerPath.lineTo(centerX + pointRadius, centerY + 7);
    mPointerPath.lineTo(mRectF.right - pointGap - lineWidth / 2, centerY);
    mPointerPath.lineTo(centerX + pointRadius, centerY - 7);
    mPointerPath.close();
}
 
开发者ID:SailFlorve,项目名称:RunHDU,代码行数:24,代码来源:GradeProgressView.java

示例6: rightPath

import android.graphics.Path; //导入方法依赖的package包/类
public void rightPath(RectF rect, Path path) {
    path.moveTo(mAngle, rect.top);
    path.lineTo(rect.width(), rect.top);
    path.arcTo(new RectF(rect.right - mAngle * 2 - mArrowWidth, rect.top,
            rect.right - mArrowWidth, mAngle * 2 + rect.top), 270, 90);
    path.lineTo(rect.right - mArrowWidth, mArrowTop);
    path.lineTo(rect.right, mArrowTop - mArrowOffset);
    path.lineTo(rect.right - mArrowWidth, mArrowTop + mArrowHeight);
    path.lineTo(rect.right - mArrowWidth, rect.height() - mAngle);
    path.arcTo(new RectF(rect.right - mAngle * 2 - mArrowWidth, rect.bottom
            - mAngle * 2, rect.right - mArrowWidth, rect.bottom), 0, 90);
    path.lineTo(rect.left, rect.bottom);
    path.arcTo(new RectF(rect.left, rect.bottom - mAngle * 2, mAngle * 2
            + rect.left, rect.bottom), 90, 90);
    path.lineTo(rect.left, rect.top);
    path.arcTo(new RectF(rect.left, rect.top, mAngle * 2 + rect.left,
            mAngle * 2 + rect.top), 180, 90);
    path.close();
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:20,代码来源:BubbleImageView.java

示例7: drawLeftBottom

import android.graphics.Path; //导入方法依赖的package包/类
private void drawLeftBottom(Canvas canvas) {

        // 初始化数据点和控制点的位置
        start.x = 0;
        start.y = mHeight - mCornerRadius;
        end.x = mCornerRadius;
        end.y = mHeight;
        control.x = 0;
        control.y = mHeight;

        Path leftBottom = new Path();
        leftBottom.moveTo(0,mHeight);
        leftBottom.lineTo(0,mHeight - mCornerRadius);
        leftBottom.quadTo(control.x,control.y,end.x,end.y);
        leftBottom.lineTo(0,mHeight);
        canvas.drawPath(leftBottom,mPaint);
    }
 
开发者ID:jiajunhui,项目名称:PlayerBase,代码行数:18,代码来源:CornerCutView.java

示例8: createBottlePath

import android.graphics.Path; //导入方法依赖的package包/类
private Path createBottlePath(RectF bottleRect) {
    float bottleneckWidth = bottleRect.width() * 0.3f;
    float bottleneckHeight = bottleRect.height() * 0.415f;
    float bottleneckDecorationWidth = bottleneckWidth * 1.1f;
    float bottleneckDecorationHeight = bottleneckHeight * 0.167f;

    Path path = new Path();
    //draw the left side of the bottleneck decoration
    path.moveTo(bottleRect.centerX() - bottleneckDecorationWidth * 0.5f, bottleRect.top);
    path.quadTo(bottleRect.centerX() - bottleneckDecorationWidth * 0.5f - bottleneckWidth * 0.15f, bottleRect.top + bottleneckDecorationHeight * 0.5f,
            bottleRect.centerX() - bottleneckWidth * 0.5f, bottleRect.top + bottleneckDecorationHeight);
    path.lineTo(bottleRect.centerX() - bottleneckWidth * 0.5f, bottleRect.top + bottleneckHeight);

    //draw the left side of the bottle's body
    float radius = (bottleRect.width() - mStrokeWidth) / 2.0f;
    float centerY = bottleRect.bottom - 0.86f * radius;
    RectF bodyRect = new RectF(bottleRect.left, centerY - radius, bottleRect.right, centerY + radius);
    path.addArc(bodyRect, 255, -135);

    //draw the bottom of the bottle
    float bottleBottomWidth = bottleRect.width() / 2.0f;
    path.lineTo(bottleRect.centerX() - bottleBottomWidth / 2.0f, bottleRect.bottom);
    path.lineTo(bottleRect.centerX() + bottleBottomWidth / 2.0f, bottleRect.bottom);

    //draw the right side of the bottle's body
    path.addArc(bodyRect, 60, -135);

    //draw the right side of the bottleneck decoration
    path.lineTo(bottleRect.centerX() + bottleneckWidth * 0.5f, bottleRect.top + bottleneckDecorationHeight);
    path.quadTo(bottleRect.centerX() + bottleneckDecorationWidth * 0.5f + bottleneckWidth * 0.15f, bottleRect.top + bottleneckDecorationHeight * 0.5f,
            bottleRect.centerX() + bottleneckDecorationWidth * 0.5f, bottleRect.top);

    return path;
}
 
开发者ID:ZhuoKeTeam,项目名称:JueDiQiuSheng,代码行数:35,代码来源:WaterBottleLoadingRenderer.java

示例9: drawLines

import android.graphics.Path; //导入方法依赖的package包/类
/**
 * 绘制直线
 */
private void drawLines(Canvas canvas) {
    Path path = new Path();
    for (int i = 0; i < count; i++) {
        path.reset();
        path.moveTo(centerX, centerY);
        float x = (float) (centerX + radius * Math.cos(angle * i));
        float y = (float) (centerY + radius * Math.sin(angle * i));
        path.lineTo(x, y);
        canvas.drawPath(path, mainPaint);
    }
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:15,代码来源:RadarView.java

示例10: drawDataSet

import android.graphics.Path; //导入方法依赖的package包/类
private void drawDataSet(Canvas canvas, final LineDataSet lineDataSet,
    float lMax, float lMin, float rMax, float rMin) {

    mRenderPaint.setStrokeWidth(lineDataSet.getLineThickness());
    mRenderPaint.setColor(lineDataSet.getColor());

    int valueCount = lineDataSet.getEntryCount();

    Path path = new Path();
    path.reset();
    boolean isFirst = true;

    float min, max;
    switch (lineDataSet.getAxisDependency()) {
        case AxisY.DEPENDENCY_RIGHT:
            min = rMin;
            max = rMax;
            break;
        case AxisY.DEPENDENCY_BOTH:
        case AxisY.DEPENDENCY_LEFT:
        default:
            min = lMin;
            max = lMax;
            break;
    }

    final int count = lineDataSet.getVisibleValueCount(mViewport);
    float width = 0;
    if (count > 0) {
        width = mContentRect.width() / ((float) count);
    }

    for (int i = 0; i < valueCount && i < lineDataSet.getValues().size(); i++) {
        PointValue point = lineDataSet.getEntryForIndex(i);

        if (Float.isNaN(point.getValue())) {
            continue;
        }

        float xPosition = width * 0.5f + getDrawX(i / ((float) valueCount));
        float yPosition = (max - point.getValue()) / (max - min) * mContentRect.height();

        point.setCoordinate(xPosition, yPosition);

        if (isFirst) {
            isFirst = false;
            path.moveTo(xPosition, yPosition);
        } else  {
            path.lineTo(xPosition, yPosition);
        }
    }

    // draw shader area
    if (lineDataSet.getShader() != null && lineDataSet.getValues().size() > 0) {
        mRenderPaint.setStyle(Paint.Style.FILL);
        Path shaderPath = new Path(path);
        int lastIndex = lineDataSet.getValues().size() - 1;
        if (lastIndex >= valueCount) lastIndex = valueCount - 1;

        PointValue pointValue = lineDataSet.getEntryForIndex(lastIndex);

        if (pointValue != null) {

            shaderPath.lineTo(lineDataSet.getValues().get(lastIndex).getX(), mContentRect.bottom);
            shaderPath.lineTo(0, mContentRect.bottom);
            shaderPath.lineTo(0, lineDataSet.getValues().get(0).getY());
            shaderPath.close();
            mRenderPaint.setShader(lineDataSet.getShader());
            canvas.drawPath(shaderPath, mRenderPaint);
            mRenderPaint.setShader(null);
            mRenderPaint.setStyle(Paint.Style.STROKE);

        }
    }

    canvas.drawPath(path, mRenderPaint);
}
 
开发者ID:donglua,项目名称:JZAndroidChart,代码行数:78,代码来源:LineRenderer.java

示例11: onLayout

import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    if (pointerCount > 1) return;
    View view = getChildAt(0);//layout 背景
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    //layout 中心的按钮
    View centerButton = getChildAt(1);
    centerButton.layout(mPoint.x - centerButton.getMeasuredWidth() / 2, mPoint.y - centerButton.getMeasuredHeight() / 2, mPoint.x + centerButton.getMeasuredWidth() / 2, mPoint.y + centerButton.getMeasuredHeight() / 2);
    setPos(getPath());

    for (int i = 2; i < getChildCount(); i++) {
        View v = getChildAt(i);
        if (v instanceof PopupButton) {
            PopupButton pv = (PopupButton) v;

            pv.layout(pv.x, pv.y, pv.x + pv.getMeasuredWidth(), pv.y + pv.getMeasuredHeight());
            Path path = pv.getmPathExplode();
            path.moveTo(mPoint.x - v.getMeasuredWidth() / 2, mPoint.y - v.getMeasuredHeight() / 2);
            path.lineTo(pv.x, pv.y);
            pv.explode();

            TextLableView tv = kvs.get(pv);
            if (tv.getText().equals(String.valueOf(Integer.MAX_VALUE)) || pv.getCurrentText().equals("-1"))
                continue;
            tv.layout(tv.x, tv.y, tv.x + tv.getMeasuredWidth(), tv.y + tv.getMeasuredHeight());
        }
    }
}
 
开发者ID:panshen,项目名称:PopupCircleMenu,代码行数:29,代码来源:PopupLayer.java

示例12: onDraw

import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
  Paint background = new Paint();
  background.setColor(Color.BLACK);
  background.setStyle(Paint.Style.FILL_AND_STROKE);
  canvas.drawPaint(background);

  if (timeSeries == null || timeSeries.isEmpty()) {
    return; // No points, so skip.
  }

  // Calculate bounds for the X axis.
  TimeSeriesSnapshot<Double> snapshot = timeSeries.getRecentSnapshot(Double.class);
  long timeEndMicro = snapshot.timestamps[snapshot.length - 1];
  long timeDelta = this.durationSec * 1000000L; // POIUY
  long timeStartMicro = timeEndMicro - timeDelta; // HACK
  double timeDeltaInv = 1.0 / (double)timeDelta;

  // Bounds for the Y axis:
  double voltMax = Constants.VOLTAGE_MAX;
  double voltMin = Constants.VOLTAGE_MIN;

  // Build the path by normalizing (time, value) to (x, y) coordinates.
  Path path = new Path();
  for (int i = 0; i < snapshot.length; i++) {
    double x = (snapshot.timestamps[i] - timeStartMicro) * timeDeltaInv;
    double y = (snapshot.values[i] - voltMin) / (voltMax - voltMin);
    double asX = x * canvas.getWidth();
    double asY = (1 - y) * canvas.getHeight();
    if (i == 0) {
      path.moveTo((float) asX, (float)asY);
    } else {
      path.lineTo((float) asX, (float)asY);
    }
  }

  Paint dots = new Paint();
  dots.setColor(this.color);
  dots.setStyle(Paint.Style.STROKE);
  dots.setAntiAlias(true);
  canvas.drawPath(path, dots);
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:43,代码来源:GraphSurfaceView.java

示例13: makeBorderPath

import android.graphics.Path; //导入方法依赖的package包/类
private static void makeBorderPath(Path borderPath, int w, int h, float inset) {
	w -= inset;
	h -= inset;
	borderPath.reset();
	borderPath.moveTo(w, inset);
	borderPath.lineTo(w, h);
	borderPath.lineTo(inset, h);
	borderPath.addArc(new RectF(inset, inset, 2 * w, 2 * h), 180, 270);
	borderPath.close();
}
 
开发者ID:salim3dd,项目名称:hsv-alpha-color-picker,代码行数:11,代码来源:HueSatView.java

示例14: draw

import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
    Path path=new Path();
    path.moveTo(getWidth()/5,getHeight()*4/5);
    path.lineTo(getWidth()*4/5, getHeight()*4/5);
    path.lineTo(getWidth()/2,getHeight()/5);
    path.close();
    canvas.drawPath(path, paint);
}
 
开发者ID:magicbaby810,项目名称:SRecyclerView,代码行数:10,代码来源:TriangleSkewSpinIndicator.java

示例15: drawGridLine

import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void drawGridLine(Canvas c, float x, float y, Path gridLinePath) {

    gridLinePath.moveTo(mViewPortHandler.contentRight(), y);
    gridLinePath.lineTo(mViewPortHandler.contentLeft(), y);

    // draw a path because lines don't support dashing on lower android versions
    c.drawPath(gridLinePath, mGridPaint);

    gridLinePath.reset();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:XAxisRendererHorizontalBarChart.java


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