Android路径实时图表

编程入门 行业动态 更新时间:2024-10-27 06:31:01
本文介绍了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路径实时图表

本文发布于:2023-11-10 10:32:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575113.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   路径   实时   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!