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

package com.macromedia.generator.app;

import com.macromedia.generator.api.*;
import java.util.*;

// Referenced classes of package com.macromedia.generator.app:
//            FlashCommand, FlashCommandException, FlashEnvironment, GenVector

public abstract class GenericCommand
    implements FlashCommand
{

    protected GenericCommand()
    {
    }

    public int convertStringToInt(String s, int i)
    {
        int j = i;
        if(!s.equalsIgnoreCase("default"))
            try
            {
                j = Integer.valueOf(s).intValue();
            }
            catch(NumberFormatException _ex)
            {
                j = i;
            }
        return j;
    }

    public abstract void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException;

    public int findColumn(String as[][], String s)
    {
        for(int i = 0; i < as[0].length; i++)
            if(as[0][i].equalsIgnoreCase(s))
                return i;

        return -1;
    }

    public boolean getBoolParam(Context context, Properties properties, String s)
    {
        return getStringParamEmpty(context, properties, s).equalsIgnoreCase("true");
    }

    public int getIntParam(Context context, Properties properties, String s, int i)
    {
        return convertStringToInt(getStringParamEmpty(context, properties, s), i);
    }

    public Shape getMask(GenVector genvector, Rect rect)
    {
        Shape shape = null;
        try
        {
            FillStyle fillstyle = (FillStyle)genvector.add(new FillStyle());
            FillStyle fillstyle1 = (FillStyle)genvector.add(new FillStyle());
            Color color = (Color)genvector.add(new Color());
            color.setRgb(0xffffff);
            fillstyle1.setColor(color);
            LineStyle linestyle = (LineStyle)genvector.add(new LineStyle());
            linestyle.setWidth(1);
            linestyle.setColor(color);
            shape = (Shape)genvector.add(new Shape());
            shape.setFillStyle(fillstyle1, fillstyle);
            shape.setLineStyle(linestyle);
            shape.moveTo(rect.getXMin(), rect.getYMin());
            shape.lineTo(rect.getXMax(), rect.getYMin());
            shape.lineTo(rect.getXMax(), rect.getYMax());
            shape.lineTo(rect.getXMin(), rect.getYMax());
            shape.lineTo(rect.getXMin(), rect.getYMin());
        }
        catch(GeneratorApiException _ex)
        {
            shape = null;
        }
        return shape;
    }

    public String getResourceString(FlashEnvironment flashenvironment, String s)
    {
        String s1 = getClass().getName();
        s1 = s1.concat("Data");
        ResourceBundle resourcebundle = ResourceBundle.getBundle(s1, Locale.getDefault());
        return resourcebundle.getString(s);
    }

    public String getStringParam(Context context, Properties properties, String s, String s1)
    {
        return context.apply(properties.getProperty(s, s1));
    }

    public String getStringParamEmpty(Context context, Properties properties, String s)
    {
        return context.apply(properties.getProperty(s, ""));
    }

    public void logError(FlashEnvironment flashenvironment, String s, String s1)
    {
        String s2 = getClass().getName();
        s2 = s2.concat("Data");
        flashenvironment.logError(s2, s, s1);
    }

    public void logMessage(FlashEnvironment flashenvironment, String s, String s1)
    {
        if(flashenvironment.logLevel() > 1)
        {
            String s2 = getClass().getName();
            s2 = s2.concat("Data");
            flashenvironment.logMessage(s2, s, s1);
        }
    }

    public void logWarning(FlashEnvironment flashenvironment, String s, String s1)
    {
        if(flashenvironment.logLevel() > 1)
        {
            String s2 = getClass().getName();
            s2 = s2.concat("Data");
            flashenvironment.logWarning(s2, s, s1);
        }
    }
}