package org.twopm.laf;

import java.awt.Color;
import java.util.List;

/**
 * @author Edward M. Kagan <pagan@tabor.one>
 */
public class AttributeSetConfigured {
    
            String name;
            Color bgColor;
            Color fgColor;
            Color underColor;
           
            Boolean v_isUseHighlightColor;
            Boolean v_isInheritForegroundColor;
            Boolean v_isUseWaveUnderlineColor;
            
            Color a_getHighlight;
            Color a_getForegroundColor;
            Color a_getWaveUnderlineColor;
            
            
            Boolean bold;
            Boolean italic;
    
    public AttributeSetConfigured  (String name,
                                    Color bgColor,
                                    Color fgColor,
                                    Color underColor,

                                    Boolean v_isUseHighlightColor,
                                    Boolean v_isInheritForegroundColor,
                                    Boolean v_isUseWaveUnderlineColor,

                                    Color a_getHighlight,
                                    Color a_getForegroundColor,
                                    Color a_getWaveUnderlineColor,
                                    
                                    Boolean bold,
                                    Boolean italic
            )
    {
        this.name = name;
        this.bgColor = bgColor;
        this.fgColor = fgColor;
        this.underColor = underColor;
        this.v_isInheritForegroundColor = v_isInheritForegroundColor;
        this.v_isUseHighlightColor = v_isUseHighlightColor;
        this.v_isUseWaveUnderlineColor = v_isUseWaveUnderlineColor;
        this.bold = bold;
        this.italic = italic;
        this.a_getForegroundColor = a_getForegroundColor;
        this.a_getHighlight = a_getHighlight;
        this.a_getWaveUnderlineColor = a_getWaveUnderlineColor;
    }
    
    public String produceConfLine ()
    {
        String res = "new AttributeSetConfigured (" ;
        res +="\"" + this.name + "\", ";
        res += wrapColor(bgColor) + ", ";
        res += wrapColor(fgColor) + ", ";
        res += wrapColor(underColor) + ", ";
        res += wrapBoolean (v_isUseHighlightColor) + ", ";
        res += wrapBoolean (v_isInheritForegroundColor) + ", ";
        res += wrapBoolean (v_isUseWaveUnderlineColor) + ", ";
        res += wrapColor(a_getForegroundColor) + ", ";
        res += wrapColor(a_getHighlight) + ", ";
        res += wrapColor(a_getWaveUnderlineColor) + ", ";
        res += wrapBoolean (bold) + ", ";
        res += wrapBoolean (italic);
        res += ")";
        return res;
    }
 
    private String wrapColor(Color c)
    {
        if (c != null)
        {
            String res = "new Color (" + c.getRed()   + ", "
                                       + c.getGreen() + ", "
                                       + c.getBlue()  + ", "
                                       + c.getAlpha() + ")";
            return res;
        }
        else
        {
            return "null";
        }
    }
    
    private String wrapBoolean(Boolean b)
    {
        if (b != null)
        {
            if (b) 
            {
                return "true";
            }
            else
            {
                return "false";
            }
        }
        else
        {
            return "null";
        }
    }
 
    public static void compileSet (String setName, List <AttributeSetConfigured> conf)
    {
        String res = "private static final AttributeSetConfigured [] " + setName + " = {\n";
        
        for (int i = 0; i < conf.size(); i ++)
        {
            if (i != conf.size() - 1)
            {
                res += "    " + conf.get(i).produceConfLine() + ", \n";
            }
            else
            {
                res += "    " + conf.get(i).produceConfLine() + "\n";
            }
        }
        
        res += "};";
        System.out.println(res);
    }
    
    
}
