Page tree

Versions Compared

Key

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

...

  1. Add a new method to your synthesis that transforms a State into a corresponding KNode:

    Code Block
    languagescala
    linenumberstrue
    private def KNode transform(State state) {
        val stateNode = state.createNode().associateWith(state);
    
        return stateNode;
    } 
  2. While this method does indeed create a node for the state passed to it, KLighD wouldn't know how to render it yet. Let's draw the node as a rounded rectangle by adding the following line before the return statement:

    Code Block
    languagejava
    linenumberstrue
    stateNode.addRoundedRectangle(4, 4, 2);
  3. The only thing missing now is a label with the state's name:

    Code Block
    languagejava
    linenumberstrue
    stateNode.addInsideCenteredNodeLabel(state.name,
        KlighdConstants.DEFAULT_FONT_SIZE,
        KlighdConstants.DEFAULT_FONT_NAME);
    stateNode.addLayoutParam(
        LayoutOptionsCoreOptions.NODE_SIZE_CONSTRAINTCONSTRAINTS,
        EnumSet.of(SizeConstraint.MINIMUM_SIZE, SizeConstraint.NODE_LABELS));
  4. Now that we know how to transform states, we have to call our new method from the main transformation method. Replace the comment in its body with the following line of code:

    Code Block
    languagescala
    linenumberstrue
    model.states.forEach[ s | root.children += transform(s) ]

...