Example usage for android.graphics Path moveTo

List of usage examples for android.graphics Path moveTo

Introduction

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

Prototype

public void moveTo(float x, float y) 

Source Link

Document

Set the beginning of the next contour to the point (x,y).

Usage

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);
    p.lineTo(0.f, -4.f);//from w ww .j av  a  2 s .c  o  m
    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.breel.wearables.shadowclock.graphics.ShapeShadow.java

public void drawShadow(Canvas canvas, float _sunPosX, float _sunPosY) {
    tmpSunPositionVector.setPosition(_sunPosX, _sunPosY);
    shadowPath.reset();//w w w. j a va 2s.co 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);//from ww w .j  a va2s.c  om
    path.lineTo(p3.x, p3.y);

    return path;
}

From source file:com.astuetz.PagerSlidingTriangleStrip.java

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

    if (isInEditMode() || tabCount == 0) {
        return;//w w w.  ja v  a2  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  w w .  j  av  a  2s  . c o  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);
    }
}

From source file:com.astuetz.PagerSlidingTrilateralStrip.java

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

    if (isInEditMode() || tabCount == 0) {
        return;//from  w  ww. j  av a  2 s.c o 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);
    }
    /*modify by HJ begin ??*/
    //
    //canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
    // ->
    float x1 = (lineLeft + lineRight) / 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);//2
    path.lineTo(x3, y3);//3
    path.lineTo(x1, y1);//1

    canvas.drawPath(path, rectPaint);

    /*modify by HJ end ??*/
    // 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.bob.googleplay.view.PagerSlidingTriangleStrip.java

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

    if (isInEditMode() || tabCount == 0) {
        return;/*  www .  jav a2 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);

    // -->
    float x1 = (lineRight - lineLeft) / 2 + lineLeft;
    float y1 = height - indicatorHeight;

    float x2 = x1 - triangleWidth / 2f;
    float y2 = height;

    float x3 = x1 + triangleWidth / 2f;
    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(width)
    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:wm.xmwei.ui.view.indicator.PagerSlidingTabIndicator.java

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

    if (isInEditMode() || tabCount == 0) {
        return;//w  w w  . ja v a2  s.  co  m
    }

    final int height = getHeight();
    final int width = getWidth();

    // 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);
        nextTab.setBackgroundResource(Color.TRANSPARENT);
        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 center = (lineLeft + lineRight) / 2;

    // ,??  
    // Path path = new Path();
    //path.moveTo(center,height - indicatorHeight);//   

    BigDecimal a = BigDecimal.valueOf(1.736);
    BigDecimal b = BigDecimal.valueOf(3);
    BigDecimal bigDecimal = a.divide(b, BigDecimal.ROUND_HALF_UP);
    float result = bigDecimal.floatValue() * indicatorHeight;

    //path.lineTo(center-result-2, height);  
    // path.lineTo(center+result+2, height);
    //path.close(); // ??  
    // canvas.drawPath(path, rectPaint);

    Path path2 = new Path();
    path2.moveTo(0, 0);//   
    path2.lineTo(0, height);
    path2.lineTo(center - result - 5, height);
    path2.lineTo(center, height - indicatorHeight);
    path2.lineTo(center + result + 5, height);
    path2.lineTo(tabsContainer.getWidth(), height);
    path2.lineTo(tabsContainer.getWidth(), 0);

    path2.close(); // ??  
    canvas.drawPath(path2, bgPaint);
    // 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.richtodd.android.quiltdesign.block.PaperPiecedBlockPiece.java

private Path createPath(int width, int height) {
    // Log.i(TAG, "pathCreate(" + width + "," + height + ")");

    Path path = null;

    for (PointF point : getPoints(width, height)) {
        // Log.i(TAG, "  point = " + point.x + ", " + point.y);

        if (path == null) {
            path = new Path();
            path.moveTo(point.x, point.y);
        } else {/*w ww  .j a  v  a 2  s. c  o m*/
            path.lineTo(point.x, point.y);
        }
    }

    if (path != null) {
        path.close();
    }

    return path;
}

From source file:com.kmagic.solitaire.DrawMaster.java

/**
 * Draw a diamond//from  w  w  w. j  av  a 2s .com
 * @param canvas canvas to draw on
 * @param width width of the diamond
 * @param height height of the diamond
 */
public void drawDiamond(final Canvas canvas, final float width, final float height) {
    final Paint paint = getRedPaint();
    final Path path = new Path();
    path.moveTo(width / 2, 0);
    final float offset = height / 5;
    path.lineTo(offset, height / 2);
    path.lineTo(width / 2, height);
    path.lineTo(width - offset, height / 2);
    path.lineTo(width / 2, 0);
    path.close();
    canvas.drawPath(path, paint);
}