I am looking for a way to make a curve line through several points. It would be preferable to use 3 points, although I believe that in order to give context to the corner of the line entering the point, it might take more to give the context of the curve, so to speak.
In general, the starting point P1, the control point P2 and the ending point P3, the line should be a curve P2 from P1, and then a curve from P2 to P3.
In fact, this is a great example of the effect I would like to achieve:

If I could do this, I would really be eternally grateful!
In Java, so far I have tried to play with things like QuadCurve2D.Double , Cub icCurve2D.Double , as well as Path2D.Double (using curveTo with Path2D.Double), but to no avail - the curves that are colored are not even close to passing through specified control point.
Here is an image of the methods I've tried so far:

And here is the code I used to create the points and curves in the image:
Graphics2D g = (Graphics2D) window.getGraphics(); g.setColor(Color.blue); int d = 4; // P0 int x0 = window.getWidth()/8; int y0 = 250; g.drawString("P0", x0, y0 + 4*d); g.fillRect(x0, y0, d, d); // P1 int x1 = (window.getWidth()/7)*2; int y1 = 235; g.drawString("P1", x1, y1 + 4*d); g.fillRect(x1, y1, d, d); // P2 int x2 = (window.getWidth()/2); int y2 = 200; g.drawString("P2", x2, y2 - 2*d); g.fillRect(x2, y2, d, d); // P3 int x3 = (window.getWidth()/7)*5; int y3 = 235; g.drawString("P3", x3, y3 + 4*d); g.fillRect(x3, y3, d, d); // P4 int x4 = (window.getWidth()/8)*7; int y4 = 250; g.drawString("P4", x4, y4 + 4*d); g.fillRect(x4, y4, d, d); g.setColor(Color.cyan); QuadCurve2D quadCurve = new QuadCurve2D.Double(x0, y0, x2, y2, x4, y4); g.draw(quadCurve); g.setColor(Color.YELLOW); CubicCurve2D.Double cubicCurve = new CubicCurve2D.Double((double)x0, (double)y0, (double)x1, (double)y1, (double)x2, (double)y2, (double)x4, (double)y4); g.draw(cubicCurve); g.setColor(Color.red); Path2D.Double path1 = new Path2D.Double(); path1.moveTo(x1, y1); path1.curveTo(x0, y0, x2, y2, x4, y4); g.draw(path1);
My reasons why I need to go through the curve in order to go through the points is that I want to “smooth out” the transition between the vertices on the graph that I wrote. Before anyone notices this, the JFree Chart is not an option . I understand that there are different types of curves and splines that are used, but I’m not very lucky in that they understand exactly how they work, or how to implement what suits my needs.
I would be very grateful for any help offered - Thanks in advance.