Graphics2D Drawing Performance

可紊 提交于 2020-01-03 02:37:05

问题


I am trying some things out with manually drawing "things" with a Java Graphics2D object within a Swing component and as I reach about >2000 squares that I order the object to draw it gets really slow.

I have no clue whether or not this is "common". Are 2000 objects to render really "a lot"? Is the Graphics2D object just not very performant? Should I just stop where I am now and rather switch to JOGL before I try out more complex stuff and it is too late?


回答1:


I wrote a Java Spirograph GUI that draws tens of thousands of line segments in 20 milliseconds or less.

Make sure you are doing your calculations elsewhere in your application. Your drawing code should do one thing and one thing only: draw.

However, there is a practical limit to the speed of Graphics and Graphics2D. This Spirograph took 172 milliseconds to draw over 250,000 line segments.



来源:https://stackoverflow.com/questions/13030891/graphics2d-drawing-performance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!