This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

JavaFX 1st attempt - display geometry scenegraph

 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to connect a pojo holding all the required xy coordinates, to a javafx scene graph, and cannot work out how to do this. It is a simple Javafx scene graph created with scenebuilder; a circle and three lines, and an exit button.

How do I connect the pojo holding with coords to javafx scene graph?

So far I have, all within a javafx enabled project in e(fx)clipse:
1) "classA": GeometryCalculator class, includes a member class object GeometryResultsObj
The output of classA is one instance of classB. This is in a for loop to run from 1-360 degrees, overwriting classB for each change.
2) "classB": GeometryResultsObj stores, the circle diameter, circle xy centre, 3 lines xy start & end coords
3) "classC": GeometryGraphic.java contains main() with launch() and start()
4) "classD": GeometryGraphic.fxml with a static circle and three lines (waiting to be animated)
5) "classE": GeometryGraphicController java class, contains initialize() and initData(classB coords).

ClassA is tested and calculates ok.
ClassB is correctly populated when classA is run.
ClassC when run, displays the scenegraph with circle & lines in their original positions, with no errors.

I've tried creating an initData method on the controller class which does a set on each fxml object with a get on the relevant pojo field. If I run the controller there is no classB of coordinates to read, but it runs ok, and displays the graphic with circle and lines in their initial positions.

AIM:
To run the series of outputs to the scenegraph for 1-360 events, with a next button, so they can be visually checked for incorrect logic in classA. It would also be great to add a play button, with slow & fast slider to view a continously animated output.

The structure probably isn't quite right, as the driver is the ClassA. Driving from ClassC finds no ClassB with coordinate data. ClassA could be changed quite easily to create a result object per iteration (1-360) and add these to a collection.

Can you please advise how to link the graph to the coordinates, and how this should be restructured to enable this.
The nearest I can think of is calling the method in ClassA at the beginning of the controller classE's initData function?

I haven't included code as it would be a lot to post, even a cut down version. Advice on the correct approach & structure would be very much appreciated.

Thank you!
 
John Damien Smith
Ranch Hand
Posts: 298
14
 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I posted it on stackexchange yesterday. I was unaware of the term cross posting, and the policy - apologies if that has offended anyone.
I haven't had a reply from either site. Are you able to help?
 
John Damien Smith
Ranch Hand
Posts: 298
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find your question a bit specific and detailed for your particular case, so a detailed answer wouldn't be of much use to anybody else. It is also difficult for me to understand your requirements well enough to provide a good specific answer or advice on program structure.

I think there are some things you can study which may be related and may help you in your quest (from simpler to more complicated);

1. See the answer to JavaFX: How to connect two Nodes by a Line?. This binds a point co-ordinate representing the center of a node, so as the co-ordinate varies, so does the node position. This link is probably most relevant to what you are trying to do.
2. A JavaFX ball simulation which uses vectors to represent the location, speed and direction of nodes (on a canvas rather than a scene graph).
3. An Inverse Kinematics library for JavaFX, which uses "bones" to represent node co-ordinates and rotations as detailed in a inverse kinematics tutorial.
4. Connecting JavaFX and Box2D.
5. Wiring JavaFX and Physics engines together.

Reproducing the code from the StackOverflow link in case it goes dead:


 
Nigel Shrin
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
many thanks for the links and example code, very much appreciated, I'll work through these examples at the weekend.

Cheers!
Nigel
 
John Damien Smith
Ranch Hand
Posts: 298
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great. Hope its helpful :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic