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

package com.macromedia.generator.api;

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

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

public class JPEGBuilder extends GenObject
{

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

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

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

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

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

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

    public void setProgressive(boolean flag)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = JPEGBuilderPeer.SetProgressive(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("error setting progressive JPEG flag");
        else
            return;
    }

    public void setQuality(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = JPEGBuilderPeer.SetQuality(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting JPEG 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;
            JPEGBuilderPeer.SetSerial(peer, i);
            return;
        }
    }
}