I have to draw a diagram. And I use the AWT Library to do that.
The problem is, that I need to draw really thin lines. But I always get lines that are too thick.
Here you can see, what I mean.

Here is the code that draw these lines
BufferedImage image = new BufferedImage(300, 60, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.createGraphics();
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.BLACK);
g2.setStroke(new BasicStroke(0.001f,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
Shape s = new Line2D.Double(new Point2D.Double(x_pos, unten - 9),
new Point2D.Double(x_pos, unten - 4));
g2.draw(s);
Instead of
Shape s = new Line2D.Double(new Point2D.Double(x_pos, unten - 9),
new Point2D.Double(x_pos, unten - 4));
g2.draw(s);
try using
g2.drawLine(x_pos, unten - 9, x_pos, unten - 4);
The Shape stuff is not really able to cope with thicknesses lower than 1... (as far as I know)
And please don't mix different languages while coding, this gives me eye cancer (even if it is german) :P. Best is, to just stick with english variable names as all the keyword are english too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With