<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.graphviz.builder;

import com.google.common.base.Preconditions;
import com.google.common.escape.Escaper;
import com.google.common.escape.Escapers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
 * Honours all HTML attributes set on the node or ports.
 *
 * Attempts some portability between graphviz attributes and HTML attributes.
 *
 * @author shevek
 */
public class GraphVizRecordLabel {

    private static final Escaper ESCAPE_MINIMAL = Escapers.builder()
            .addEscape('\n', "<BR/>")
            .addEscape('\r', "")
            .build();

    private static String E(@Nonnull GraphVizLabel in) {
        return ESCAPE_MINIMAL.escape(in.getBuffer().toString());
    }

    private static final GraphVizHtmlAttribute[] ATTRIBUTE_NAMES = GraphVizHtmlAttribute.values();
    private static final Map<GraphVizHtmlAttribute, GraphVizAttribute> ATTRIBUTE_MAP = new EnumMap<GraphVizHtmlAttribute, GraphVizAttribute>(GraphVizHtmlAttribute.class);

    static {
        for (GraphVizHtmlAttribute a : ATTRIBUTE_NAMES)
            ATTRIBUTE_MAP.put(a, null);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.BGCOLOR, GraphVizAttribute.color);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.BORDER, GraphVizAttribute.penwidth);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.COLOR, GraphVizAttribute.fontcolor);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.HREF, GraphVizAttribute.href);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.TITLE, GraphVizAttribute.tooltip);

    }

    @CheckForNull
    private GraphVizNode node;
    private final List<GraphVizPort> ports;

    @Nonnull
    public GraphVizRecordLabel(@Nonnull GraphVizNode node, @Nonnull Collection<? extends GraphVizPort> ports) {<commit_msg>GraphVizRecordLabel: node is Nonnull.<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.graphviz.builder;

import com.google.common.base.Preconditions;
import com.google.common.escape.Escaper;
import com.google.common.escape.Escapers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
 * Honours all HTML attributes set on the node or ports.
 *
 * Attempts some portability between graphviz attributes and HTML attributes.
 *
 * @author shevek
 */
public class GraphVizRecordLabel {

    private static final Escaper ESCAPE_MINIMAL = Escapers.builder()
            .addEscape('\n', "<BR/>")
            .addEscape('\r', "")
            .build();

    private static String E(@Nonnull GraphVizLabel in) {
        return ESCAPE_MINIMAL.escape(in.getBuffer().toString());
    }

    private static final GraphVizHtmlAttribute[] ATTRIBUTE_NAMES = GraphVizHtmlAttribute.values();
    private static final Map<GraphVizHtmlAttribute, GraphVizAttribute> ATTRIBUTE_MAP = new EnumMap<GraphVizHtmlAttribute, GraphVizAttribute>(GraphVizHtmlAttribute.class);

    static {
        for (GraphVizHtmlAttribute a : ATTRIBUTE_NAMES)
            ATTRIBUTE_MAP.put(a, null);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.BGCOLOR, GraphVizAttribute.color);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.BORDER, GraphVizAttribute.penwidth);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.COLOR, GraphVizAttribute.fontcolor);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.HREF, GraphVizAttribute.href);
        ATTRIBUTE_MAP.put(GraphVizHtmlAttribute.TITLE, GraphVizAttribute.tooltip);

    }

    @Nonnull
    private GraphVizNode node;
    private final List<GraphVizPort> ports;

    @Nonnull
    public GraphVizRecordLabel(@Nonnull GraphVizNode node, @Nonnull Collection<? extends GraphVizPort> ports) {
{'fraction_non_alphanumeric': 0.09123307198859587, 'fraction_numerical': 0.0, 'mean_word_length': 4.242839352428393, 'pattern_counts': {'":': 0, '<': 13, '<?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': '6820199', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1242, 'n_words': 285}