当我试图翻转我创建的坐标系的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不应该是相同的吗?
发布于 2010-12-21 19:42:38
你有一个打字错误
double scaleX = (double) this.getWidth() / (coordinateSystem.getMaxX() - coordinateSystem.getMinY());(最后一个Y应该是X。)也许就是这样。
发布于 2010-12-22 02:41:40
通过PI旋转实际上根本不是一个正确的解决方案,因为它将翻转X轴和Y轴。
https://stackoverflow.com/questions/4498171
复制相似问题