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

package com.macromedia.generator.api;

import com.macromedia.generator.api.peer.BufferPeer;
import com.macromedia.generator.api.peer.ScriptPeer;
import com.macromedia.generator.platform.Mac;
import java.io.*;
import java.util.Enumeration;
import java.util.Properties;

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, Buffer, GeneratorApiException, GeneratorApiRuntimeException, 
//            Matrix, Rect, Sound, Context, 
//            Color, Action, Bitmap, Button, 
//            Shape, Text, Font, Serial

public class Script extends GenObject
{

    public Script()
    {
        peer = ScriptPeer.New();
        if(peer == 0)
            throw new GeneratorApiRuntimeException("unable to create peer");
        else
            return;
    }

    protected Script(int i)
    {
        peer = i;
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        else
            return;
    }

    public void MP3convert(Buffer buffer, Buffer buffer1, int i, int j, int k, int l, int i1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j1 = ScriptPeer.MP3convert(peer, buffer.peer, buffer1.peer, i, j, k, l, i1);
        if(j1 == 0)
            throw new GeneratorApiException("error inserting MP3 sound file");
        else
            return;
    }

    public void addCommand(String s, Properties properties, int i, int j, int k)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null || s.length() == 0)
            throw new GeneratorApiRuntimeException("invalid command name");
        for(Enumeration enumeration = properties.propertyNames(); enumeration.hasMoreElements();)
        {
            String s1 = (String)enumeration.nextElement();
            if(!s1.equalsIgnoreCase("command"))
            {
                String s2 = properties.getProperty(s1);
                s = s + " " + s1 + "=\"" + s2 + "\"";
            }
        }

        int l = ScriptPeer.AddCommand(peer, s, i, j, k);
        if(l == 0)
            throw new GeneratorApiException("error adding tag");
        else
            return;
    }

    public void addExternalMedia(Script script)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.AddExternalMedia(peer, script.peer);
        if(i == 0)
            throw new GeneratorApiException("error adding external media");
        else
            return;
    }

    public void addTag(String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.AddTag(peer, s);
        if(i == 0)
            throw new GeneratorApiException("error adding tag");
        else
            return;
    }

    public void appendScript(Script script)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.AppendScript(peer, script.peer);
        if(i == 0)
            throw new GeneratorApiException("error appending script");
        else
            return;
    }

    public void applyContext(Context context)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.ApplyContext(peer, context.peer);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error applying the context");
        else
            return;
    }

    public Script copyScript()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.CopyScript(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error copying script");
        else
            return new Script(ai[0]);
    }

    public void extrude(Script script, float f, int i, Color color, Color color1, int j, Color color2, 
            float f1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int k = ScriptPeer.Extrude(peer, script.getPeer(), f, i, color.getPeer(), color1.getPeer(), j, color2.getPeer(), f1);
        if(k == 0)
            throw new GeneratorApiException("error extruding");
        else
            return;
    }

    protected void finalize()
        throws Throwable
    {
        if(peer != 0)
            ScriptPeer.Release(peer);
        peer = 0;
    }

    public int findFrameLabel(String s)
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        int i = ScriptPeer.FindFrameLabel(peer, s, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting frame label");
        else
            return ai[0];
    }

    public Script findScript(String s)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = ScriptPeer.FindScript(peer, s, ai);
        if(i == 0)
            return null;
        else
            return new Script(ai[0]);
    }

    public Sound findSound(String s)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = ScriptPeer.FindSound(peer, s, ai);
        if(i == 0)
            return null;
        else
            return new Sound(ai[0]);
    }

    public Rect getBounds()
    {
        Rect rect = null;
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetBounds(peer, ai);
        if(i != 0)
            rect = new Rect(ai[0]);
        return rect;
    }

    public int getCommandCount()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetCommandCount(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting command count");
        else
            return ai[0];
    }

    public int getCommandFrameCount(int i)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandFrameCount(peer, i, ai);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error getting command frame count");
        else
            return ai[0];
    }

    public int getCommandFrameIndex(int i)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandFrameIndex(peer, i, ai);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error getting command frame index");
        else
            return ai[0];
    }

    public int getCommandLayer(int i)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandLayer(peer, i, ai);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error getting command layer");
        else
            return ai[0];
    }

    public Matrix getCommandMatrix(int i)
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandMatrix(peer, i, ai);
        if(j == 0)
            return null;
        if(ai[0] == 0)
            return null;
        else
            return new Matrix(ai[0]);
    }

    public Rect getCommandRect(int i)
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandRect(peer, i, ai);
        if(j == 0)
            return null;
        if(ai[0] == 0)
            return null;
        else
            return new Rect(ai[0]);
    }

    public Script getCommandScript(int i)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandScript(peer, i, ai);
        if(j == 0)
            return null;
        if(ai[0] == 0)
            return null;
        else
            return new Script(ai[0]);
    }

    public String getCommandString(int i)
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetCommandString(peer, i, as);
        if(j == 0)
            return null;
        else
            return as[0];
    }

    public int getExternalFontCount()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetExternalFontCount(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting external font count");
        else
            return ai[0];
    }

    public String getExternalFontFile(int i)
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetExternalFontFile(peer, i, as);
        if(j == 0)
            return null;
        else
            return as[0];
    }

    public int getFileVersion()
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int ai[] = new int[1];
        int i = ScriptPeer.GetFileVersion(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting file version");
        else
            return ai[0];
    }

    public float getFrameRate()
    {
        float af[] = new float[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetFrameRate(peer, af);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting frame rate");
        else
            return af[0];
    }

    public int getHeight()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetHeight(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting height");
        else
            return ai[0];
    }

    public boolean getIsCommand()
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetIsCommand(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting command flag");
        else
            return aflag[0];
    }

    public boolean getIsProcessed()
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetIsProcessed(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting processed flag");
        else
            return aflag[0];
    }

    public boolean getIsReferenced()
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetIsReferenced(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting referenced flag");
        else
            return aflag[0];
    }

    public int getLastFrame()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetLastFrame(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting last frame index");
        else
            return ai[0];
    }

    public boolean getLoadTopDown()
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetLoadTopDown(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting load top down flag");
        else
            return aflag[0];
    }

    public Script getScript(int i)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.GetScript(peer, i, ai);
        if(j == 0)
            return null;
        else
            return new Script(ai[0]);
    }

    public int getScriptCount()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetScriptCount(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting script count");
        else
            return ai[0];
    }

    public int getWidth()
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.GetWidth(peer, ai);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting width");
        else
            return ai[0];
    }

    public void insertAction(Action action, int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.InsertAction(peer, action.peer, i);
        if(j == 0)
            throw new GeneratorApiException("error inserting action");
        else
            return;
    }

    public void insertAnimatedBitmap(String s, int i, int j, Matrix matrix, int k, Matrix matrix1, boolean flag, 
            int l, int i1, int j1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        Mac mac = Mac.getMac();
        int k1;
        if(mac != null)
        {
            String s1 = mac.makeSystemPretty(s);
            k1 = ScriptPeer.InsertAnimatedBitmap(peer, s1, i, j, matrix.peer, k, matrix1.peer, flag, l, i1, j1);
        } else
        {
            k1 = ScriptPeer.InsertAnimatedBitmap(peer, s, i, j, matrix.peer, k, matrix1.peer, flag, l, i1, j1);
        }
        if(k1 == 0)
            throw new GeneratorApiException("error inserting bitmap");
        else
            return;
    }

    public void insertAnimatedBitmapBuffer(Buffer buffer, int i, int j, Matrix matrix, int k, Matrix matrix1, boolean flag, 
            int l, int i1, int j1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int k1 = ScriptPeer.InsertAnimatedBitmapBuffer(peer, buffer.peer, i, j, matrix.peer, k, matrix1.peer, flag, l, i1, j1);
        if(k1 == 0)
            throw new GeneratorApiException("error inserting bitmap");
        else
            return;
    }

    public void insertBackgroundColor(Color color)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.InsertBackgroundColor(peer, color.peer);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error inserting background color");
        else
            return;
    }

    public void insertBackgroundRgb(int i)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.InsertBackgroundRgb(peer, i);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error inserting background rgb color");
        else
            return;
    }

    public void insertBitmap(Bitmap bitmap, int i, int j, Matrix matrix, int k, Matrix matrix1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = ScriptPeer.InsertBitmap(peer, bitmap.peer, i, j, matrix.peer, k, matrix1.peer);
        if(l == 0)
            throw new GeneratorApiException("error inserting bitmap");
        else
            return;
    }

    public void insertButton(Button button, int i, int j, Matrix matrix, int k, Matrix matrix1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = ScriptPeer.InsertButton(peer, button.peer, i, j, matrix.peer, k, matrix1.peer);
        if(l == 0)
            throw new GeneratorApiException("error inserting button");
        else
            return;
    }

    public void insertFrames(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int k = ScriptPeer.InsertFrames(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error inserting frames");
        else
            return;
    }

    public void insertObject(GenObject genobject, int i, int j, Matrix matrix, int k, Matrix matrix1, GenObject genobject1, 
            String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = genobject1 == null ? 0 : genobject1.peer;
        String s1 = s == null ? "" : s;
        int i1 = ScriptPeer.InsertObject(peer, genobject.peer, i, j, matrix.peer, k, matrix1.peer, l, s1);
        if(i1 == 0)
            throw new GeneratorApiException("error inserting object");
        else
            return;
    }

    public void insertScript(Script script, int i, int j, Matrix matrix, int k, Matrix matrix1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = ScriptPeer.InsertScript(peer, script.peer, i, j, matrix.peer, k, matrix1.peer);
        if(l == 0)
            throw new GeneratorApiException("error inserting script");
        else
            return;
    }

    public void insertShape(Shape shape, int i, int j, Matrix matrix, int k, Matrix matrix1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = ScriptPeer.InsertShape(peer, shape.peer, i, j, matrix.peer, k, matrix1.peer);
        if(l == 0)
            throw new GeneratorApiException("error inserting shape");
        else
            return;
    }

    public void insertSound(Sound sound, int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int k = ScriptPeer.InsertSound(peer, sound.peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error inserting sound");
        else
            return;
    }

    public void insertText(Text text, int i, int j, Matrix matrix, int k, Matrix matrix1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int l = ScriptPeer.InsertText(peer, text.peer, i, j, matrix.peer, k, matrix1.peer);
        if(l == 0)
            throw new GeneratorApiException("error inserting text");
        else
            return;
    }

    public void loadExternalFontBuffer(int i, Buffer buffer)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.LoadExternalFontBuffer(peer, i, buffer.peer);
        if(j == 0)
            throw new GeneratorApiException("error loading external font file");
        else
            return;
    }

    public void loadExternalFontFile(int i, String s, boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        Mac mac = Mac.getMac();
        if(mac != null)
            s = mac.makeSystemPretty(s);
        int j = ScriptPeer.LoadExternalFontFile(peer, i, s, flag);
        if(j == 0)
            throw new GeneratorApiException("error loading external font file");
        else
            return;
    }

    public void mergeScript(Script script, int i, int j, int k, int l, Matrix matrix)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i1 = ScriptPeer.MergeScript(peer, script.peer, i, j, k, l, matrix.peer);
        if(i1 == 0)
            throw new GeneratorApiException("error merging script");
        else
            return;
    }

    public void newExternalFont(Font font)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.NewExternalFont(peer, font.peer);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error applying the context");
        else
            return;
    }

    public void release()
    {
        if(peer != 0)
            ScriptPeer.Release(peer);
        peer = 0;
    }

    public void setBuffer(Buffer buffer)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.SetBuffer(peer, buffer.peer);
        if(i == 0)
            throw new GeneratorApiException("error setting buffer");
        else
            return;
    }

    public void setCommandBrightness(int i, float f)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.SetCommandBrightness(peer, i, f);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error setting brightness");
        else
            return;
    }

    public void setCommandColor(int i, float f, int j, float f1, int k, float f2, int l, 
            float f3, int i1)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j1 = ScriptPeer.SetCommandColor(peer, i, f, j, f1, k, f2, l, f3, i1);
        if(j1 == 0)
            throw new GeneratorApiRuntimeException("error setting custom color");
        else
            return;
    }

    public void setCommandLabel(int i, String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        String s1 = s == null ? "" : s;
        int j = ScriptPeer.SetCommandLabel(peer, i, s1);
        if(j == 0)
            throw new GeneratorApiException("error setting command label");
        else
            return;
    }

    public void setCommandMask(int i, GenObject genobject)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.SetCommandMask(peer, i, genobject.peer);
        if(j == 0)
            throw new GeneratorApiException("error setting command mask");
        else
            return;
    }

    public void setCommandMatrix(int i, Matrix matrix)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.SetCommandMatrix(peer, i, matrix.peer);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error setting matrix");
        else
            return;
    }

    public void setCommandScript(int i, Script script)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = script == null ? 0 : script.peer;
        int k = ScriptPeer.SetCommandScript(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting command script");
        else
            return;
    }

    public void setCommandTint(int i, int j, float f)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int k = ScriptPeer.SetCommandTint(peer, i, j, f);
        if(k == 0)
            throw new GeneratorApiRuntimeException("error setting tint");
        else
            return;
    }

    public void setCommandTransparency(int i, float f)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.SetCommandTransparency(peer, i, f);
        if(j == 0)
            throw new GeneratorApiRuntimeException("error setting transparency");
        else
            return;
    }

    public void setFile(String s, boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        Mac mac = Mac.getMac();
        if(mac != null)
            s = mac.makeSystemPretty(s);
        int i = ScriptPeer.SetFile(peer, s, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting file");
        else
            return;
    }

    public void setFileVersion(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = ScriptPeer.SetFileVersion(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting file version");
        else
            return;
    }

    public void setFrameRate(float f)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.SetFrameRate(peer, f);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting frame rate");
        else
            return;
    }

    public void setHeight(int i)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = i * 20;
        int k = ScriptPeer.SetHeight(peer, j);
        if(k == 0)
            throw new GeneratorApiRuntimeException("error setting height");
        else
            return;
    }

    public void setIsProcessed(boolean flag)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.SetIsProcessed(peer, flag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting processed flag");
        else
            return;
    }

    public void setLoadTopDown(boolean flag)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = ScriptPeer.SetLoadTopDown(peer, flag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting load top down flag");
        else
            return;
    }

    public void setSerial(Serial serial)
    {
        if(peer == 0)
        {
            throw new GeneratorApiRuntimeException("invalid peer");
        } else
        {
            int i = serial == null ? 0 : serial.peer;
            ScriptPeer.SetSerial(peer, i);
            return;
        }
    }

    public void setWidth(int i)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int j = i * 20;
        int k = ScriptPeer.SetWidth(peer, j);
        if(k == 0)
            throw new GeneratorApiRuntimeException("error setting width");
        else
            return;
    }

    public Buffer writeBuffer()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(ScriptPeer.Write(peer, ai) == 0)
            throw new GeneratorApiRuntimeException("unable to write to buffer");
        else
            return new Buffer(ai[0]);
    }

    public void writeFile(String s)
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        int ai1[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        if(ScriptPeer.Write(peer, ai1) == 0)
            throw new GeneratorApiException("unable to write " + s);
        BufferPeer.GetBufferCount(ai1[0], ai);
        if(ai[0] > 0)
            try
            {
                File file = new File(s);
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                for(int i = 0; i < ai[0]; i++)
                {
                    int ai2[] = new int[1];
                    BufferPeer.GetBufferSize(ai1[0], i, ai2);
                    byte abyte0[] = new byte[ai2[0]];
                    BufferPeer.GetBuffer(ai1[0], i, abyte0);
                    fileoutputstream.write(abyte0);
                }

                fileoutputstream.close();
            }
            catch(IOException _ex)
            {
                BufferPeer.Release(ai1[0]);
                throw new GeneratorApiException("unable to write " + s);
            }
        BufferPeer.Release(ai1[0]);
    }

    public void writeStream(OutputStream outputstream)
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        int ai1[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(ScriptPeer.Write(peer, ai1) == 0)
            throw new GeneratorApiException("unable to write to stream");
        BufferPeer.GetBufferCount(ai1[0], ai);
        if(ai[0] > 0)
            try
            {
                for(int i = 0; i < ai[0]; i++)
                {
                    int ai2[] = new int[1];
                    BufferPeer.GetBufferSize(ai1[0], i, ai2);
                    byte abyte0[] = new byte[ai2[0]];
                    BufferPeer.GetBuffer(ai1[0], i, abyte0);
                    outputstream.write(abyte0);
                }

            }
            catch(IOException _ex)
            {
                BufferPeer.Release(ai1[0]);
                throw new GeneratorApiException("unable to write to stream");
            }
        BufferPeer.Release(ai1[0]);
    }

    public Buffer writeText()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(ScriptPeer.WriteText(peer, ai) == 0)
            throw new GeneratorApiRuntimeException("unable to write text to the buffer");
        else
            return new Buffer(ai[0]);
    }
}