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是鼠标的坐标
因为这就是缩放比例。如果你想保留起点,你也需要翻译。 –