シェイプをスケーリングしたい。
だから私はアフィン変換で 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 : resize です。
x,y はマウス座標