Re: AffineTransform.getScaleInstance question
- From: dtown22@xxxxxxxxx
- Date: 24 Aug 2006 10:07:01 -0700
Hi Knute,
You are correct, I want the shape to be drawn from the mouse position
upwards and to the right, I want to scale the shape so that it seems
like it is growing. My shape is actually a little more complex than a
square, so clipping it would make it look wierd.
I ran your example, and it is close to what i want, I like how it grows
from the bottom up, but I want it to start growing from the point of
the mouse click, rather than the bottom of the frame. I tried playing
with the transfrom, but I didn't have any luck.
Also, why do i not need to dispose g2? is most examples I have seen,
this seems to be the common practice, so I took it as a required step.
thanks!
Knute Johnson wrote:
dtown22@xxxxxxxxx wrote:
Ok,
So I have an example...in this example, I only mess with the y-scale,
and the shape gets drawn from the top down to the point where the mouse
is clicked.
I want it to come down the other way, where as i want the shape to
appear as if it is coming upwards.
So do you want to click the mouse at a point and have the shape drawn
from the mouse position up and to the right? Does it need to be scaled
or can you just clip it?
Try changing your paintComponent() to mine below and tell me if that is
what you were trying to get here.
public void paintComponent(Graphics g) {
super.paintComponent(g); // you may not need this line
if(shape != null) {
Graphics2D g2 = (Graphics2D) g;
g2.rotate(Math.PI,250,250);
g2.scale(1, scale);
Shape s = g2.getTransform().createTransformedShape(shape);
g2.fill(s);
g2.dispose(); // you don't need this line
}
}
--
Knute Johnson
email s/nospam/knute/
.
- Follow-Ups:
- Re: AffineTransform.getScaleInstance question
- From: Knute Johnson
- Re: AffineTransform.getScaleInstance question
- From: dtown22
- Re: AffineTransform.getScaleInstance question
- References:
- AffineTransform.getScaleInstance question
- From: dtown22
- Re: AffineTransform.getScaleInstance question
- From: Knute Johnson
- Re: AffineTransform.getScaleInstance question
- From: dtown22
- Re: AffineTransform.getScaleInstance question
- From: Knute Johnson
- AffineTransform.getScaleInstance question
- Prev by Date: Rendering CAD/GIS Data on a Map Canvas
- Next by Date: Using HTML in Swing components with Linux
- Previous by thread: Re: AffineTransform.getScaleInstance question
- Next by thread: Re: AffineTransform.getScaleInstance question
- Index(es):
Relevant Pages
|