Source: styles/style.js

let uniform = require('./uniform');
let unique = require('./unique');

const dict = {
    "uniform": uniform,
    "unique": unique
};

/**
 * Класс StyleFabric - фабрика функций стилей
 * @class StyleFabric
 */
class StyleFabric {
    /**
     * Создает экземпляр класса функции стиля на основе входных параметров
     * @param params
     */
    constructor(params) {
        this.style = create(params);
        this.params = params;
    }

    /**
     * Возвращает функцию (объект) стиля
     * @return {*}
     */
    getStyle() {
        return this.style;
    }

    /**
     * Устанавливает функцию (объект) стиля
     * @param style
     */
    setStyle(style) {
        this.styles = style;
    }

    create(params) {
        let type = params.type;
        let styleClass = dict[type];
        let styleObject = new styleClass(params);
        this.style = styleObject.create(params);
        //todo доработать через наследование классов
        this.styleArray = styleObject.styleArray();
        this.getLegend = styleObject.legend();
    }

   /**
    * Возвращает легенду слоя
    * @return {*}
    */
    legend() {
        return this.getLegend();
    }
}

module.exports = StyleFabric;