开发者

How to get the new height of a scaled Shape in Java

开发者 https://www.devze.com 2023-03-14 09:52 出处:网络
I am scalling a shape for a specific point as follows : 开发者_C百科AffineTransform t = shape.getAffineTransform();

I am scalling a shape for a specific point as follows :

  开发者_C百科              AffineTransform t = shape.getAffineTransform();

                AffineTransform translatAffine =AffineTransform.getTranslateInstance(-cx, -cy);
                AffineTransform scaleAffine= AffineTransform.getScaleInstance(sx,sy);
                scaleAffine.concatenate(translatAffine); 
                translatAffine = scaleAffine;

                scaleAffine =AffineTransform.getTranslateInstance(cx, cy);
                scaleAffine.concatenate(translatAffine);
                translatAffine = scaleAffine;                   

                scaleAffine= new AffineTransform(t);
                translatAffine.concatenate(scaleAffine); 
                shape.setAffineTransform(translatAffine);

When I try to get the new height with shape.getHeight(), I get the initial height


I found a work a round by getting the affineTransform and calculating the new height. I added the follwing line to the code above

System.out.println("The new height :"+ shape.getHeight() *  shape.getAffineTransform().getScaleX());
0

精彩评论

暂无评论...
验证码 换一张
取 消