Java AffineTransform 移动原点

发布于 2024-07-27 01:38:36 字数 59 浏览 14 评论 0原文

我想将原点从组件的左上角移动到底部中间? 我一直在玩 AffineTransform 类无法让它工作?

I would like to move the origin from top left to bottom middle of the component?
I have been playing with AffineTransform class could not get it to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑饮青盏花 2024-08-03 01:38:36

您将需要尝试绘制的组件的高度和宽度。 假设您使用 Paint(Graphics g) 方法,最简单的方法是:

paint(Graphics g){

Graphics2D g2 =  (Graphics2D)g;

g2.translate( component.getWidth()/2.0, component.getHeight()/2.0);

//...

}

You will need the height and width of the component that you are trying to draw. Assuming you are in the paint(Graphics g) method the simplest way is:

paint(Graphics g){

Graphics2D g2 =  (Graphics2D)g;

g2.translate( component.getWidth()/2.0, component.getHeight()/2.0);

//...

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文