<commit_before>package com.abstratt.mdd.modelrenderer.uml2dot;

import org.eclipse.uml2.uml.CallEvent;
import org.eclipse.uml2.uml.Event;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Pseudostate;
import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.Trigger;
import org.eclipse.uml2.uml.Vertex;

import com.abstratt.mdd.modelrenderer.dot.DOTRenderingUtils;
import com.abstratt.modelrenderer.IEObjectRenderer;
import com.abstratt.modelrenderer.IRenderingSession;
import com.abstratt.modelrenderer.IndentedPrintWriter;

public class VertexRenderer<V extends Vertex> implements IEObjectRenderer<V> {
    @Override
    public boolean renderObject(V element, IndentedPrintWriter out, IRenderingSession context) {
        out.print('"' + getVertexSymbol(element) + "\" [");
        out.println("label = \"" + getVertexLabel(element) + "\"");
        out.println("shape = \"mrecord\"");
        out.println("style = \"rounded\""); 
        out.println("];");
        renderTransitions(element, out, context);
        return true;
    }

    protected String getVertexSymbol(V element) {
        return element.getName();
    }

    protected String getVertexLabel(V element) {
        return element.getName();
    }
    
    private void renderTransitions(V element, IndentedPrintWriter out, IRenderingSession context) {
        Vertex source = element;
        
        element.getOutgoings().forEach((Transition transition) -> {
            Vertex target = transition.getTarget();
            boolean mutual = target.getOutgoings().stream().anyMatch(it -> it.getTarget() == source);
            
            transition.getTriggers().forEach((Trigger trigger) -> {
                String triggerLabel = getEventName(trigger.getEvent());
                renderTransition(source, target, out, mutual, triggerLabel);
            });
            
            if (transition.getTriggers().isEmpty()) {
                renderTransition(source, target, out, mutual, "");
            }
        });
    }

    private void renderTransition(Vertex source, Vertex target, IndentedPrintWriter out, boolean mutual, String transitionLabel) {
        out.print("\"" + source.getName() + "\":out -- " + "\"" + target.getName()
                + "\":in "); 
        out.println("[");
        out.enterLevel();
        DOTRenderingUtils.addAttribute(out, "label", transitionLabel);
        DOTRenderingUtils.addAttribute(out, "constraint", "" + mutual);
        DOTRenderingUtils.addAttribute(out, "arrowhead", "open");
        DOTRenderingUtils.addAttribute(out, "arrowtail", "tail");
        DOTRenderingUtils.addAttribute(out, "style", "solid");
        out.exitLevel();
        out.println("]");
    }<commit_msg>final state lower in the chart<commit_after>package com.abstratt.mdd.modelrenderer.uml2dot;

import org.eclipse.uml2.uml.CallEvent;
import org.eclipse.uml2.uml.Event;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Pseudostate;
import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.Trigger;
import org.eclipse.uml2.uml.Vertex;

import com.abstratt.mdd.modelrenderer.dot.DOTRenderingUtils;
import com.abstratt.modelrenderer.IEObjectRenderer;
import com.abstratt.modelrenderer.IRenderingSession;
import com.abstratt.modelrenderer.IndentedPrintWriter;

public class VertexRenderer<V extends Vertex> implements IEObjectRenderer<V> {
    @Override
    public boolean renderObject(V element, IndentedPrintWriter out, IRenderingSession context) {
        out.print('"' + getVertexSymbol(element) + "\" [");
        out.println("label = \"" + getVertexLabel(element) + "\"");
        out.println("shape = \"mrecord\"");
        out.println("style = \"rounded\""); 
        out.println("];");
        renderTransitions(element, out, context);
        return true;
    }

    protected String getVertexSymbol(V element) {
        return element.getName();
    }

    protected String getVertexLabel(V element) {
        return element.getName();
    }
    
    private void renderTransitions(V element, IndentedPrintWriter out, IRenderingSession context) {
        Vertex source = element;
        
        element.getOutgoings().forEach((Transition transition) -> {
            Vertex target = transition.getTarget();
            boolean mutual = target.getOutgoings().stream().anyMatch(it -> it.getTarget() == source);
            boolean constraint = mutual || (target instanceof Pseudostate);
            transition.getTriggers().forEach((Trigger trigger) -> {
                String triggerLabel = getEventName(trigger.getEvent());
                renderTransition(source, target, out, constraint, triggerLabel);
            });
            
            if (transition.getTriggers().isEmpty()) {
                renderTransition(source, target, out, constraint, "");
            }
        });
    }

    private void renderTransition(Vertex source, Vertex target, IndentedPrintWriter out, boolean constraint, String transitionLabel) {
        out.print("\"" + source.getName() + "\":out -- " + "\"" + target.getName()
                + "\":in "); 
        out.println("[");
        out.enterLevel();
        DOTRenderingUtils.addAttribute(out, "label", transitionLabel);
        DOTRenderingUtils.addAttribute(out, "constraint", "" + constraint);
        DOTRenderingUtils.addAttribute(out, "arrowhead", "open");
        DOTRenderingUtils.addAttribute(out, "arrowtail", "tail");
        DOTRenderingUtils.addAttribute(out, "style", "solid");
        out.exitLevel();
        out.println("]");
    }
{'fraction_non_alphanumeric': 0.13134851138353765, 'fraction_numerical': 0.0035026269702276708, 'mean_word_length': 3.0705630791161798, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5049651', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1606, 'n_words': 297}