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

package com.macromedia.generator.api;

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

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

public class PngBuilder extends GenObject
{

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

    protected PngBuilder(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 = PngBuilderPeer.Build(peer, buffer.peer, buffer1.peer);
        if(i == 0)
            throw new GeneratorApiException("error building the PNG buffer");
        else
            return;
    }

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

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

    public void setColorOptimization(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = PngBuilderPeer.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 = PngBuilderPeer.SetDimensions(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting dimensions for png");
        else
            return;
    }

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

    public void setDitherType(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = PngBuilderPeer.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 = PngBuilderPeer.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 = PngBuilderPeer.SetFilePalette(peer, s);
        if(i == 0)
            throw new GeneratorApiException("error setting the custom palette");
        else
            return;
    }

    public void setGradient(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = PngBuilderPeer.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 = PngBuilderPeer.SetInterlace(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting PNG interlace");
        else
            return;
    }

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

    public void setOption(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = PngBuilderPeer.SetOption(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting PNG option");
        else
            return;
    }

    public void setPaletteType(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = PngBuilderPeer.SetPaletteType(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting palette type");
        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;
            PngBuilderPeer.SetSerial(peer, i);
            return;
        }
    }

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

    public void setType(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = PngBuilderPeer.SetType(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting PNG type");
        else
            return;
    }
}