在javafx中是否有任何矩形选择的实现? [英] Is there are any implementation of rectangle selection in javafx?

查看:236
本文介绍了在javafx中是否有任何矩形选择的实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是在文件管理器中,当你点击,拖动鼠标,创建矩形选择并在创建鼠标释放选择后?

I mean like in file managers, when you would click, drag the mouse, creating a rectangle selection and after the mouse released selection is created?

我能做什么像这样(pseude-code like):

I could do that like this (pseude-code like):

onMousePressed:
setGestureStarted(true)

onMouseMoved:
if isGestureStarted:
   changeRectangle(event.getX, event.getY)

onMouseReleased:
   select(getSelectionRectange())

但我认为这是非常常见的行为,也许它已经在框架中了。

But I thought that it's pretty common behavior and maybe it's already in framework.

EDIT1:

我试图做zoomable线图。我实际上遇到了图书馆。
这是相当不错的,但可能会更好。
现在我正在考虑我们的web项目中javaFX的实际价值,因为我不喜欢可缩放图表这样的东西不在库中。使用javascript可能会更好(除了我应该先学习它,但它不应该那么难)。

I was trying to do zoomable linechart. And I actually came across library to do that. It's pretty good, but could be better though. Right now I'm considering the actual worth of javaFX in our web project, because I don't like how such thing as zoomable chart is not in the library. Probably would be better with javascript (except I should learn it first, but It shouldn't be that hard).

推荐答案



你可能需要为此自己实现。我发现你的伪代码很安静。如果您想选择任何组件,那么您需要首先创建一个简单的矩形边界,这可以通过伪代码轻松实现。


You would probably need to make your own implementation for this. I found your pseudo code is quiet good. If you like to select for any component then you need to first create a simple rectangular boundary which is easily possible by your pseudo code.

现在找出你的节点在那个边界内,然后你需要使用这个函数迭代某些父对象的所有节点/子节点:节点相交检查

Now for finding out either your node is inside that boundary then you need to do iteration of all the nodes/children of certain Parent Object by using this function: Node Intersect check

我建议在 onMouseReleased 之后使用该功能,或者如果您想实时查看内容,那么最好是 onMouseMoved

I would suggest to use that function after the onMouseReleased or if you like to see things in realtime then it is preferable in onMouseMoved

这篇关于在javafx中是否有任何矩形选择的实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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