package de.renew.gui;

import java.util.HashMap;
import java.util.Map;

import CH.ifa.draw.figures.TextFigure;
import CH.ifa.draw.standard.ToolButton;


public class TextFigureToolButtonRegistry {
    private final Map<Class<? extends TextFigure>, ToolButton> mapping;

    public TextFigureToolButtonRegistry() {
        this.mapping = new HashMap<>();
    }

    public void registerFigureType(Class<? extends TextFigure> clazz, ToolButton button) {
        this.mapping.put(clazz, button);
    }

    public void deregisterFigureType(Class<? extends TextFigure> clazz) {
        this.mapping.remove(clazz);
    }

    public ToolButton toolButtonForTextFigure(TextFigure figure) {
        Class<? extends TextFigure> clazz = figure.getClass();
        return this.mapping.get(clazz);
    }
}