package event.editor.frame;
import images.*;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import java.net.URL;
import java.awt.Image;
import java.awt.image.BufferedImage;
import scriptbuilder.structures.ScriptEvent;
import scriptbuilder.structures.ScriptEvent;
import scriptbuilder.structures.events.*;
import scriptbuilder.structures.events.I_ScriptEvent;

public enum Properties
{
    ATMS                ("ATMS", PropertyTypes.Optional,
        loadImage(Images.getImage("ATMSEval.png")), new ATMSEvaluationEvent()),
    ActivityLog         ("Activity Log", PropertyTypes.Optional,
        loadImage(Images.getImage("ActivityLogEval.png")), new ActivityLogEvaluationEvent()),
    CAD                 ("CAD", PropertyTypes.Optional,
        loadImage(Images.getImage("CADEval.png")), new CADEvaluationEvent()),
    Facilitator         ("Faciliatator", PropertyTypes.Optional,
        loadImage(Images.getImage("FacilitatorEval.png")), new FacilitatorEvaluationEvent()),
    Radio               ("Radio", PropertyTypes.Optional,
        loadImage(Images.getImage("RadioEval.png")), new RadioEvaluationEvent()),
    MaintenanceRadio    ("Maintenance Radio", PropertyTypes.Optional,
        loadImage(Images.getImage("MaintenanceRadio.png")), new MaintenanceRadioEvent()),
    TMTRadio            ("TMT Radio", PropertyTypes.Optional,
        loadImage(Images.getImage("TMTRadio.png")), new TMTRadioEvent()),
    Telephone           ("Telephone", PropertyTypes.Optional,
        loadImage(Images.getImage("Telephone.png")), new TelephoneEvent()),
    CHPRadio            ("CHP Radio",PropertyTypes.Optional,
        loadImage(Images.getImage("CHPRadio.png")), new CHPRadioEvent()),
    CMS                 ("CMS", PropertyTypes.Multiple,
        loadImage(Images.getImage("CMSEval.png")), new CMSEvaluationEvent()),
    Audio               ("Audio", PropertyTypes.Multiple,
        loadImage(Images.getImage("Audio.png")), new AudioEvent()),
    CCTV                ("CCTV", PropertyTypes.Multiple,
        loadImage(Images.getImage("CCTV.png")), new CCTVEvent()),
    CADLog              ("CAD Log", PropertyTypes.Multiple,
        loadImage(Images.getImage("CAD.png")), new CADEvent()),
    Paramics            ("Paramics", PropertyTypes.Multiple,
        loadImage(Images.getImage("Paramics.png")), new ParamicsEvent()),
    Tow                 ("Tow", PropertyTypes.Multiple,
        loadImage(Images.getImage("Tow.png")), new TowEvent()),
    Unit                ("Unit", PropertyTypes.Multiple,
        loadImage(Images.getImage("Unit.png")), new UnitEvent()),
    Witness             ("Witness", PropertyTypes.Multiple,
        loadImage(Images.getImage("Witness.png")), new WitnessEvent());

    private String title;
    private PropertyTypes type;
    private ImageIcon image;
    private I_ScriptEvent sevt;

    private Properties(String theTitle, PropertyTypes theType, ImageIcon theImage, I_ScriptEvent se)
    {
        title = theTitle;
        type = theType;
        image = theImage;
        sevt = se;
    }

    public String getTitle()
    {
        return title;
    }
    
    public I_ScriptEvent getEvent()
    {
        return ScriptEvent.factoryByType(sevt.getScriptEventType());
    }

    public PropertyTypes getType()
    {
        return type;
    }

    public ImageIcon getImage()
    {
        return image;
    }

    private static ImageIcon loadImage(URL url)
    {
        double scale = 0.8;
        ImageIcon icon = new ImageIcon(url);
        Image img = icon.getImage();
        BufferedImage bi = new BufferedImage(img.getWidth(null),
                img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.createGraphics();
        g.drawImage(img, 0, 0, (int) (img.getWidth(null) * scale), (int)(img.getHeight(null) * scale), null);
        return new ImageIcon(bi);
    }
}