4

When you use Graphics2D.scale(); and draw a shape, the outline thickness is also scaled.

Is there a way to draw it without the line thickness being scaled? Perhaps there's another efficient way to scale it other than using the above function?

Perry Monschau
  • 883
  • 8
  • 22

3 Answers3

1

This question is similar. It looks like you have to mess around with a Stroke object to set the right line width.

Community
  • 1
  • 1
Jose
  • 1,616
  • 4
  • 26
  • 38
0

You're going to have to save your drawing as a list of line vectors, and scale and render the drawing at various sizes to maintain the line thickness you want.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
0

I've just found a solution to my own question. I've no idea how efficient it is but it works as intended:

Area area = new Area(myShape); //myShape is the shape I want to scale
AffineTransform at = new AffineTransform();
at.scale(2,2);
area = area.createTransformedArea(at);
graphics2d.draw(area); //graphics2d is the Graphics2D instance to do the drawing

Perhaps someone could enlighten me as to whether or not this is a good approach to take?

Perry Monschau
  • 883
  • 8
  • 22