I'm drawing a graph with a lot of points and edges.
I was able to make calculations for the position of the string so that it would be above the edge and in the middle in a way that was comfortable and easy to read.
When the graph has many vertices the action of writing the string disrupts the whole graph.
The following pictures show an example where the graph works on many vertices and then on fewer vertices.
Here the graph has more than 47 Vertices, and there are problems that cause my graph to disrupts
Here is the code I use to rotate the angle of the string, may the function of rotate cause the graph to disrupt if there are more than 48 vertices or something I don't get it yet.
public static void drawRotate(Graphics2D g2d, double x, double y, double angle, String text) {
g2d.translate((float)x,(float)y);
g2d.rotate(angle);
g2d.drawString(text,0,0);
g2d.rotate(-angle);
g2d.translate(-(float)x,-(float)y);
}

