Example usage for android.graphics DashPathEffect DashPathEffect

List of usage examples for android.graphics DashPathEffect DashPathEffect

Introduction

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

Prototype

public DashPathEffect(float intervals[], float phase) 

Source Link

Document

The intervals array must contain an even number of entries (>=2), with the even indices specifying the "on" intervals, and the odd indices specifying the "off" intervals.

Usage

From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java

public void initCompassView() {
    setFocusable(true);/*from  www.j  av a2 s.  c o m*/
    initAstronomicParameters();
    northString = "N";
    eastString = "E";
    southString = "S";
    westString = "W";

    dashPath = new DashPathEffect(new float[] { 2, 5 }, 1);
    dashedPaint = new Paint(Paint.FAKE_BOLD_TEXT_FLAG);
    dashedPaint.setPathEffect(dashPath);
    dashedPaint.setStrokeWidth(2);
    dashedPaint.setPathEffect(dashPath);
    dashedPaint.setColor(ContextCompat.getColor(getContext(), R.color.qibla_color));

    textPaint = new Paint(Paint.FAKE_BOLD_TEXT_FLAG);
    textPaint.setColor(ContextCompat.getColor(getContext(), (R.color.qibla_color)));
    textPaint.setTextSize(20);
}

From source file:com.savvasdalkitsis.betwixt.demo.InterpolatorView.java

private void init() {
    paint = new Paint();
    paint.setColor(Color.BLACK);/*from ww  w.  ja va 2s . c o m*/
    paint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.interpolation_width));
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setAntiAlias(true);
    paint.setStrokeCap(Paint.Cap.ROUND);
    linePaint.setColor(Color.WHITE);
    linePaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.interpolation_width));
    float dashSize = getResources().getDimensionPixelSize(R.dimen.dash_size);
    linePaint.setPathEffect(new DashPathEffect(new float[] { dashSize, dashSize }, 0));
    linePaint.setStyle(Paint.Style.STROKE);
    rectPaint = new Paint();
    rectPaint.setARGB(255, 255, 200, 200);
    radius = getResources().getDimensionPixelSize(R.dimen.circle_radius);
    animationInset = getResources().getDimensionPixelSize(R.dimen.play_inset);
    circlePaint.setColor(Color.RED);
    circlePaint.setAntiAlias(true);
    textPaint.setColor(Color.BLACK);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(getResources().getDimensionPixelSize(R.dimen.interpolator_description_size));
    textPaddingLeft = getResources().getDimensionPixelSize(R.dimen.text_padding_left);
    dim.setColor(ColorUtils.setAlphaComponent(Color.BLACK, 200));
    setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            play();
        }
    });
    playAnimator.setStartDelay(500);
    playAnimator.setDuration(1000);
    playAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            progress = animation.getAnimatedFraction();
            postInvalidate();
        }
    });
    playAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationCancel(Animator animation) {
            endAnimation();
        }

        @Override
        public void onAnimationEnd(final Animator animation) {
            postDelayed(new Runnable() {
                @Override
                public void run() {
                    endAnimation();
                }
            }, 500);
        }
    });
}

From source file:de.treichels.hott.ui.android.html.AndroidCurveImageGenerator.java

private Bitmap getBitmap(final Curve curve, final float scale, final boolean description) {
    final boolean pitchCurve = curve.getPoint()[0].getPosition() == 0;
    final float scale1 = scale * 0.75f; // smaller images on the android
    // platform//from   w  w w .  j  a  va 2  s. co m

    final Bitmap image = Bitmap.createBitmap((int) (10 + 200 * scale1), (int) (10 + 250 * scale1),
            Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(image);

    final Paint backgroundPaint = new Paint();
    backgroundPaint.setColor(Color.WHITE);
    backgroundPaint.setStyle(Style.FILL);

    final Paint forgroundPaint = new Paint();
    forgroundPaint.setColor(Color.BLACK);
    forgroundPaint.setStyle(Style.STROKE);
    forgroundPaint.setStrokeWidth(1.0f);
    forgroundPaint.setStrokeCap(Cap.BUTT);
    forgroundPaint.setStrokeJoin(Join.ROUND);
    forgroundPaint.setStrokeMiter(0.0f);

    final Paint curvePaint = new Paint(forgroundPaint);
    curvePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    curvePaint.setStrokeWidth(2.0f);

    final Paint pointPaint = new Paint(curvePaint);
    pointPaint.setStrokeWidth(5.0f);
    pointPaint.setStyle(Style.FILL_AND_STROKE);

    final Paint helpLinePaint = new Paint(forgroundPaint);
    helpLinePaint.setColor(Color.GRAY);
    helpLinePaint.setPathEffect(new DashPathEffect(new float[] { 5.0f, 5.0f }, 2.5f));

    final Paint textPaint = new Paint(forgroundPaint);
    textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    textPaint.setTextSize(12.0f);
    textPaint.setTextAlign(Align.CENTER);
    textPaint.setStyle(Style.FILL);

    canvas.drawRect(0, 0, 10 + 200 * scale1, 10 + 250 * scale1, backgroundPaint);
    canvas.drawRect(5, 5, 5 + 200 * scale1, 5 + 250 * scale1, forgroundPaint);

    canvas.drawLine(5, 5 + 25 * scale1, 5 + 200 * scale1, 5 + 25 * scale1, helpLinePaint);
    canvas.drawLine(5, 5 + 225 * scale1, 5 + 200 * scale1, 5 + 225 * scale1, helpLinePaint);
    if (!pitchCurve) {
        canvas.drawLine(5, 5 + 125 * scale1, 5 + 200 * scale1, 5 + 125 * scale1, helpLinePaint);
        canvas.drawLine(5 + 100 * scale1, 5, 5 + 100 * scale1, 5 + 250 * scale1, helpLinePaint);
    }

    if (curve.getPoint() != null) {
        int numPoints = 0;
        for (final CurvePoint p : curve.getPoint()) {
            if (p.isEnabled()) {
                numPoints++;
            }
        }

        final double[] xVals = new double[numPoints];
        final double[] yVals = new double[numPoints];

        int i = 0;
        for (final CurvePoint p : curve.getPoint()) {
            if (p.isEnabled()) {
                if (i == 0) {
                    xVals[i] = pitchCurve ? 0 : -100;
                } else if (i == numPoints - 1) {
                    xVals[i] = 100;
                } else {
                    xVals[i] = p.getPosition();
                }
                yVals[i] = p.getValue();

                if (description) {
                    float x0;
                    float y0;
                    if (pitchCurve) {
                        x0 = (float) (5 + xVals[i] * 2 * scale1);
                        y0 = (float) (5 + (225 - yVals[i] * 2) * scale1);
                    } else {
                        x0 = (float) (5 + (100 + xVals[i]) * scale1);
                        y0 = (float) (5 + (125 - yVals[i]) * scale1);
                    }

                    canvas.drawPoint(x0, y0, pointPaint);
                    if (y0 < 5 + 125 * scale1) {
                        canvas.drawRect(x0 - 4, y0 + 5, x0 + 3, y0 + 18, backgroundPaint);
                        canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 + 16, textPaint);
                    } else {
                        canvas.drawRect(x0 - 4, y0 - 5, x0 + 3, y0 - 18, backgroundPaint);
                        canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 - 7, textPaint);
                    }
                }

                i++;
            }
        }

        if (numPoints > 2 && curve.isSmoothing()) {
            final SplineInterpolator s = new SplineInterpolator();
            final PolynomialSplineFunction function = s.interpolate(xVals, yVals);

            float x0 = 5;
            float y0;
            if (pitchCurve) {
                y0 = (float) (5 + (225 - yVals[0] * 2) * scale1);
            } else {
                y0 = (float) (5 + (125 - yVals[0]) * scale1);
            }

            while (x0 < 4 + 200 * scale1) {
                final float x1 = x0 + 1;
                float y1;
                if (pitchCurve) {
                    y1 = (float) (5 + (225 - function.value((x1 - 5) / scale1 / 2) * 2) * scale1);
                } else {
                    y1 = (float) (5 + (125 - function.value((x1 - 5) / scale1 - 100)) * scale1);
                }

                canvas.drawLine(x0, y0, x1, y1, curvePaint);

                x0 = x1;
                y0 = y1;
            }
        } else {
            for (i = 0; i < numPoints - 1; i++) {
                float x0, y0, x1, y1;

                if (pitchCurve) {
                    x0 = (float) (5 + xVals[i] * 2 * scale1);
                    y0 = (float) (5 + (225 - yVals[i] * 2) * scale1);

                    x1 = (float) (5 + xVals[i + 1] * 2 * scale1);
                    y1 = (float) (5 + (225 - yVals[i + 1] * 2) * scale1);
                } else {
                    x0 = (float) (5 + (100 + xVals[i]) * scale1);
                    y0 = (float) (5 + (125 - yVals[i]) * scale1);

                    x1 = (float) (5 + (100 + xVals[i + 1]) * scale1);
                    y1 = (float) (5 + (125 - yVals[i + 1]) * scale1);
                }

                canvas.drawLine(x0, y0, x1, y1, curvePaint);
            }
        }
    }

    return image;
}

From source file:com.jjoe64.graphview_demos.fragments.Styling.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    GraphView graph = (GraphView) rootView.findViewById(R.id.graph);

    DataPoint[] points = new DataPoint[30];
    for (int i = 0; i < 30; i++) {
        points[i] = new DataPoint(i, Math.sin(i * 0.5) * 20 * (Math.random() * 10 + 1));
    }//  w w w. j  a va2  s.c o  m
    LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(points);

    points = new DataPoint[15];
    for (int i = 0; i < 15; i++) {
        points[i] = new DataPoint(i * 2, Math.sin(i * 0.5) * 20 * (Math.random() * 10 + 1));
    }
    LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(points);

    // styling grid/labels
    graph.getGridLabelRenderer().setGridColor(Color.RED);
    graph.getGridLabelRenderer().setHighlightZeroLines(false);
    graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.GREEN);
    graph.getGridLabelRenderer().setVerticalLabelsColor(Color.RED);
    graph.getGridLabelRenderer().setVerticalLabelsAlign(Paint.Align.LEFT);
    graph.getGridLabelRenderer().setLabelVerticalWidth(150);
    graph.getGridLabelRenderer().setTextSize(40);
    graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.HORIZONTAL);
    graph.getGridLabelRenderer().reloadStyles();

    // styling viewport
    graph.getViewport().setBackgroundColor(Color.argb(255, 222, 222, 222));

    // styling series
    series.setTitle("Random Curve 1");
    series.setColor(Color.GREEN);
    series.setDrawDataPoints(true);
    series.setDataPointsRadius(10);
    series.setThickness(8);

    series2.setTitle("Random Curve 2");
    series2.setDrawBackground(true);
    series2.setBackgroundColor(Color.argb(100, 255, 255, 0));
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(10);
    paint.setPathEffect(new DashPathEffect(new float[] { 8, 5 }, 0));
    series2.setCustomPaint(paint);

    // styling legend
    graph.getLegendRenderer().setVisible(true);
    graph.getLegendRenderer().setTextSize(25);
    graph.getLegendRenderer().setBackgroundColor(Color.argb(150, 50, 0, 0));
    graph.getLegendRenderer().setTextColor(Color.WHITE);
    //graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);
    //graph.getLegendRenderer().setMargin(30);
    graph.getLegendRenderer().setFixedPosition(150, 0);

    graph.addSeries(series);
    graph.addSeries(series2);

    return rootView;
}

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

public PdfDocument createDocument() {
    //create new document
    PdfDocument document = new PdfDocument();

    // crate a page description
    PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(A4_WIDTH, A4_HEIGHT, 1).create();

    // start a page
    PdfDocument.Page page = document.startPage(pageInfo);

    can = page.getCanvas();//from   w ww  .java  2  s. co  m
    Paint paint = new Paint();
    paint.setStrokeWidth(0.5f);
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.STROKE);
    can.drawRect(1, 1, 594, 395, paint);

    /**
     * Page one Text Fields
     */
    drawText("Job Reference:", 9, 21, FONT14, carlitoBold);
    drawText("Date:", 354, 21, FONT14, carlitoBold);
    drawText("Time:", 473, 21, FONT14, carlitoBold);
    drawText("Location:", 9, 48, FONT14, carlitoBold);
    drawText("Task:", 261, 48, FONT14, carlitoBold);

    paint.setPathEffect(new DashPathEffect(new float[] { 1.5f, 1 }, 0));
    can.drawLine(85, 36, 350, 36, paint);
    can.drawLine(386, 36, 468, 36, paint);
    can.drawLine(506, 36, 585, 36, paint);
    can.drawLine(59, 60, 256, 60, paint);
    can.drawLine(291, 60, 585, 60, paint);

    if (mEditTextValues[0] != null) {
        drawText(mEditTextValues[0], 98, 19, FONT14, roboto);
    }
    if (mEditTextValues[1] != null) {
        drawText(mEditTextValues[1], 65, 44, FONT14, roboto);
    }
    if (mEditTextValues[2] != null) {
        drawText(mEditTextValues[2], 297, 44, FONT14, roboto);
    }
    drawText(mDateString, 390, 19, FONT14, roboto);
    drawText(mTimeString, 509, 19, FONT14, roboto);

    /**
     * Section One (Stop, step back...)
     */
    drawHeader1(8, 69, 202, "Stop, step back and think", 1);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(0.35f);
    paint.setPathEffect(null);
    int left, top;

    //draw left boxes
    left = 177;
    top = 108;
    for (int x = 0; x < mCheckBoxSectionOne.size(); x++) {
        Take5Data.CheckValue isYes = mCheckBoxSectionOne.get(x).getCheckValue();
        float topLoc = top + (x * 33);

        if (x < 1) { //allowing for different 1st row size
            drawBox(left, topLoc, paint, true, isYes);
        } else {
            float newTop = topLoc - 6;
            if (x < 3) {
                drawBox(left, newTop, paint, false, isYes);
            } else {
                drawBox(left, newTop, paint, true, isYes);
            }
        }
    }

    DashPathEffect pathEffect = new DashPathEffect(new float[] { 1, 1.5f }, 0);

    drawText(mCheckBoxSectionOne.get(0).getHeading(), 13, 113, FONT12, carlitoBold);

    for (int x = 1; x < mCheckBoxSectionOne.size(); x++) {
        int height = 132 + ((x - 1) * 33);
        drawText(mCheckBoxSectionOne.get(x).getHeading(), 13, height, FONT12, carlitoBold);
        paint.setPathEffect(pathEffect);
        can.drawLine(10, height - 6, 222, height - 6, paint);
        paint.setPathEffect(null);
    }

    /**
     * Section Two (Identidy the Hazards...)
     */
    drawHeader1(230, 69, 345, "Identify the hazard(s)", 2);

    //draw right boxes
    left = 542;
    top = 104;
    for (int x = 0; x < mCheckBoxSectionTwo.size(); x++) {
        float topLoc = top + (x * 20.7f);
        Take5Data.CheckValue isYes = mCheckBoxSectionTwo.get(x).getCheckValue();
        drawBox(left, topLoc, paint, false, isYes);
    }

    for (int x = 0; x < mCheckBoxSectionTwo.size(); x++) {
        float height = 105 + (x * 20.7f);
        drawText(mCheckBoxSectionTwo.get(x).getHeading(), 238, height + 3, FONT12, carlitoBold);
        if (x > 0) {
            paint.setPathEffect(pathEffect);
            can.drawLine(238, height - 4, 581, height - 4, paint);
            paint.setPathEffect(null);
        }
    }

    /**
     * draw section 3,4,5 (including checkboxes)
     */
    drawSmallCircle(8, 331, "Assess the level of risk", 3);
    drawSmallCircle(202, 331, "Control the hazards", 4);
    drawSmallCircle(398, 331, "Proceed safely", 5);

    /**
     * Draw Page Two
     */
    int xLoc = 7;
    int yLoc = 420;
    int height;
    int width = 565;
    int RADIUS = 14;
    float INNER_RADIUS = 13;
    int centre = yLoc + 7 + RADIUS;
    width = xLoc + width;
    int middle = width - 340;
    can.drawRect(1, 420, 594, 420 + 395, paint);

    paint.setStyle(Paint.Style.FILL);
    paint.setTypeface(impact);
    paint.setTextSize(12);

    can.drawCircle(xLoc + RADIUS, centre, RADIUS, paint);
    can.drawRect(xLoc + RADIUS, centre - RADIUS, width, centre + RADIUS, paint);
    can.drawCircle(width, centre, RADIUS, paint);
    paint.setColor(Color.WHITE);
    can.drawCircle(xLoc + RADIUS, centre, INNER_RADIUS, paint);
    can.drawCircle(width, centre, INNER_RADIUS, paint);
    can.drawRect(middle, centre - INNER_RADIUS, width, centre + INNER_RADIUS, paint);
    paint.setColor(Color.BLACK);
    can.drawCircle(middle, centre, RADIUS, paint);

    paint.setColor(Color.WHITE);
    can.drawText("SAFE WORK METHOD STATEMENT (SWMS)", xLoc + 31, centre + 5, paint);
    paint.setTextSize(16);
    paint.setColor(Color.BLACK);
    can.drawText(String.valueOf(4), xLoc + RADIUS - 4, centre + 6, paint);

    height = 50;
    drawText("What are the hazards and risks?", 25, yLoc + height, FONT12, carlitoBold);
    drawText("Risk\nRating", 267, yLoc + 47, FONT12, carlitoBold);
    drawText("How will hazards and risks be controlled?", 319, yLoc + height, FONT12, carlitoBold);

    paint.setPathEffect(pathEffect);
    can.drawLine(262, yLoc + 45, 262, yLoc + 320, paint);
    can.drawLine(302, yLoc + 45, 302, yLoc + 320, paint);
    paint.setPathEffect(null);

    float currentItemHeight = yLoc + 75;
    float padding = 5;

    for (int x = 0; x < mRiskElements.size(); x++) {
        int textHeight = (int) currentItemHeight;
        float totalItemHeight = drawRiskElement(textHeight, mRiskElements.get(x));
        currentItemHeight += totalItemHeight + padding;
    }

    paint.setPathEffect(pathEffect);
    height = yLoc + 350;
    drawText("Name/s:", 12, height, FONT12, carlitoBold);
    drawText(mEditTextValues[3], 55, height - 3, FONT14, roboto);
    paint.setPathEffect(pathEffect);
    can.drawLine(50, height + 12, 580, height + 12, paint);
    paint.setPathEffect(null);

    height = yLoc + 372;
    drawText("Signatures:", 12, height, FONT12, carlitoBold);
    drawText("Date:", 468, height, FONT12, carlitoBold);
    drawText(mDateString, 497, height - 3, FONT14, roboto);
    paint.setPathEffect(pathEffect);
    can.drawLine(60, height + 12, 464, height + 12, paint);
    can.drawLine(492, height + 12, 580, height + 12, paint);
    paint.setPathEffect(null);

    // finish the page
    document.finishPage(page);

    int imagePageCount = 2;

    for (Take5RiskElement risk : mRiskElements) {

        if (risk.imagePath != null) {

            // crate a page description
            PdfDocument.PageInfo pageInfo1 = new PdfDocument.PageInfo.Builder(A4_WIDTH, A4_HEIGHT,
                    imagePageCount).create();

            PdfDocument.Page imagePage = document.startPage(pageInfo1);
            Canvas canvas = imagePage.getCanvas();

            try {

                Bitmap original = BitmapFactory.decodeFile(risk.imagePath);

                Bitmap b = resize(original, canvas.getWidth() - 100, canvas.getHeight() - 100);
                canvas.drawBitmap(b, 50, 60, new Paint());
                //                    canvas.drawText(risk.getOne(), 50, 40, new Paint());

                Path textPath = new Path();
                textPath.moveTo(50, 50);
                textPath.lineTo(canvas.getWidth() - 100, 50);

                canvas.drawTextOnPath(risk.getOne(), textPath, 0, 0, new Paint());

            } catch (Exception e) {
                e.printStackTrace();
            }

            document.finishPage(imagePage);

            imagePageCount++;

            new File(risk.imagePath).delete();
        }
    }

    // add more pages
    return document;
}

From source file:com.ruesga.rview.widget.ActivityStatsChart.java

public ActivityStatsChart(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final Resources r = getResources();
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    int color = Color.DKGRAY;
    int textColor = Color.WHITE;

    Resources.Theme theme = context.getTheme();
    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.ActivityStatsChart, defStyleAttr, 0);
    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case R.styleable.ActivityStatsChart_charLineColor:
            color = a.getColor(attr, color);
            break;

        case R.styleable.ActivityStatsChart_charLineTextColor:
            textColor = a.getColor(attr, textColor);
            break;
        }/*from  ww  w .  j  a  v  a  2s.  c o m*/
    }
    a.recycle();

    mLinePaint = new Paint();
    mLinePaint.setStyle(Paint.Style.STROKE);
    mLinePaint.setColor(color);
    mLinePaint.setStrokeWidth(
            TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1.5f, r.getDisplayMetrics()));

    mAreaPaint = new Paint(mLinePaint);
    mAreaPaint.setStyle(Paint.Style.FILL);
    mAreaPaint.setAlpha(180);

    mGridLinesPaint = new Paint();
    mGridLinesPaint.setStyle(Paint.Style.STROKE);
    mGridLinesPaint.setColor(textColor);
    mGridLinesPaint.setStrokeWidth(
            TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0.5f, r.getDisplayMetrics()));
    mGridLinesPaint.setAlpha(90);
    mGridLinesPaint.setPathEffect(new DashPathEffect(new float[] { 10, 10 }, 0));

    mTicksPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mTicksPaint.setColor(textColor);
    mTicksPaint.setTextAlign(Paint.Align.RIGHT);
    mTicksPaint.setAlpha(180);
    mTicksPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8f, r.getDisplayMetrics()));

    // Ensure we have a background. Otherwise it will not draw anything
    if (getBackground() == null) {
        setBackgroundColor(Color.TRANSPARENT);
    }
}

From source file:com.github.jorgecastillo.FillableLoader.java

private PathEffect getDashPathForDistance(float distance) {
    return new DashPathEffect(new float[] { distance, pathData.length }, 0);
}

From source file:com.blestep.sportsbracelet.view.TimelineChartView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr) {
    mUiHandler = new Handler(Looper.getMainLooper(), mMessenger);

    final Resources res = getResources();

    final ViewConfiguration vc = ViewConfiguration.get(ctx);
    mTouchSlop = vc.getScaledTouchSlop() / 2;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(ctx);

    int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcStepsFooterLabelColor);
    int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsBarItemBg);
    int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsHighlightBarItemBg);

    mBarItemBgPaint = new Paint();
    mBarItemBgPaint.setColor(barItemBg);
    mHighlightBarItemBgPaint = new Paint();
    mHighlightBarItemBgPaint.setColor(highlightBarItemBg);

    mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight);

    mViewAreaBgPaint = new Paint();

    mGraphAreaBgPaint = new Paint();
    mGraphAreaBgPaint.setColor(Color.TRANSPARENT);

    mFooterAreaBgPaint = new Paint();
    mFooterAreaBgPaint.setColor(Color.TRANSPARENT);

    mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGraphBottomLinePaint.setColor(Color.WHITE);
    mGraphBottomLinePaint.setStrokeWidth(1);
    // //  w w  w  .j  a  v a 2 s .c om
    mGraphTargetDashedLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGraphTargetDashedLinePaint.setStyle(Paint.Style.STROKE);
    mGraphTargetDashedLinePaint.setColor(Color.WHITE);
    mGraphTargetDashedLinePaint.setStrokeWidth(1);
    PathEffect pathEffect = new DashPathEffect(new float[] { 9, 3 }, 1);
    mGraphTargetDashedLinePaint.setPathEffect(pathEffect);

    // labelPaint??
    mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mLabelFgPaint.setColor(footerLabelColor);
    //        DisplayMetrics dp = getResources().getDisplayMetrics();
    //        float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp);
    mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize));

    mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mHighlightLabelFgPaint.setColor(Color.WHITE);
    mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize));

    mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth);
    mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace);
    mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace);

    // SurfaceView requires a background
    if (getBackground() == null) {
        setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
    }

    // Initialize stuff
    setupBackgroundHandler();
    setupTickLabels();

    // Initialize the drawing refs (this will be update when we have
    // the real size of the canvas)
    computeBoundAreas();
}

From source file:com.lt.adamlee.aagame.GameView.java

public GameView(Context context, AttributeSet attrs) {
    super(context, attrs);
    ctx = context;//from   www  . ja v a 2 s  .co  m
    getHolder().addCallback(this);
    setFocusable(true);
    DisplayMetrics DisplayMetrics = new DisplayMetrics();
    DisplayMetrics = context.getResources().getDisplayMetrics();
    screenW = DisplayMetrics.widthPixels;
    screenH = DisplayMetrics.heightPixels;
    this.mainpageimage = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.mainpageimage);
    this.mainpageimage = Bitmap.createScaledBitmap(this.mainpageimage, screenW, screenH, true);
    this.play = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.play);
    this.play = Bitmap.createScaledBitmap(this.play, (int) F.wf(90.0f), (int) F.wf(90.0f), true);
    this.cartoonbomb = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.cartoonbomb);
    this.cartoonbomb = Bitmap.createScaledBitmap(this.cartoonbomb, (int) F.hf(20.0f), (int) F.hf(20.0f), true);
    this.leaderboard = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.leaderboard);
    this.leaderboard = Bitmap.createScaledBitmap(this.leaderboard, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.moreapps = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.moreapps);
    this.moreapps = Bitmap.createScaledBitmap(this.moreapps, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.help = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.help);
    this.help = Bitmap.createScaledBitmap(this.help, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.about = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.about);
    this.about = Bitmap.createScaledBitmap(this.about, (int) F.wf(70.0f), (int) F.wf(70.0f), true);
    this.localAd = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.addimagebottom);
    view = new Circle();
    paint2 = new Paint();
    paint3 = new Paint();
    paint4 = new Paint();
    paint5 = new Paint();
    paint6 = new Paint();
    paint7 = new Paint();
    paint13 = new Paint();
    this.paint10 = new Paint();
    this.level = new LevelPage();
    circledrawboolean = new boolean[100];
    this.innercircletext = new Paint();
    this.innercircletext.setColor(-1);
    this.textsizetext = 10.0f;
    this.innercircletext.setTextSize(F.hf(this.textsizetext));
    this.innercircletext.setTypeface(tf);
    this.innercircletext.setTextAlign(Paint.Align.CENTER);
    this.innercircletext.setAntiAlias(true);
    this.innercircletext.setFilterBitmap(true);
    this.p9 = new Paint();
    this.paint20 = new Paint();
    this.paint21 = new Paint();
    this.pp = new Paint();
    this.eg = new ExitGame();
    paint4.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint4.setAntiAlias(true);
    paint4.setFilterBitmap(true);
    paint4.setPathEffect(new DashPathEffect(new float[] { 30.0f, 0.0f }, 0.0f));
    paint4.setStrokeWidth(2.0f);
    paint4.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint3.setColor(ViewCompat.MEASURED_STATE_MASK);
    paint3.setAntiAlias(true);
    paint3.setFilterBitmap(true);
    counter = 0;
    linecounter = -1;
    blinedraw = new boolean[100];
    blinedraw1 = new boolean[100];
    circleanimation = new boolean[100];
    savex = new int[100];
    savey = new int[100];
    rotation = new float[100];
    textsize = 20;
    a2 = 1200;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    textsize4 = 20;
    this.paint21.setTextSize(F.hf((float) textsize4));
    paint2.setTextSize(F.hf((float) textsize));
    textsize = 25;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    paint6.setTextSize(F.hf((float) textsize));
    this.textsize3 = 22;
    tf = Typeface.createFromAsset(ctx.getAssets(), "Russo_One.ttf");
    this.pp.setTextSize(F.hf((float) this.textsize3));
    a1 = MotionEventCompat.ACTION_MASK;
    changeangle = 2.0d;
    this.directioncounter = 1;
    NoOfInitialLines = 6;
    holdcounter = 0;
    hcm = 0;
    this.anim = new Levelfailedanimation();
    levelcounter = 1;
    textdisplayboolean = true;
    if (levelcounter > 0 && levelcounter < 4) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 3 && levelcounter < 7) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 6 && levelcounter < 10) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 9 && levelcounter < 13) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 12 && levelcounter < 16) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 15 && levelcounter < 19) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 18 && levelcounter < 22) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 21 && levelcounter < 25) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 24 && levelcounter < 28) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 27 && levelcounter < 31) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 30 && levelcounter < 34) {
        NoOfInitialLines = 1;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 33 && levelcounter < 37) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 36 && levelcounter < 40) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 39 && levelcounter < 43) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 42 && levelcounter < 46) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 45 && levelcounter < 49) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 48 && levelcounter < 52) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 51 && levelcounter < 55) {
        NoOfInitialLines = 7;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 54 && levelcounter < 58) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 57 && levelcounter < 61) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 606 && levelcounter < 64) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 63 && levelcounter < 67) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 66 && levelcounter < 70) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 69 && levelcounter < 73) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 72 && levelcounter < 76) {
        NoOfInitialLines = 9;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 75 && levelcounter < 79) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 78 && levelcounter < 82) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 81 && levelcounter < 85) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 84 && levelcounter < 88) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 87 && levelcounter < 91) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 90 && levelcounter < 94) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 93 && levelcounter < 97) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 96 && levelcounter < 101) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 100 && levelcounter < 105) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 104 && levelcounter < 108) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 107 && levelcounter < 111) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 110 && levelcounter < 114) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 113 && levelcounter < 117) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 116 && levelcounter < 121) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 120 && levelcounter < 124) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 123 && levelcounter < TransportMediator.KEYCODE_MEDIA_PAUSE) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > TransportMediator.KEYCODE_MEDIA_PLAY && levelcounter < 131) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > TransportMediator.KEYCODE_MEDIA_RECORD && levelcounter < 134) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 133 && levelcounter < 137) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 136 && levelcounter < 140) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 139 && levelcounter < 144) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 143 && levelcounter < 146) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 146 && levelcounter < 151) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 150 && levelcounter < 155) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 154 && levelcounter < 158) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 157 && levelcounter < 161) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 160 && levelcounter < 164) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 163 && levelcounter < 167) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 166 && levelcounter < 171) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 170 && levelcounter < 174) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 173 && levelcounter < 177) {
        NoOfInitialLines = 5;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 176 && levelcounter < 180) {
        NoOfInitialLines = 4;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 179 && levelcounter < 184) {
        NoOfInitialLines = 2;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 183 && levelcounter < 187) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 186 && levelcounter < 191) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 190 && levelcounter < 194) {
        NoOfInitialLines = 3;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 193 && levelcounter < 197) {
        NoOfInitialLines = 6;
        saveline = NoOfInitialLines;
    }
    if (levelcounter > 196 && levelcounter < 202) {
        NoOfInitialLines = 8;
        saveline = NoOfInitialLines;
    }
}

From source file:com.app.jdy.ui.MyFaceActivity.java

private void initLineChart() {

    mLineChart = (LineChartView) findViewById(R.id.linechart);
    mLineChart.setOnEntryClickListener(lineEntryListener);
    mLineChart.setOnClickListener(lineClickListener);

    mLineGridPaint = new Paint();
    mLineGridPaint.setColor(this.getResources().getColor(R.color.line_grid));
    mLineGridPaint.setPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
    mLineGridPaint.setStyle(Paint.Style.STROKE);
    mLineGridPaint.setAntiAlias(true);/*ww w. j a  v a  2 s.c om*/
    mLineGridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
}