Re: AffineTransform.getScaleInstance question



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/

.



Relevant Pages

  • Re: When Cap comes back...
    ... the costume has virtually always been drawn with the ... scales...in the old days, it was mostly a faint hint of scale pattern, ... like chain mail rather than scale ... Most of those are actually chainmail. ...
    (rec.arts.comics.marvel.universe)
  • Re: 1Re: Problems with the radio carbon dating of the Newport Tower
    ... entitled to assume that that plan is drawn to scale. ... connected to your graphics card by an analog or digital connection? ... pixels* are independent of the screen display. ...
    (sci.archaeology)
  • Re: 1Re: Problems with the radio carbon dating of the Newport Tower
    ... entitled to assume that that plan is drawn to scale. ... both of which use vector graphics. ... pixels* are independent of the screen display. ...
    (sci.archaeology)
  • Re: Drawing images on a JPanel
    ... Knute Johnson wrote: ... background will be drawn if it is opaque and you call ... That is apparently the one real difference ...
    (comp.lang.java.programmer)
  • RE: Print Preview colors
    ... After further testing it appears that the problem isn't caused by the amount ... Printing goes fine at every scale. ... "Arno" wrote: ... > The preview works fine but only the images are drawn not correct. ...
    (microsoft.public.vc.mfc)