// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:41:58
// 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/GifBuilder

package com.macromedia.generator.api;

import com.macromedia.generator.api.peer.GifBuilderPeer;

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, GeneratorApiException, Buffer, Serial

public class GifBuilder extends GenObject
{

    public GifBuilder()
        throws GeneratorApiException
    {
        peer = GifBuilderPeer.New();
        if(peer == 0)
            throw new GeneratorApiException("unable to create peer");
        else
            return;
    }

    protected GifBuilder(int i)
        throws GeneratorApiException
    {
        peer = i;
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        else
            return;
    }

    public void build(Buffer buffer, Buffer buffer1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(buffer.peer == 0 || buffer1.peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.Build(peer, buffer.peer, buffer1.peer);
        if(i == 0)
            throw new GeneratorApiException("error building the GIF buffer");
        else
            return;
    }

    public void buildImageMap(boolean flag, int i, Buffer buffer, Buffer buffer1, String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(buffer.peer == 0 || buffer1.peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(s == null)
            s = new String("NOMAPNAME");
        int j = GifBuilderPeer.BuildImageMap(peer, flag, i, buffer.peer, buffer1.peer, s);
        if(j == 0)
            throw new GeneratorApiException("error building the image map buffer");
        else
            return;
    }

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

    public boolean getAnimated()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetAnimated(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting animated flag");
        else
            return aflag[0];
    }

    public boolean getColorOptimization()
        throws GeneratorApiException
    {
        boolean aflag[] = {
            true
        };
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetColorOptimization(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting the color optimization flag");
        else
            return aflag[0];
    }

    public boolean getDimensions(int ai[], int ai1[])
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetDimensions(peer, ai, ai1);
        if(i == 0)
            throw new GeneratorApiException("error getting dimensions");
        else
            return true;
    }

    public boolean getDither()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetDither(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting dither flag");
        else
            return aflag[0];
    }

    public int getDitherType()
        throws GeneratorApiException
    {
        int ai[] = {
            2
        };
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetDitherType(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting dither type value");
        else
            return ai[0];
    }

    public int getFirstFrame()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetFirstFrame(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting first frame");
        else
            return ai[0];
    }

    public boolean getGradient()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetGradient(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting gradient flag");
        else
            return aflag[0];
    }

    public boolean getInterlace()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetInterlace(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting interlace flag");
        else
            return aflag[0];
    }

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

    public int getLoopCount()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetLoopCount(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting loop count");
        else
            return ai[0];
    }

    public boolean getSmooth()
        throws GeneratorApiException
    {
        boolean aflag[] = {
            true
        };
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetSmooth(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting smooth flag");
        else
            return aflag[0];
    }

    public boolean getTransparent()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetTransparent(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting transparent flag");
        else
            return aflag[0];
    }

    public boolean getTransparentSmart()
        throws GeneratorApiException
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetTransparentSmart(peer, aflag);
        if(i == 0)
            throw new GeneratorApiException("error getting transparent smart flag");
        else
            return aflag[0];
    }

    public int getTransparentThreshold()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.GetTransparentThreshold(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting transparent threshold value");
        else
            return ai[0];
    }

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

    public void setAnimated(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetAnimated(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting animated flag");
        else
            return;
    }

    public void setColorOptimization(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetColorOptimization(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting color optimization flag");
        else
            return;
    }

    public void setDimensions(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = GifBuilderPeer.SetDimensions(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting dimensions for gif");
        else
            return;
    }

    public void setDither(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetDither(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting dither flag");
        else
            return;
    }

    public void setDitherType(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetDitherType(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting dither type flag");
        else
            return;
    }

    public void setExactFit(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetExactFit(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting exact fit flag");
        else
            return;
    }

    public void setFilePalette(String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetFilePalette(peer, s);
        if(i == 0)
            throw new GeneratorApiException("error setting the custom palette");
        else
            return;
    }

    public void setFirstFrame(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetFirstFrame(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting first frame");
        else
            return;
    }

    public void setGradient(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetGradient(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting gradient flag");
        else
            return;
    }

    public void setInterlace(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetInterlace(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting interlace flag");
        else
            return;
    }

    public void setLastFrame(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetLastFrame(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting last frame");
        else
            return;
    }

    public void setLoopCount(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetLoopCount(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting loop count");
        else
            return;
    }

    public void setMaxColors(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetMaxColors(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting max number of colors");
        else
            return;
    }

    public void setPaletteType(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetPaletteType(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting palette type");
        else
            return;
    }

    public void setQuality(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetQuality(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("Error Setting Quality");
        else
            return;
    }

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

    public void setSmooth(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetSmooth(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting smooth flag");
        else
            return;
    }

    public void setTransparent(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetTransparent(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting transparent flag");
        else
            return;
    }

    public void setTransparentSmart(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = GifBuilderPeer.SetTransparentSmart(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting transparent smart flag");
        else
            return;
    }

    public void setTransparentThreshold(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = GifBuilderPeer.SetTransparentThreshold(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting transparent threshold value");
        else
            return;
    }
}