package cn.com.qmth.stmms.biz.common.domain.card;

import cn.com.qmth.stmms.biz.mark.model.MarkConfigItem;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

/**
 * 评卷分组的显示坐标
 */
public class MarkConfig {

    private Map<Integer, List<ConfigItem>> map;

    public MarkConfig() {
        this.map = new HashMap<>();
    }

    public void addConfig(int mainNumber, int index, double left, double top, double width, double height) {
        ConfigItem item = new ConfigItem();
        item.index = index;
        item.left = left;
        item.top = top;
        item.width = width;
        item.height = height;
        this.map.computeIfAbsent(mainNumber, key -> new LinkedList<>()).add(item);
    }

    public List<ConfigItem> getConfig(int mainNumber) {
        return map.get(mainNumber);
    }

    static class ConfigItem {

        // 对应的图片序号
        int index;

        // 坐标点与宽高的相对比例
        double left, top, width, height;

        @Override
        public String toString() {
            return StringUtils.join(Arrays.asList(index, left, top, width, height), MarkConfigItem.DB_FIELD_JOINER);
        }
    }
}
