<commit_before>package com.derniereligne.engine.board;

import com.derniereligne.engine.Color;
import java.io.ByteArrayOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.jdom2.filter.Filters;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;

/**
 * This class generate the SVG based on a description saved in a config file.
 *
 * @author jenselme
 */
public class SvgBoardGenerator {

    /**
     * The XML namespace for XPath.
     */
    private static final Namespace ns = Namespace.getNamespace("ns", "http://www.w3.org/2000/svg");
    /**
     * The XML namespace the the elements we add.
     */
    private static final Namespace svgNs = Namespace.getNamespace("http://www.w3.org/2000/svg");
    /**
     * The common XPathFactory to create XPathExpression.
     */
    private static final XPathFactory xPathFactory = XPathFactory.instance();
    /**
     * The folder in which we must save the SVGs.
     */
    private static final String svgFilePath = "src/main/webapp/WEB-INF/svg/";

    /**
     * The name of the SVG template file.
     */
    private final static String templateName = "template.svg";
    /**
     * The name of the SVG layer that will contain the board.
     */
    private final static String boardLayerId = "boardLayer";
    /**
     * The name of the board (used to save it in the correct file).
     */
    private final String boardName;
    /**
     * The SVG document object.
     */
    private Document document;
    /**
     * The node object representing the layer that will contain the board.
     */
    private Element layer;
    /**
     * The x coordinates of a square.
     */
    private int xid;
    /**
     * The y coordinates of a square.
     */
    private int yid;
    /**
     * How the color are disposed on the board.
     */
    private final List<List<Color>> colorDisposition;
    /**
     * The number of arms that the game has.
     */
    private final int numberOfArms;
    /**
     * The width of the arms.
     */
    private final int armsWidth;
    /**
     * The length of the arms.
     */
    private final int armsLength;
    /**
     * The x coordinate from which we start filling the board.
     */
    private final int originX;
    /**
     * The y coordinate from which we start filling the board.
     */
    private final int originY;
    /**
     * The description of the element used to fill the board.
     */
    private final HashMap<String, String> fill;
    /**
     * The width of the element used to fill the board.
     */
    private final int filledElementWidth;
    /**
     * The height of the element used to fill the board.
     */
    private final int filledElementHeigth;
    /**
     * The x coordinate of the rotation center of the board.
     */
    private final String filledElementTag;
    private final int rotationCenterX;
    /**
     * The y coordinate of rotation center of the board.
     */
    private final int rotationCenterY;
    /**
     * The lines of the element used to create the SVG (and not fill it).
     */<commit_msg>doc(SvgBoardGenerator): correct the doc of tow attributes.<commit_after>package com.derniereligne.engine.board;

import com.derniereligne.engine.Color;
import java.io.ByteArrayOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.jdom2.filter.Filters;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;

/**
 * This class generate the SVG based on a description saved in a config file.
 *
 * @author jenselme
 */
public class SvgBoardGenerator {

    /**
     * The XML namespace for XPath.
     */
    private static final Namespace ns = Namespace.getNamespace("ns", "http://www.w3.org/2000/svg");
    /**
     * The XML namespace the the elements we add.
     */
    private static final Namespace svgNs = Namespace.getNamespace("http://www.w3.org/2000/svg");
    /**
     * The common XPathFactory to create XPathExpression.
     */
    private static final XPathFactory xPathFactory = XPathFactory.instance();
    /**
     * The folder in which we must save the SVGs.
     */
    private static final String svgFilePath = "src/main/webapp/WEB-INF/svg/";

    /**
     * The name of the SVG template file.
     */
    private final static String templateName = "template.svg";
    /**
     * The name of the SVG layer that will contain the board.
     */
    private final static String boardLayerId = "boardLayer";
    /**
     * The name of the board (used to save it in the correct file).
     */
    private final String boardName;
    /**
     * The SVG document object.
     */
    private Document document;
    /**
     * The node object representing the layer that will contain the board.
     */
    private Element layer;
    /**
     * The x coordinates of a square.
     */
    private int xid;
    /**
     * The y coordinates of a square.
     */
    private int yid;
    /**
     * How the color are disposed on the board.
     */
    private final List<List<Color>> colorDisposition;
    /**
     * The number of arms that the game has.
     */
    private final int numberOfArms;
    /**
     * The width of the arms.
     */
    private final int armsWidth;
    /**
     * The length of the arms.
     */
    private final int armsLength;
    /**
     * The x coordinate from which we start filling the board.
     */
    private final int originX;
    /**
     * The y coordinate from which we start filling the board.
     */
    private final int originY;
    /**
     * The description of the element used to fill the board.
     */
    private final HashMap<String, String> fill;
    /**
     * The width of the element used to fill the board.
     */
    private final int filledElementWidth;
    /**
     * The height of the element used to fill the board.
     */
    private final int filledElementHeigth;
    /**
     * The tag of the element used to fill the board.
     */
    private final String filledElementTag;
    /**
     * The x coordinate of the rotation center of the board.
     */
    private final int rotationCenterX;
    /**
     * The y coordinate of rotation center of the board.
     */
    private final int rotationCenterY;
    /**
     * The lines of the element used to create the SVG (and not fill it).
     */
{'fraction_non_alphanumeric': 0.09487215313678916, 'fraction_numerical': 0.005588933910856504, 'mean_word_length': 2.478134110787172, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1918831', 'n_tokens_mistral': 2071, 'n_tokens_neox': 2046, 'n_words': 736}