Saturday, January 25, 2020

GEF5 Tutorial - Part 3 - Model updates

In step 3 of this tutorial, the model, the parts and the visuals are compositions of multiple objects. Each model node type is mapped with the ModelPartFactory to a corresponding content part (ModelPart and TextNodePart).

For the source of this tutorial step see github - gef5.mvc.tutorial3.


In the previous example the model was a flat list of objects, now we have a tree like model. One instance of Model having 2 childs of TextModel.

The model and part elements need to implement some type of update mechanism. Here the bean property listeners are used. You might use the javafx ObservableValues or something else.
However, in the end the "refreshVisual()" of the part needs to be called.

This example has a button on the top, that applies changes to the model. So the text and the position of the boxes is varied.



No comments:

Post a Comment