How to draw a curve consisting of multiple line segments in a non-jagged way

Viewed 622

I am trying to write a program that puts incoming USB data onto a line graph. The way I have done this is by drawing onto the canvas a bunch of straight lines connecting all the data points. The problem is that the resulting line is not smooth, as you can see below:

Jagged Line

I tried using Graphics Context's lineTo(x, y) method but that just made it worse. I also tried changing the Line Cap and Line Join parameters but that didn't help much.

Is there a better way to play "Connect the Dots" with JavaFX Graphics Context? Perhaps with bezier curves? If there is, then please let me know.

1 Answers
Related