Android实时图形调整用户触摸屏

标签 android real-time graphing

是否有任何现有的 Android 图形库可以让我绘制一条具有可调节数量的线段的线,并且可以实时触摸和拖动?我目前有一个使用 androidplot 的工作应用程序,它可以捕获我正在扫描的图像并绘制该数据的图表。我需要图表下方的可调整线段,以便用户可以选择将从数据收集的曲线和可调整线之间积分的区域。

我无法在 androidplot 中找到任何可以让我执行此操作的内容,如果需要的话,我可以切换图形库。

最佳答案

尝试查看路径。这可能是最容易使用的类。

class Graph extends View {
    Graph(Context context) {
        super(context);
        // ... Init paints
    }

    @Override public void onDraw(Canvas canvas) {
        canvas.save(MATRIX_SAVE_FLAG);

        // Draw Y-axis
        canvas.drawLine(axisOffset, axisOffset, axisOffset, canvasHeight-axisOffset, paint);
        // Draw X-axis
        canvas.drawLine(axisOffset, canvasHeight-axisOffset, canvasWidth-axisOffset, canvasHeight-axisOffset, paint);
        canvas.drawPath(new RectF(0.0f, 0.0f, 1.0f, 1.0f), mPath, paint);
        canvas.restore();
    }

    Path mPath = new Path(); // your open path
    float canvasWidth = 1.0f;
    float canvasHeight= 1.0f;
    float axisOffset = 0.1f; // The offset from the border of the canvas

    public void registerDataPlot(int xCoord, int yCoord) {
        // You need to convert the plot data to a location on the canvas
        // Just find the percent value from the base of the axis
        float x = xCoord / (canvasWidth - (2*axisOffset));
        float y = yCoord / (canvasHeight - (2*axisOffset));
        mPath.lineTo(x, y);
    }

关于Android实时图形调整用户触摸屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6612279/

相关文章:

Android:如何为应用程序设置文化值

java - 图像和字符串数组的 ListView 不起作用

Android Canvas 路径实时性能

javascript - 在 jQuery 浮点图上添加或突出显示单个点?

android - 通过单击 ListView 项目发送字符串

javascript - Node.js 应通知哪个用户

java - 以格式 HH :MM:SS 连续减少 java 中的时间

r - 如何将列表中的标题添加到一系列直方图?

iphone - 在 iPad/iPhone 上创建图表

android - 将一项 Activity 的主页按钮更改回左箭头