Android路径实时图表 [英] Android Paths for real time charting

查看:328
本文介绍了Android路径实时图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Android中创建一个实时图表实用程序,并且在大多数情况下它的工作,除了当我在我的一个路径中获取太多的数据点,它打破了OpenGL。我使用路径,因为我通过矩阵转换整个数据集,当传入的值超出图的当前边界。我这个错误的方式吗?有没有更好的/更适当的API这种事情?我很乐意修剪路径到当前边界,如果可能/我知道如何做到。感谢!



onDraw:

  @覆盖
void onDraw(Canvas canvas){
scaleX = getWidth()/(maxX - minX);
scaleY = getHeight()/(maxY - minY);
// TODO:使用剪辑来绘制x / y轴,允许在属性中定义颜色等等。
canvas.drawColor(0xFF000000);
for(DataLine line:mPathList.values()){
canvas.drawPath(line,line.getPaint());
}
}

(DataLine是Path的子类,对象)



错误是来自OpenGLRenderer的警告:
形状路径太大,无法渲染到纹理

解决方案

如果你查看你的日志,你会注意到这样的错误:


04-04 10:39:06.314:W / OpenGLRenderer(6092):形状路径太大,无法渲染到纹理中


由于打开硬件加速,一切都被渲染为纹理,并且纹理有一个大小限制。如果你把较大的形状分解成较小的形状,这将解决你的问题。或者只需关闭硬件加速:

  android:hardwareAccelerated =false
/ pre>

I'm trying to create a real-time charting utility in android, and for the most part it works, except that when I get too many data points in one of my Paths it breaks openGL. I'm using paths because I'm transforming the entire dataset via matrix when a passed in value is outside the current bounds of the graph. Am I going about this the wrong way? is there a better/more appropriate API for this sort of thing? I'd be happy to trim the path to the current bounds if that were possible/I knew how to do it. Thanks!

onDraw:

  @Override
  protected void onDraw(Canvas canvas) {
    scaleX = getWidth()  / (maxX - minX);
    scaleY = getHeight() / (maxY - minY);
    // TODO: Use clips to draw x/y axis, allow color to be defined in attributes, etc.
    canvas.drawColor(0xFF000000);
    for (DataLine line : mPathList.values()) {
      canvas.drawPath(line, line.getPaint());
    }
  }

(DataLine is a subclass of Path that includes a Paint object)

Error in question is a warning from the OpenGLRenderer: "Shape path too large to be rendered into a texture"

解决方案

If you looked in your logs you will notice an error like so:

04-04 10:39:06.314: W/OpenGLRenderer(6092): Shape path too large to be rendered into a texture

Since turning on hardware acceleration everything gets rendered as a texture and there is a size limit for textures. If you break down the larger shapes into smaller ones, that will solve your problem. Or just turn off hardware acceleration:

android:hardwareAccelerated="false"

这篇关于Android路径实时图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆