0
我想縮放形狀。爲什麼移動我在java中使用仿射變換的位置1.6se
所以我在仿射變換中使用setToScale方法。
那麼,不僅形狀的長度爲反式,而且形狀的出發點移動
爲什麼?
public void initResize(int x, int y) {
oldX = x;
oldY = y;
}
public void resize(int x, int y) {
double xratio = (double)(x - shape.getBounds().x)/(shape.getBounds().width);
double yratio = (double)(y - shape.getBounds().y)/(shape.getBounds().height);
af.setToScale(xratio, 1);
shape = af.createTransformedShape(shape);
anchor.resize(shape.getBounds());
oldX = x;
oldY = y;
}
方法調用的順序是MousePress:initResize,MouseDrgged:調整
的x,y是鼠標的座標
因爲這就是縮放比例。如果你想保留起點,你也需要翻譯。 –