package uk.ac.reload.editor.style;

import java.io.File;
import java.io.IOException;
import org.jdom.Element;
import uk.ac.reload.diva.util.FileUtils;

public final class StyleUtils {

    private StyleUtils() {
    }

    //copia de recursos de estilo por defecto al cp
    public static void copyDefaultStyleResourcesTo(File fcp) {
        try {
            String sDir = System.getProperties().getProperty("user.dir");
            File fDefaultStyleResources = new java.io.File(sDir, "DefaultStyleResources");
            FileUtils.copyFolder(fDefaultStyleResources, fcp);
        } catch (IOException ex) {
            System.out.println(ex);
        }

    }

    //establece values de style por defecto
    public static java.util.ArrayList<Value> setDefaultStyleValues(File fcp) {
        java.util.ArrayList<Value> stylevalues = new java.util.ArrayList<Value>();

        //Background image
        File fBackgroundImage = new java.io.File(fcp, "background_image.JPG");
        stylevalues.add(new Value(" Background image", fBackgroundImage, "backgroundimage"));

        //Background music
        File fBackgroundMusic = new java.io.File(fcp, "background_music.mp3");
        stylevalues.add(new Value(" Background music", fBackgroundMusic, "backgroundmusic"));

        //Exit icon
        File fExitIcon = new java.io.File(fcp, "exit_icon.JPG");
        stylevalues.add(new Value(" Exit icon", fExitIcon, "exiticon"));

        //Go-back icon
        File fGoBackIcon = new java.io.File(fcp, "goback_icon.GIF");
        stylevalues.add(new Value(" Go-back icon", fGoBackIcon, "gobackicon"));

        //Bullet points
        File fBulletPoints = new java.io.File(fcp, "bullet_points.gif");
        stylevalues.add(new Value(" Bullet points", fBulletPoints, "bulletpoints"));

        //Font (normal)
        stylevalues.add(new Value(" Font (normal)", new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 24), "normalfont"));

        //Font color (normal)
        stylevalues.add(new Value(" Font color (normal)", new java.awt.Color(255, 255, 255), "normalcolor"));

        //Font (focused)
        stylevalues.add(new Value(" Font (focused)", new java.awt.Font("Tahoma", java.awt.Font.BOLD, 32), "focusedfont"));

        //Font color (focused)
        stylevalues.add(new Value(" Font color (focused)", new java.awt.Color(255, 255, 0), "focusedcolor"));

        //Scroll-up arrow
        File fScrollUpArrow = new java.io.File(fcp, "scrollup_arrow.GIF");
        stylevalues.add(new Value(" Scroll-up arrow", fScrollUpArrow, "scrolluparrow"));

        //Scroll-down arrow
        File fScrollDownArrow = new java.io.File(fcp, "scrolldown_arrow.GIF");
        stylevalues.add(new Value(" Scroll-down arrow", fScrollDownArrow, "scrolldownarrow"));

        return stylevalues;
    }
    
     //inicialización de elemento style en imsmanifest
    public static void setDefaultStyleXMLElement(Element styleelement, java.util.ArrayList<Value> stylevalues) {
        for (int i=0; i<stylevalues.size(); i++){
            Value value = stylevalues.get(i);
            if(value.getValueClass().equals(File.class)) styleelement.addContent(StyleXMLUtils.getFileElement(value, styleelement));
            else if(value.getValueClass().equals(java.awt.Font.class)) styleelement.addContent(StyleXMLUtils.getFontElement(value, styleelement));
            else if(value.getValueClass().equals(java.awt.Color.class)) styleelement.addContent(StyleXMLUtils.getColorElement(value, styleelement));
            else System.err.println("stylexmlelement: clase no compatible");
        }

    }

}
