我在尝试翻转我创建的坐标系的 y 轴时遇到了一个奇怪的问题:
private AffineTransform getTransform() {
if (transform == null) {
transform = new AffineTransform();
double scaleX = (double) this.getWidth() / (coordinateSystem.getMaxX() - coordinateSystem.getMinY());
double scaleY = (double) this.getHeight() / (coordinateSystem.getMaxY() - coordinateSystem.getMinY());
transform.setToScale(scaleX, scaleY);
double deltaX = (coordinateSystem.getMaxX() - coordinateSystem.getMinX()) / 2;
double deltaY = (coordinateSystem.getMaxY() - coordinateSystem.getMinY()) / 2;
transform.translate(deltaX, deltaY);
}
return transform;
}
AffineTransform 设置为缩放和平移。一切正常,除了我的 y 值是倒置的(最大值是坐标系的底部,最小值是顶部)。我尝试通过反转 y 轴的比例因子来切换它。但这不起作用。
我是否必须让变换按 PI 旋转,以实现翻转的 y 轴?将 y 轴的比例因子乘以负 1 不应该相同吗?