// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:23
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/commands/PngSetCommand

package com.macromedia.generator.commands;

import com.macromedia.generator.api.Context;
import com.macromedia.generator.api.Script;
import com.macromedia.generator.app.*;
import java.io.File;
import java.util.Hashtable;
import java.util.Properties;

public class PngSetCommand extends GenericCommand
{

    public PngSetCommand()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        Boolean boolean1 = (Boolean)flashenvironment.get("PNGInitialized");
        if(boolean1 != null && boolean1.booleanValue())
        {
            logError(flashenvironment, "MultiPNGInit", null);
            return;
        }
        String s = context.apply(properties.getProperty("width", "-1"));
        String s1 = context.apply(properties.getProperty("height", "-1"));
        String s2 = context.apply(properties.getProperty("type", ""));
        String s3 = context.apply(properties.getProperty("options", ""));
        String s4 = context.apply(properties.getProperty("interlace", "true"));
        String s5 = context.apply(properties.getProperty("smooth", "true"));
        String s6 = context.apply(properties.getProperty("dither", "true"));
        String s7 = context.apply(properties.getProperty("nogradients", ""));
        String s8 = context.apply(properties.getProperty("dithertype", ""));
        String s9 = context.apply(properties.getProperty("optcolors", ""));
        String s10 = context.apply(properties.getProperty("paletteoptions", ""));
        String s11 = context.apply(properties.getProperty("maxcolors", "64"));
        String s12 = context.apply(properties.getProperty("custompalette", ""));
        Integer integer = new Integer(-1);
        Integer integer1 = new Integer(-1);
        Integer integer2 = new Integer(0);
        Integer integer3 = new Integer(0);
        Integer integer4 = new Integer(1);
        Integer integer5 = new Integer(0);
        Integer integer6 = new Integer(64);
        Boolean boolean2 = new Boolean(true);
        Boolean boolean3 = new Boolean(true);
        Boolean boolean4 = new Boolean(true);
        Boolean boolean5 = new Boolean(s7.equalsIgnoreCase("true"));
        Boolean boolean6 = new Boolean(s9.equalsIgnoreCase("true"));
        if(!s.equalsIgnoreCase("default"))
            try
            {
                if(Integer.valueOf(s).intValue() > 0)
                    integer = Integer.valueOf(s);
            }
            catch(NumberFormatException _ex)
            {
                logError(flashenvironment, "InvalWidth", null);
            }
        if(!s1.equalsIgnoreCase("default"))
            try
            {
                if(Integer.valueOf(s1).intValue() > 0)
                    integer1 = Integer.valueOf(s1);
            }
            catch(NumberFormatException _ex)
            {
                logError(flashenvironment, "InvalHeight", null);
            }
        try
        {
            if(s8.equalsIgnoreCase(getResourceString(flashenvironment, "None")) || s8 == "" || s8.equalsIgnoreCase("\u306A\u3057") || s8.equalsIgnoreCase("Kein") || s8.equalsIgnoreCase("Aucun") || s8.equalsIgnoreCase("Ninguna") || s8.equalsIgnoreCase("Nessuno") || s8.equalsIgnoreCase("Ingen") || s8.equalsIgnoreCase("Nenhum"))
                integer4 = new Integer(0);
            else
            if(s8.equalsIgnoreCase(getResourceString(flashenvironment, "Ordered")) || s8.equalsIgnoreCase("\u30C7\u30D5\u30A9\u30EB\u30C8") || s8.equalsIgnoreCase("Angeordnet") || s8.equalsIgnoreCase("Ordonn\351") || s8.equalsIgnoreCase("Ordenada") || s8.equalsIgnoreCase("Ordinato") || s8.equalsIgnoreCase("Ordnad") || s8.equalsIgnoreCase("Ordenado"))
                integer4 = new Integer(1);
            else
            if(s8.equalsIgnoreCase(getResourceString(flashenvironment, "Diffusion")) || s8.equalsIgnoreCase("\u62E1\u6563") || s8.equalsIgnoreCase("Diffus") || s8.equalsIgnoreCase("Difusi\363n") || s8.equalsIgnoreCase("Diffusione") || s8.equalsIgnoreCase("Difuso"))
            {
                integer4 = new Integer(2);
            } else
            {
                logError(flashenvironment, "InvalDitherType", null);
                integer4 = new Integer(2);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalDitherType", null);
        }
        try
        {
            if(s10.equalsIgnoreCase(getResourceString(flashenvironment, "Web 216")) || s10 == "" || s10.equalsIgnoreCase("Web 216 \u8272") || s10.equalsIgnoreCase("Webbs\344kra 216"))
                integer5 = new Integer(0);
            else
            if(s10.equalsIgnoreCase(getResourceString(flashenvironment, "Adaptive")) || s10.equalsIgnoreCase("\u30A2\u30C0\u30D7\u30C6\u30A3\u30D6") || s10.equalsIgnoreCase("Adaptiv") || s10.equalsIgnoreCase("Adaptable") || s10.equalsIgnoreCase("Adattata") || s10.equalsIgnoreCase("Adaptiva") || s10.equalsIgnoreCase("Adaptativo"))
                integer5 = new Integer(1);
            else
            if(s10.equalsIgnoreCase(getResourceString(flashenvironment, "Web Snap Adaptive")) || s10.equalsIgnoreCase("Web Snap \u30A2\u30C0\u30D7\u30C6\u30A3\u30D6") || s10.equalsIgnoreCase("Web Snap adaptiv") || s10.equalsIgnoreCase("Web Snap Adaptable") || s10.equalsIgnoreCase("Adattata Web Snap") || s10.equalsIgnoreCase("Webbs\344kra adaptiva") || s10.equalsIgnoreCase("Adaptive Web Snap") || s10.equalsIgnoreCase("Adaptativo Ajuste \340 Web"))
                integer5 = new Integer(2);
            else
            if(s10.equalsIgnoreCase(getResourceString(flashenvironment, "Custom")) || s10.equalsIgnoreCase("\u30AB\u30B9\u30BF\u30E0") || s10.equalsIgnoreCase("Benutzerdefiniert") || s10.equalsIgnoreCase("Personnalis\351e") || s10.equalsIgnoreCase("Personalizada") || s10.equalsIgnoreCase("Personalizzata") || s10.equalsIgnoreCase("Anpassade") || s10.equalsIgnoreCase("Personalizado"))
            {
                integer5 = new Integer(3);
            } else
            {
                logError(flashenvironment, "InvalPaletteType", null);
                integer5 = new Integer(1);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalPaletteType", null);
        }
        try
        {
            if(s2.equalsIgnoreCase(getResourceString(flashenvironment, "8-bit")) || s2.equalsIgnoreCase("8 \u30D3\u30C3\u30C8") || s2.equalsIgnoreCase("8 bit") || s2.equalsIgnoreCase("8 bits") || s2.equalsIgnoreCase("8-bitar"))
                integer2 = new Integer(0);
            else
            if(s2.equalsIgnoreCase(getResourceString(flashenvironment, "24-bit")) || s2.equalsIgnoreCase("24 \u30D3\u30C3\u30C8") || s2.equalsIgnoreCase("24 bits") || s2.equalsIgnoreCase("24 bit") || s2.equalsIgnoreCase("24-bitar"))
                integer2 = new Integer(1);
            else
            if(s2.equalsIgnoreCase(getResourceString(flashenvironment, "24-bit with Alpha")) || s2 == "" || s2.equalsIgnoreCase("24 \u30D3\u30C3\u30C8(\u30A2\u30EB\u30D5\u30A1\u30C1\u30E3\u30F3\u30CD\u30EB)") || s2.equalsIgnoreCase("24-Bit (Alpha)") || s2.equalsIgnoreCase("24 bits avec Alpha") || s2.equalsIgnoreCase("24 bits con alfa") || s2.equalsIgnoreCase("24 bit con alfa") || s2.equalsIgnoreCase("24-bitar med Alfa") || s2.equalsIgnoreCase("24 bits com Alpha"))
            {
                integer2 = new Integer(2);
            } else
            {
                logError(flashenvironment, "InvalType", null);
                integer2 = new Integer(0);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalType", null);
        }
        try
        {
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "None")) || s3 == "" || s3.equalsIgnoreCase("\u306A\u3057") || s3.equalsIgnoreCase("Keine") || s3.equalsIgnoreCase("Aucune") || s3.equalsIgnoreCase("Ninguno") || s3.equalsIgnoreCase("Nessuno") || s3.equalsIgnoreCase("Inget") || s3.equalsIgnoreCase("Nenhum"))
                integer3 = new Integer(0);
            else
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "Sub")) || s3.equalsIgnoreCase("Davor") || s3.equalsIgnoreCase("Inf\351rieure") || s3.equalsIgnoreCase("Under"))
                integer3 = new Integer(1);
            else
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "Up")) || s3.equalsIgnoreCase("Dar\374ber") || s3.equalsIgnoreCase("Sup\351rieure") || s3.equalsIgnoreCase("Arriba") || s3.equalsIgnoreCase("Su") || s3.equalsIgnoreCase("Upp"))
                integer3 = new Integer(2);
            else
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "Average")) || s3.equalsIgnoreCase("Durchschnitt") || s3.equalsIgnoreCase("Moyenne") || s3.equalsIgnoreCase("Medio") || s3.equalsIgnoreCase("Media") || s3.equalsIgnoreCase("Medel") || s3.equalsIgnoreCase("M\351dio"))
                integer3 = new Integer(3);
            else
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "Paeth")))
                integer3 = new Integer(4);
            else
            if(s3.equalsIgnoreCase(getResourceString(flashenvironment, "Adaptive")) || s3.equalsIgnoreCase("Adaptable") || s3.equalsIgnoreCase("Adattato") || s3.equalsIgnoreCase("Adaptivt") || s3.equalsIgnoreCase("Adaptativo"))
            {
                integer3 = new Integer(5);
            } else
            {
                logError(flashenvironment, "InvalOption", null);
                integer3 = new Integer(0);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalOption", null);
        }
        if(!s4.equalsIgnoreCase("true"))
            boolean2 = new Boolean(false);
        if(!s5.equalsIgnoreCase("true"))
            boolean3 = new Boolean(false);
        if(!s6.equalsIgnoreCase("true"))
            boolean4 = new Boolean(false);
        if(integer5.intValue() == 3)
        {
            String s13 = _mth0143(flashenvironment, s12);
            if(s13 == null)
            {
                logError(flashenvironment, "InvalPaletteName", s12);
                integer5 = new Integer(1);
                s13 = "";
            }
            s12 = s13;
        }
        flashenvironment.put("PNGWidth", integer);
        flashenvironment.put("PNGHeight", integer1);
        flashenvironment.put("PNGType", integer2);
        flashenvironment.put("PNGOption", integer3);
        flashenvironment.put("PNGInterlace", boolean2);
        flashenvironment.put("PNGSmooth", boolean3);
        flashenvironment.put("PNGDither", boolean4);
        flashenvironment.put("PNGDitherType", integer4);
        flashenvironment.put("PNGNoGradients", boolean5);
        flashenvironment.put("PNGColorOpt", boolean6);
        flashenvironment.put("PNGPaletteType", integer5);
        flashenvironment.put("PNGPaletteFile", s12);
        flashenvironment.put("PNGMaxColors", integer6);
        flashenvironment.put("PNGInitialized", new Boolean(true));
    }

    private String _mth0143(FlashEnvironment flashenvironment, String s)
    {
        String s1 = null;
        File file = null;
        file = new File(s);
        if(!file.isAbsolute())
            file = new File(flashenvironment.getDirectory(), file.getPath());
        if(file.exists() && file.isFile())
            s1 = file.getPath();
        return s1;
    }
}