<commit_before>import Template from "./template";
import paper from "paper";

export default class GradientGenerator extends Template {
    constructor() {
        super();
    }

    __setupDefinitions() {
        this.__unique = {
            position: "Point"
        };

        this.__heritable = {
            bendSpacing: "Float",
            numberOfBends: "Float",
            channelWidth: "Float",
            bendLength: "Float",
            in: "Float",
            out: "Float",
            spacing: "Float",
            height: "Float",
            rotation: "Float"
        };

        this.__defaults = {
            channelWidth: 0.8 * 1000,
            bendSpacing: 1.23 * 1000,
            numberOfBends: 1,
            rotation: 0,
            bendLength: 2.46 * 1000,
            in: 1,
            out: 3,
            spacing: 10000,
            height: 250,
            rotation: 0
        };

        this.__units = {
            bendSpacing: "&mu;m",
            numberOfBends: "",
            channelWidth: "&mu;m",
            bendLength: "&mu;m",
            
            in: "",
            out: "",
            spacing: "&mu;m",
            height: "&mu;m",
            rotation: "&deg;"
        };

        this.__minimum = {
            channelWidth: 10,
            bendSpacing: 10,
            numberOfBends: 1,
            rotation: 270,
            bendLength: 10,
            in: 1,
            out: 3,
            spacing: 10,
            height: 10
        };

        this.__maximum = {
            channelWidth: 2000,
            bendSpacing: 6000,
            numberOfBends: 20,
            rotation: 270,
            bendLength: 12 * 1000,
            in: 30,
            out: 90,
            spacing: 90000,
            height: 1200
        };

        this.__featureParams = {
            position: "position",
            channelWidth: "channelWidth",
            bendSpacing: "bendSpacing",
            numberOfBends: "numberOfBends",
            rotation: "rotation",
            bendLength: "bendLength",
            in: "in",
            out: "out",
            spacing: "spacing",
        };

        this.__targetParams = {
            channelWidth: "channelWidth",
            bendSpacing: "bendSpacing",
            numberOfBends: "numberOfBends",
            rotation: "rotation",
            bendLength: "bendLength",
            in: "in",
            out: "out",
            spacing: "spacing"
        };

        this.__placementTool = "componentPositionTool";

        this.__toolParams = {
            position: "position"
        };

        this.__renderKeys = ["FLOW"];

        this.__mint = "GRADIENT GENERATOR";
    }

    getPorts(params) {
        let position = params["position"];
        let bendSpacing = params["bendSpacing"];
        let numBends = params["numberOfBends"];
        let channelWidth = params["channelWidth"];
        let bendLength = params["bendLength"];
        let rotation = params["rotation"];
        let invalue = params["in"];
        let outvalue = params["out"];
        let spacing = params["spacing"]; //Center to Center

        let ports = [];

        let maxstagewidth = (outvalue - 1) * spacing;
        let posx = maxstagewidth/2;

        let stagelength = channelWidth * (2 * numBends + 1) + (2 * numBends + 2) * bendSpacing + channelWidth;

        let stagevalue = invalue;
        let totalstagewidth = (stagevalue - 1) * spacing;

        let xref = posx - totalstagewidth / 2;
        let yref = stagelength * (stagevalue - invalue);
    
        for(var i = 0 ; i < invalue; i++){
            //Generate the ports for each of the inputs
            let x = xref + spacing * i;
            ports.push(new ComponentPort(x, 0, (i+1).toString(), "FLOW"));
        }

        stagevalue = outvalue;
        totalstagewidth = (stagevalue - 1) * spacing;

        xref = posx - totalstagewidth / 2;
        yref = stagelength * (stagevalue - invalue);

        for(var i = 0; i < outvalue; i++){
            //Generate the ports for each of the outputs
            let x = xref + spacing * i;
            ports.push(new ComponentPort(x, yref, (invalue+1+i).toString(), "FLOW"));
        }

        return ports;
    }

    render2D(params, key) {
        let position = params["position"];
        let bendSpacing = params["bendSpacing"];
        let numBends = params["numberOfBends"];
        let channelWidth = params["channelWidth"];
        let bendLength = params["bendLength"];
        let rotation = params["rotation"];
        let invalue = params["in"];
        let outvalue = params["out"];
        let spacing = params["spacing"]; //Center to Center<commit_msg>adding ports to gradient generator<commit_after>import Template from "./template";
import paper from "paper";
import ComponentPort from "../core/componentPort";

export default class GradientGenerator extends Template {
    constructor() {
        super();
    }

    __setupDefinitions() {
        this.__unique = {
            position: "Point"
        };

        this.__heritable = {
            bendSpacing: "Float",
            numberOfBends: "Float",
            channelWidth: "Float",
            bendLength: "Float",
            in: "Float",
            out: "Float",
            spacing: "Float",
            height: "Float",
            rotation: "Float"
        };

        this.__defaults = {
            channelWidth: 0.8 * 1000,
            bendSpacing: 1.23 * 1000,
            numberOfBends: 1,
            rotation: 0,
            bendLength: 2.46 * 1000,
            in: 1,
            out: 3,
            spacing: 10000,
            height: 250,
            rotation: 0
        };

        this.__units = {
            bendSpacing: "&mu;m",
            numberOfBends: "",
            channelWidth: "&mu;m",
            bendLength: "&mu;m",
            
            in: "",
            out: "",
            spacing: "&mu;m",
            height: "&mu;m",
            rotation: "&deg;"
        };

        this.__minimum = {
            channelWidth: 10,
            bendSpacing: 10,
            numberOfBends: 1,
            rotation: 270,
            bendLength: 10,
            in: 1,
            out: 3,
            spacing: 10,
            height: 10
        };

        this.__maximum = {
            channelWidth: 2000,
            bendSpacing: 6000,
            numberOfBends: 20,
            rotation: 270,
            bendLength: 12 * 1000,
            in: 30,
            out: 90,
            spacing: 90000,
            height: 1200
        };

        this.__featureParams = {
            position: "position",
            channelWidth: "channelWidth",
            bendSpacing: "bendSpacing",
            numberOfBends: "numberOfBends",
            rotation: "rotation",
            bendLength: "bendLength",
            in: "in",
            out: "out",
            spacing: "spacing",
        };

        this.__targetParams = {
            channelWidth: "channelWidth",
            bendSpacing: "bendSpacing",
            numberOfBends: "numberOfBends",
            rotation: "rotation",
            bendLength: "bendLength",
            in: "in",
            out: "out",
            spacing: "spacing"
        };

        this.__placementTool = "componentPositionTool";

        this.__toolParams = {
            position: "position"
        };

        this.__renderKeys = ["FLOW"];

        this.__mint = "GRADIENT GENERATOR";
    }

    getPorts(params) {
        let position = params["position"];
        let bendSpacing = params["bendSpacing"];
        let numBends = params["numberOfBends"];
        let channelWidth = params["channelWidth"];
        let bendLength = params["bendLength"];
        let rotation = params["rotation"];
        let invalue = params["in"];
        let outvalue = params["out"];
        let spacing = params["spacing"]; //Center to Center

        let ports = [];

        let maxstagewidth = (outvalue - 1) * spacing;
        let posx = maxstagewidth/2;

        let stagelength = channelWidth * (2 * numBends + 1) + (2 * numBends + 2) * bendSpacing + channelWidth;

        let segBend = bendSpacing + 2 * channelWidth;

        let fullLength = (outvalue - 1) * (4 * segBend - 3.5 * channelWidth) + stagelength;

        let stagevalue = invalue;
        let totalstagewidth = (stagevalue - 1) * spacing;

        let xref = - totalstagewidth / 2;
        let yref = stagelength * (stagevalue - invalue);

        let vRepeat = 2 * bendSpacing + 2 * channelWidth;
    
        for(var i = 0 ; i < invalue; i++){
            //Generate the ports for each of the inputs
            let x = xref + spacing * i + channelWidth/2;
            ports.push(new ComponentPort(x, 0, (i+1).toString(), "FLOW"));
        }

        stagevalue = outvalue;
        totalstagewidth = (stagevalue - 1) * spacing;

        xref = - totalstagewidth / 2;
        yref = stagelength * (stagevalue - invalue);

        for(var i = 0; i < outvalue; i++){
            //Generate the ports for each of the outputs
            let x = xref + spacing * i + channelWidth/2;
            ports.push(new ComponentPort(x, fullLength, (invalue+1+i).toString(), "FLOW"));
        }

        return ports;
    }

    render2D(params, key) {
        let position = params["position"];
        let bendSpacing = params["bendSpacing"];
        let numBends = params["numberOfBends"];
        let channelWidth = params["channelWidth"];
        let bendLength = params["bendLength"];
        let rotation = params["rotation"];
        let invalue = params["in"];
        let outvalue = params["out"];
        let spacing = params["spacing"]; //Center to Center
{'fraction_non_alphanumeric': 0.117312661498708, 'fraction_numerical': 0.020981912144702842, 'mean_word_length': 1.5496706192358367, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3852139', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2629, 'n_words': 687}