Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Draggable Group

 
Otto J. Lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo all,
I need your help.
I'm trying to make some circle with label on it. After some searching, I found that to make a circle with label on it is to put it on a group.
The problem is now, as I'm trying to apply mouse dragging on that group, I don't get correct posX and posY for circle's new position. And it looks like that my dragg running with lags.
Here's my code, I hope you can get me some suggestions.
 
John Damien Smith
Ranch Hand
Posts: 298
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I don't get correct posX and posY for circle's new position

Here some sample code with the correct mathematics for the drag operation:



This is based on the related StackOverflow question:

* http://stackoverflow.com/questions/10682107/correct-way-to-move-a-node-by-dragging-in-javafx-2

> And it looks like that my dragg running with lags.

To get minimize of lag in the drag set: -Dprism.vsync=false as suggested by Xanatos for:

* http://stackoverflow.com/questions/10682107/correct-way-to-move-a-node-by-dragging-in-javafx-2

Note, I still get some lag with vsync set to false, but it is pretty minimal.
 
Otto J. Lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot! That's really what I need.
I will need a lot of those circle on my application, so I expanded your solution to my needed.
I will have some of those "circles" connected with each other, and that line have to react to the change of circle's position. So, I wrote:



I'm trying to follow this one:
https://gist.github.com/jewelsea/1441960

My questions now:
What have I missed from that example in my code? My line doesn't react to the circle's move.
And, is that possible to directly get the centerX and centerY from class StackPane contain my circle?
Sorry for this newbie questions.

Thanks a lot in advance!
 
John Damien Smith
Ranch Hand
Posts: 298
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For how to drag around circles that are connected by a line, see:

http://stackoverflow.com/questions/19748744/javafx-how-to-connect-two-nodes-by-a-line
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic