Child pages
  • Graphical Modeling with Graphiti

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The last section of this tutorial is about text labels in the graphical editor. We will use such labels for displaying state names and transition specifications. The steps required for these tasks are given only coarsely here, since you should now be able to find out yourself about the details using the Graphiti documentation.

  1. Add a Text element to states in the  StateAddFeature in order to display the name of each state.
  2. Create a new class StateDirectEditingFeature extending AbstractDirectEditingFeature and register it by overriding getDirectEditingFeature in the TuringFeatureProvider. This new feature is responsible for connecting the edited text with the name attribute of states with the in-diagram text editing box, i.e. retrieving the current text from the attribute and updating it after the user has entered a new value.
  3. Create a new class StateUpdateFeature extending AbstractUpdateFeature and register it by overriding getUpdateFeature in the TuringFeatureProvider. This new feature is responsible for updating the displayed text when the corresponding attribute in the domain model is changed outside the Graphiti editor. For example you could open the Turing Machine model with the Sample Reflective Ecore Model Editor in order to modify attributes. You can activate automatic updates of the diagram by extending isAutoUpdateAtRuntime (resp. Startup / Reset) in the TuringDiagramTypeProvider and returning true. The update feature can be invoked explicitly in other features by calling the superclass method updatePictogramElement.
  4. Create a new class StateLayoutFeature extending AbstractLayoutFeature and register it by overriding getLayoutFeature in the TuringFeatureProvider. This new feature is responsible for updating the position and size of graphics algorithms of a state when the state is resized in the graphical editor or when the displayed text for the state name is updated. The layout feature can be invoked explicitly in other features by calling the superclass method layoutPictogramElement.