Example usage for android.graphics.drawable.shapes PathShape PathShape

List of usage examples for android.graphics.drawable.shapes PathShape PathShape

Introduction

In this page you can find the example usage for android.graphics.drawable.shapes PathShape PathShape.

Prototype

public PathShape(@NonNull Path path, float stdWidth, float stdHeight) 

Source Link

Document

PathShape constructor.

Usage

From source file:de.uni_weimar.mheinz.androidtouchscope.display.HandleView.java

private void init() {
    mGestureDetector = new GestureDetectorCompat(getContext(), new SimpleGestureListener());

    mShapeDrawable.setShape(new PathShape(mHandlePath, mBounds.width(), mBounds.height()));
    mShapeDrawable.setBounds(0, 0, (int) mBounds.width(), (int) mBounds.height());
    setLayerType(LAYER_TYPE_SOFTWARE, mShapeDrawable.getPaint());
    makeHandle();/* w w  w .ja v  a  2  s  . co  m*/

    mIsOn = true;

    mMainTextPaint.setColor(Color.BLACK);
    mMainTextPaint.setTextSize(15);
    mMainTextPaint.setTextAlign(Paint.Align.CENTER);
}

From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java

private void initDrawable(ShapeDrawable drawable, Path path, int color, int width, int height) {
    path.moveTo(0, 0);/*from www  .  j a va  2  s .  c o m*/
    drawable.setShape(new PathShape(path, width, height));
    drawable.getPaint().setStyle(Paint.Style.STROKE);
    drawable.getPaint().setColor(color);
    drawable.setBounds(0, 0, width, height);

    setLayerType(LAYER_TYPE_SOFTWARE, drawable.getPaint());
}

From source file:com.richtodd.android.quiltdesign.block.PaperPiecedBlockPiece.java

private Drawable createDrawable(RenderOptions renderOptions) {

    PathShape pathShape = new PathShape(getPath(renderOptions.getWidth(), renderOptions.getHeight()),
            renderOptions.getWidth(), renderOptions.getHeight());

    if (renderOptions.getRenderStyle() == RenderStyles.BlackWhite) {

        ShapeDrawable strokeDrawable = new ShapeDrawable(pathShape);
        strokeDrawable.setBounds(0, 0, renderOptions.getWidth(), renderOptions.getHeight());
        strokeDrawable.getPaint().setColor(Color.BLACK);
        strokeDrawable.getPaint().setStyle(Paint.Style.STROKE);
        strokeDrawable.getPaint().setStrokeWidth(renderOptions.getStrokeWidth());

        ShapeDrawable fillDrawable = new ShapeDrawable(pathShape);
        fillDrawable.setBounds(0, 0, renderOptions.getWidth(), renderOptions.getHeight());
        fillDrawable.getPaint().setColor(Color.WHITE);
        fillDrawable.getPaint().setStyle(Paint.Style.FILL);

        Drawable[] layers = new Drawable[2];
        layers[0] = fillDrawable;/*from w  w  w. j a v  a2s  .co  m*/
        layers[1] = strokeDrawable;
        LayerDrawable drawable = new LayerDrawable(layers);

        return drawable;

    } else {

        ShapeDrawable drawable = new ShapeDrawable(pathShape);
        drawable.getPaint().setColor(getColor());
        drawable.getPaint().setStyle(Paint.Style.FILL);

        return drawable;
    }
}

From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java

private void initGridV(ShapeDrawable drawable, Path path, int color, int width, int height) {
    path.rewind();/*www  .j a v  a 2s.  c o  m*/
    float cellWidth = width / NUM_COLUMNS;
    for (int i = 0; i < NUM_COLUMNS; ++i) {
        path.moveTo(i * cellWidth, 0);
        path.lineTo(i * cellWidth, height);
    }

    float offset = NUM_ROWS * 5;
    drawable.setShape(new PathShape(path, width, height));
    drawable.getPaint().setStyle(Paint.Style.STROKE);
    drawable.getPaint().setColor(color);
    drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (height - offset) / offset }, 0));
    drawable.setBounds(0, 0, width, height);
}

From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java

private void initGridH(ShapeDrawable drawable, Path path, int color, int width, int height) {
    path.rewind();//from w w w .j  a  v a2s.  com
    float cellHeight = height / NUM_ROWS;
    for (int i = 0; i < NUM_ROWS; ++i) {
        path.moveTo(0, i * cellHeight);
        path.lineTo(width, i * cellHeight);
    }

    float offset = NUM_COLUMNS * 5;
    drawable.setShape(new PathShape(path, width, height));
    drawable.getPaint().setStyle(Paint.Style.STROKE);
    drawable.getPaint().setColor(color);
    drawable.getPaint().setPathEffect(new DashPathEffect(new float[] { 1, (width - offset) / offset }, 0));
    drawable.setBounds(0, 0, width, height);
}