Re: rescale using affineTransform, but scaling factor isn't quite honored?
- From: Knute Johnson <nospam@xxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Dec 2005 20:03:43 -0800
Graham Street wrote:
Hi, I'm using affineTransform to rescale a polygon to fit in the screens area. If the shape is 25% smaller than the drawing area, then the shape is increased by 25%. Each side of the shapes length in inches is initially the same as the length of the side in pixels.
I need the lengths to stay the same when I re-scale the polygon... To acheive this, I'm storing the "factor" that I'm supplying to AffineTransform... Then, in my getLength() method I divide by this same number to "reverse" the transform and get the real edge length. Sometimes it works great (less than half) but usually it is off. It's usually off by less than 1, but occasionally by some huge amount like 30%.
I was thinking this was a casting problem, but it seems to be something a little trickier. It seems that the affineTransform scale is actually not using the same scaling factor all the time.. Does anyone knw what variables might throw this off and how I might be able to control it?
Thanks! Graham Street
Does it appear to change as you run your program? Is it possible that you aren't resetting the transform back to the original when you are done and you are transforming the transform?
public void paint(Graphics g) {
AffineTransform at = g.getTransform();
g.scale(x,y);
g.draw(something);
g.setTransform(at);--
Knute Johnson email s/nospam/knute/ .
- References:
- rescale using affineTransform, but scaling factor isn't quite honored?
- From: Graham Street
- rescale using affineTransform, but scaling factor isn't quite honored?
- Prev by Date: Re: Input Verifier for JComboBox
- Next by Date: Re: color pallet
- Previous by thread: rescale using affineTransform, but scaling factor isn't quite honored?
- Next by thread: JTextArea not producing events
- Index(es):
Relevant Pages
|