Alternatives to drawing with Swing components
We're making a program that are required to draw about 200000 lines of different kinds. At the moment we are using Swing to draw on a component, but it really isn't fast enough.
The question: Are there any faster way to draw lines, than the Swing library. Is AWT faster, is OpenGL the way to roll (and is it fas开发者_如何学JAVAter) and so on.
With the little information you provide the only thing i can recommend you is to try to use the class :
javafx.scene.shape.Line;
I think you are probably ussing.
java.awt.geom.Line2D;
awt components used to be in applets and they are heavyweight if you use them, that might be a reason of your performance issues.
Have a look at JavaFX ( www.javafx.com ) maybe you find some component that suits your needs(faster).
Here an example how to draw a line in Java using Graphics2D: http://www.javadb.com/drawing-a-line-using-java-2d-graphics-api
精彩评论