采摘在Java 2D的 [英] Picking in java 2d

查看:151
本文介绍了采摘在Java 2D的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Java2D绘制在我已经实现通过调用包含(MousePoint)为每个对象/形状,这工作,但采摘的那一刻起简单的图形线性扩展。

I am using java2d to draw a simple graph at the moment I have implemented picking by calling contains(MousePoint) for each object/shape, this works but scales linearly.

有没有更有效的在Java2D的采摘方法是什么?

Is there a more efficient method for picking in java2d?

推荐答案

是的,但是完整的答案就太长了这个空间。

Yes, although the full answer would be too long for this space.

首先,除非你有一个的很多的节点,然后直线将最有可能被罚款,你不应该改变什么的除非的性能已经看到吃亏。

First of all, unless you have a lot of nodes, then linear will most likely be fine, and you shouldn't change anything unless performance is already seen to suffer.

二,你想要什么,在一般情况下,是应用了某种层次分解,如四叉树。这是使用更多的存储器(和更多的时间前面,在搜索过程中摊销),以消除在一个所谓的宽泛阶段从考虑的项目的方式。一些尽职调查在网络上会有所帮助,因为会把书实时碰撞检测,由克里斯特埃里克松。

Second, what you want, in general, is to apply some sort of hierarchical decomposition, such as a quadtree. This is a way of using more memory (and more time up front, amortized during searches) to eliminate items from consideration in a so-called "broad phase". Some diligence on the web will help, as will the book "Real-Time Collision Detection", by Christer Ericson.

这篇关于采摘在Java 2D的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆