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());
精彩评论