Example usage for android.graphics Path set

List of usage examples for android.graphics Path set

Introduction

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

Prototype

public void set(@NonNull Path src) 

Source Link

Document

Replace the contents of this with the contents of src.

Usage

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

private int updatePath(Path path, WaveData waveData) {
    int retValue = -1;
    if (waveData == null || waveData.data == null || waveData.data.length == 0) {
        path.rewind();//  w  w  w.java 2s .  c o  m
        return retValue;
    }

    retValue = 0;
    int length = Math.min(BaseScope.SAMPLE_LENGTH, waveData.data.length) - 10;
    float widthRatio = (float) (mContentWidth) / (length * DISPLAY_RATIO);
    double vScale = waveData.voltageScale;
    if (vScale == 0)
        vScale = 1.0f;

    Path newPath = new Path();
    double point = manipulatePoint(waveData.voltageOffset, vScale, waveData.data[10]);

    float j = -(length * (1 - DISPLAY_RATIO)) / 2;
    newPath.moveTo(j++ * widthRatio, (float) point);

    for (int i = 11; i < waveData.data.length; ++i, ++j) {
        point = manipulatePoint(waveData.voltageOffset, vScale, waveData.data[i]);
        newPath.lineTo(j * widthRatio, (float) point);
    }

    if (new PathMeasure(path, false).getLength() == 0) {
        path.set(newPath);
        return retValue;
    }

    if (mChangeDelay <= 0) {
        path.set(newPath);
        retValue = 1;
    } else {
        mChangeDelay--;
    }

    return retValue;
}