Scaling Lines

Hi,

I've written a java program which paints a number

of lines, and the scene can be scaled or rotated.

When the scene is scaled up, the lines increase

in size not only in length but in width. What

is the best way of ensuring the lines stay the

same width regardless of scale? Are there any

transformation geometry routines that could do

this?At the moment, my paint routine does it

this way:

protectedvoid paintComponent(Graphics g){

super.paintComponent(g);

Graphics2D g2 = (Graphics2D) g;

BasicStroke solid =new BasicStroke((float)(3.0 * (1/myScale)));

g2.scale(myScale, myScale);

....

.... (paint lines here)

Also, my program paints a few dashed lines.

But I'm finding that as I increase or decrease the

scale, the blank space between each dash varies to

the point where the dashes space out too much, or

the lines look completely solid.Do I solve this

problem in a similar way as above?

Thanks.

[1207 byte] By [stretch65a] at [2007-10-3 4:22:03]
# 1

What is the best way of ensuring the lines stay the

same width regardless of scale?

Apply your AffineTransform to the lines and not to the graphics context. Scaling the

graphics context is like looking at it through a magnifying glass/telescope. Scaling only

the geometry primitives, your lines, changes their size but not their width. Their width is

controlled by the stoke set in the graphics context. So you are separating the way your

lines are rendered in the graphics context from the size of them which you control with the

AffineTransform.

74philipa at 2007-7-14 22:24:19 > top of Java-index,Security,Cryptography...
# 2
Thanks for your help.
stretch65a at 2007-7-14 22:24:19 > top of Java-index,Security,Cryptography...