Example usage for android.graphics Path lineTo

List of usage examples for android.graphics Path lineTo

Introduction

In this page you can find the example usage for android.graphics Path lineTo.

Prototype

public void lineTo(float x, float y) 

Source Link

Document

Add a line from the last point to the specified point (x,y).

Usage

From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java

private Path createClipPath(float perpendicularHeight) {
    Path path = new Path();
    if (settings.isBottom()) {
        if (settings.isGravityLeft()) {
            path.moveTo(width - getPaddingRight() + EPSILON,
                    height - perpendicularHeight - getPaddingBottom() + EPSILON);
            path.lineTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON);
            path.close();/* www . j  a  v  a  2 s. c o m*/
        } else {
            path.moveTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON,
                    height - perpendicularHeight - getPaddingBottom() + EPSILON);
            path.close();
        }
    } else {
        if (settings.isGravityLeft()) {
            path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() + perpendicularHeight - EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON);
            path.lineTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON);
            path.close();
        } else {
            path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() + perpendicularHeight - EPSILON);
            path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON);
            path.close();
        }
    }
    return path;
}

From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java

/**
 * MARK: Update drawings//from w w w. j av  a 2s  . com
 */

private void makePathBlack() {

    if (mPathBlack == null) {
        mPathBlack = new Path();
    }

    Path p = new Path();
    p.moveTo(Math.max(getPaddingLeft(), mProgress * mWidth / 100), mHeight / 2 + calculateDeltaY());
    p.lineTo(mWidth, mHeight / 2);

    mPathBlack.set(p);
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void drawGaugeNeedle(Canvas canvas, int count, int Scale) {
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    float divisor = 360.0f / Scale;

    canvas.rotate((float) (divisor * count), 100, 100);

    //Inside//from  w w  w.  j av  a  2 s.com
    Paint needleInsidePaint = new Paint();
    needleInsidePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    needleInsidePaint.setColor(Color.WHITE);
    needleInsidePaint.setStrokeWidth(4);
    needleInsidePaint.setAntiAlias(true);

    Paint needleEdgePaint = new Paint();
    needleEdgePaint.setStyle(Paint.Style.STROKE);
    needleEdgePaint.setColor(Color.DKGRAY);
    needleEdgePaint.setStrokeWidth(0.5f);
    needleEdgePaint.setAntiAlias(true);

    canvas.drawOval(new RectF(95, 95, 105, 105), needleInsidePaint);
    canvas.drawOval(new RectF(95, 96, 105, 105), needleEdgePaint);

    Path needleInside = new Path();
    needleInside.moveTo(98, 98);
    needleInside.lineTo(100, 20);
    needleInside.lineTo(102, 102);
    canvas.drawPath(needleInside, needleInsidePaint);

    Path needleEdge = new Path();
    needleInside.moveTo(99, 99);
    needleInside.lineTo(99, 19);
    needleInside.lineTo(103, 103);

    canvas.drawPath(needleEdge, needleEdgePaint);
    canvas.restore();
}

From source file:com.semfapp.adamdilger.semf.Take5PdfDocument.java

/**
 * Draw checkbox/*from   w w  w .  j av a  2s.co  m*/
 * @param xLoc left location
 * @param yLoc top location
 * @param paint Paint object
 */
private void drawCheck(float xLoc, float yLoc, Paint paint) {
    float x1[] = { 2.3f, 6f, 11.5f };
    float y1[] = { 8f, 11f, 2.2f };
    Path path = new Path();
    path.moveTo(xLoc + x1[0], yLoc + y1[0]);
    path.lineTo(xLoc + x1[1], yLoc + y1[1]);
    path.lineTo(xLoc + x1[2], yLoc + y1[2]);
    paint.setStrokeWidth(3);
    can.drawPath(path, paint);
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java

private void setupWayOverlay() {
    Path p = new Path();
    p.moveTo(4.f, 0.f);//ww w. java2s .  com
    p.lineTo(0.f, -4.f);
    p.lineTo(8.f, -4.f);
    p.lineTo(12.f, 0.f);
    p.lineTo(8.f, 4.f);
    p.lineTo(0.f, 4.f);

    Paint fastWayOverlayColor = new Paint(Paint.ANTI_ALIAS_FLAG);
    fastWayOverlayColor.setStyle(Paint.Style.STROKE);
    fastWayOverlayColor.setColor(Color.BLUE);
    fastWayOverlayColor.setAlpha(160);
    fastWayOverlayColor.setStrokeWidth(5.f);
    fastWayOverlayColor.setStrokeJoin(Paint.Join.ROUND);
    fastWayOverlayColor.setPathEffect(new ComposePathEffect(
            new PathDashPathEffect(p, 12.f, 0.f, PathDashPathEffect.Style.ROTATE), new CornerPathEffect(30.f)));

    // create the WayOverlay and add the ways
    this.fastWayOverlay = new FastWayOverlay(session, fastWayOverlayColor);
    mapView.getOverlays().add(this.fastWayOverlay);
    Result result = session.getResult();
    if (result != null) {
        addPathToMap(result.getWay());
    }
}

From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java

private void makePathBubble() {

    if (mPathBubble == null) {
        mPathBubble = new Path();
    }//  w w  w .ja v a2 s  .co m

    int width = mBubbleWidth;
    int height = mBubbleHeight;
    int arrowWidth = width / 3;

    //Rect r = new Rect(Math.max(getPaddingLeft()-width/2-arrowWidth/4, mProgress*mWidth/100-width/2-arrowWidth/4), mHeight/2-height + calculatedeltaY(), Math.max(getPaddingLeft()+width/2-arrowWidth/4, mProgress*mWidth/100+width/2-arrowWidth/4), mHeight/2+height-height + calculatedeltaY());
    Rect r = new Rect((int) (Math.max(getPaddingLeft() - width / 2, mProgress * mWidth / 100 - width / 2)),
            (int) (mHeight / 2 - height + calculateDeltaY()),
            (int) (Math.max(getPaddingLeft() + width / 2, mProgress * mWidth / 100 + width / 2)),
            (int) (mHeight / 2 + height - height + calculateDeltaY()));
    int arrowHeight = (int) (arrowWidth / 1.5f);
    int radius = 8;

    Path path = new Path();

    // Down arrow
    path.moveTo(r.left + r.width() / 2 - arrowWidth / 2, r.top + r.height() - arrowHeight);
    bubbleAnchorX = r.left + r.width() / 2;
    bubbleAnchorY = r.top + r.height();
    path.lineTo(bubbleAnchorX, bubbleAnchorY);
    path.lineTo(r.left + r.width() / 2 + arrowWidth / 2, r.top + r.height() - arrowHeight);

    // Go to bottom-right
    path.lineTo(r.left + r.width() - radius, r.top + r.height() - arrowHeight);

    // Bottom-right arc
    path.arcTo(new RectF(r.left + r.width() - 2 * radius, r.top + r.height() - arrowHeight - 2 * radius,
            r.left + r.width(), r.top + r.height() - arrowHeight), 90, -90);

    // Go to upper-right
    path.lineTo(r.left + r.width(), r.top + arrowHeight);

    // Upper-right arc
    path.arcTo(new RectF(r.left + r.width() - 2 * radius, r.top, r.right, r.top + 2 * radius), 0, -90);

    // Go to upper-left
    path.lineTo(r.left + radius, r.top);

    // Upper-left arc
    path.arcTo(new RectF(r.left, r.top, r.left + 2 * radius, r.top + 2 * radius), 270, -90);

    // Go to bottom-left
    path.lineTo(r.left, r.top + r.height() - arrowHeight - radius);

    // Bottom-left arc
    path.arcTo(new RectF(r.left, r.top + r.height() - arrowHeight - 2 * radius, r.left + 2 * radius,
            r.top + r.height() - arrowHeight), 180, -90);

    path.close();

    mPathBubble.set(path);
}

From source file:com.breel.wearables.shadowclock.graphics.ShapeShadow.java

public void drawShadow(Canvas canvas, float _sunPosX, float _sunPosY) {
    tmpSunPositionVector.setPosition(_sunPosX, _sunPosY);
    shadowPath.reset();//from   w  ww . j a v a2 s  . c  o m
    for (int i = 0; i < vertexArray.size(); i++) {
        Path tmpPath = shadowPaths.get(i);
        tmpPath.reset();

        AVector v1 = vertexArray.get(i);
        AVector v2 = vertexArray.get(i == getVertCount() - 1 ? 0 : i + 1);

        tmpPath.moveTo(v2.getX(), v2.getY());
        tmpPath.lineTo(v1.getX(), v1.getY());

        // Current shadow vertex
        AVector tmpShadowVector = AVector.sub(v1, tmpSunPositionVector);
        tmpShadowVector.normalize();
        tmpShadowVector.multiply(600.0f);
        tmpShadowVector.add(v1);

        tmpPath.lineTo(tmpShadowVector.getX(), tmpShadowVector.getY());

        // Current shadow vertex
        tmpShadowVector = AVector.sub(v2, tmpSunPositionVector);
        tmpShadowVector.normalize();
        tmpShadowVector.multiply(600.0f);
        tmpShadowVector.add(v2);

        tmpPath.lineTo(tmpShadowVector.getX(), tmpShadowVector.getY());
        tmpPath.close();

        shadowPath.op(tmpPath, Path.Op.UNION);
    }
    canvas.drawPath(shadowPath, shadowPathPaint);
}

From source file:ingbank.com.tr.happybanking.common.ui.controls.PagerSlidingTabStrip.java

public Path getEquilateralTriangle(Rect bounds) {
    android.graphics.Point startPoint = null, p2 = null, p3 = null;
    int width = bounds.right - bounds.left - 12;
    int height = bounds.bottom - bounds.top;

    startPoint = new android.graphics.Point(bounds.left, bounds.bottom);

    p2 = new android.graphics.Point(startPoint.x + width, startPoint.y);
    //p3 = new Point(startPoint.x + (width / 2), startPoint.y - width);
    p3 = new android.graphics.Point(startPoint.x + (width / 2), startPoint.y - height);

    Path path = new Path();
    path.moveTo(startPoint.x, startPoint.y);
    path.lineTo(p2.x, p2.y);
    path.lineTo(p3.x, p3.y);//  w  w w. ja  v a2  s  .c  o  m

    return path;
}

From source file:com.astuetz.PagerSlidingTriangleStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//from   w  w w.j  av a 2 s . c om
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    //
    //canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    //
    float x1 = (lineRight + lineLeft) / 2;
    float y1 = height - indicatorHeight;//
    float x2 = x1 - triangleWidth / 2;
    float y2 = height;//
    float x3 = x1 + triangleWidth / 2;
    float y3 = height;//

    Path path = new Path();
    path.moveTo(x1, y1);
    path.lineTo(x2, y2);
    path.lineTo(x3, y3);
    path.lineTo(x1, y1);

    //
    //        rectPaint.setStyle(Style.STROKE);
    //        rectPaint.setStrokeWidth(2);

    canvas.drawPath(path, rectPaint);

    // draw underline

    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}

From source file:com.astuetz.PagerSlidingTabStripCustom.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;/*  w ww .  j  av  a 2 s  .  co  m*/
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }
    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    //draw triangle 
    float bianchang = indicatorHeight + 10;
    float x1 = (lineRight + lineLeft) / 2;
    float y1 = height - bianchang;
    float x2 = x1 + bianchang * 2;
    float y2 = y1 + bianchang;
    float x3 = x1 - bianchang * 2;
    float y3 = y1 + bianchang;

    Path path = new Path();
    path.moveTo(x1, y1);
    path.lineTo(x2, y2);
    path.lineTo(x3, y3);
    path.close();
    canvas.drawPath(path, rectPaint);

    // draw underline   tabcontent

    rectPaint.setColor(underlineColor);

    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider tab

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}