Tuesday, November 3, 2015

GEF4 Tutorial - Part 2 - Text box

Note: there is a GEF5 Tutorial

In this step 2 of the tutorial, the model shall be changed to hold only a position, a text and the color. The size of the rectangle surrounding the text is done automatically by the part.

For the source code see github gef4.mvc.tutorial2

The ModelPart is now extending AbstractFXContentPart<Group>, so the visual representation can be composed of a rounded rectangle and a text.

The ModelPart first creates the Text object, uses a "through away Scene" to be able to retrieve the measurements of the text, than uses this information to setup the rectangle bounds and text position.

MVC structure

Compared to step 1, the visual is now a composition of multiple objects.


The result







No comments:

Post a Comment