开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜