JComponent JPanel Zoom, pan and Coordinates Question

旧城冷巷雨未停 提交于 2019-12-20 04:52:49

问题


I have a JPanel with an vector image that the user can zoom and pan on. Overlaying this image is a (transparent) JComponent, which I allow the user to annotate the underlying image. This works great at full scale, but If I zoom in, using AffineTransform, the overlaying coordinates are affected also. So, If a user draws a box on the image the box is scaled also.

Any suggestions on how to decouple this behaviour? So that the JComponent is not affected by the JPanel's AffineTransform?


回答1:


Typically, you need both a forward and inverse transform to translate between the two co-ordinate systems. In this example, the scaling equations are explicit; in this alternate approach, a second AffineTransform is used.



来源:https://stackoverflow.com/questions/4292174/jcomponent-jpanel-zoom-pan-and-coordinates-question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!