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

package com.macromedia.generator.api;

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

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, GeneratorApiException, Rect, FillStyle, 
//            LineStyle

public class Shape extends GenObject
{

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

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

    public void append(Shape shape)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ShapePeer.Append(peer, shape.peer);
        if(i == 0)
            throw new GeneratorApiException("error appending shape");
        else
            return;
    }

    public void curveTo(int i, int j, int k, int l)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(i > 30000 || j > 30000 || i < -30000 || j < -30000)
            throw new GeneratorApiException("Shape outline range error");
        if(k > 30000 || l > 30000 || k < -30000 || l < -30000)
            throw new GeneratorApiException("Shape outline range error");
        int i1 = ShapePeer.CurveTo(peer, i, j, k, l);
        if(i1 == 0)
            throw new GeneratorApiException("error adding a curve");
        else
            return;
    }

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

    public Rect getBounds()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ShapePeer.GetBounds(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting bounds");
        else
            return new Rect(ai[0]);
    }

    public void lineTo(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(i > 30000 || j > 30000 || i < -30000 || j < -30000)
            throw new GeneratorApiException("Shape outline range error");
        int k = ShapePeer.LineTo(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error adding a line");
        else
            return;
    }

    public void moveTo(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(i > 30000 || j > 30000 || i < -30000 || j < -30000)
            throw new GeneratorApiException("Shape outline range error");
        int k = ShapePeer.MoveTo(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error moving to a position");
        else
            return;
    }

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

    public void setCenter(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(i > 30000 || j > 30000 || i < -30000 || j < -30000)
            throw new GeneratorApiException("Shape outline range error");
        int k = ShapePeer.SetCenter(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting center");
        else
            return;
    }

    public void setFillStyle(FillStyle fillstyle, FillStyle fillstyle1)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ShapePeer.SetFillStyle(peer, fillstyle.peer, fillstyle1.peer);
        if(i == 0)
            throw new GeneratorApiException("error setting the fill style");
        else
            return;
    }

    public void setLineStyle(LineStyle linestyle)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ShapePeer.SetLineStyle(peer, linestyle.peer);
        if(i == 0)
            throw new GeneratorApiException("error setting the line style");
        else
            return;
    }
}