// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 11:00: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/utils/Chart

package com.macromedia.generator.utils;

import com.macromedia.generator.api.*;
import com.macromedia.generator.app.*;
import com.macromedia.generator.platform.Mac;
import java.io.File;
import java.util.Locale;
import java.util.ResourceBundle;

// Referenced classes of package com.macromedia.generator.utils:
//            ChartPeer, PropertyParser

public class Chart extends GenObject
{

    public Chart(String s, FlashEnvironment flashenvironment, Context context, Script script)
        throws GeneratorApiException
    {
        _fld0276 = null;
        _fld0119 = context;
        _fld0115 = flashenvironment;
        _fld0276 = s.concat("Data");
        peer = ChartPeer.New();
        if(peer == 0)
            throw new GeneratorApiException("unable to create peer");
        else
            return;
    }

    public String GetResourceString(String s)
    {
        ResourceBundle resourcebundle = ResourceBundle.getBundle(_fld0276, Locale.getDefault());
        return resourcebundle.getString(s);
    }

    public String MakeFloatLabel(float f)
    {
        int i = (int)f;
        float f1 = f - (float)i;
        if((double)Math.abs(f1) < 0.01D)
        {
            String s = (new Integer(i)).toString();
            return s;
        }
        i = f <= 0.0F ? i - 1 : i + 1;
        f1 = (float)i - f;
        if((double)Math.abs(f1) < 0.01D)
        {
            String s1 = (new Integer(i)).toString();
            return s1;
        }
        i = (int)(f * 100F);
        String s2 = (new Integer(i)).toString();
        int j = s2.length();
        if(j < 2)
            j = 2;
        String s3 = s2.substring(0, j - 2);
        String s4 = s2.substring(j - 2);
        String s5 = s3 + '.' + s4;
        return s5;
    }

    public void RenderLabels(FlashEnvironment flashenvironment, GenVector genvector, Script script)
    {
        if(script == null)
            return;
        float f = getMajorInterval();
        float f1 = getChartMin();
        float f2 = getChartMax();
        float f3 = f - (float)(new Float(f)).longValue();
        boolean flag = f3 < 1E-005F;
        for(float f4 = f1; f4 <= f2 + 1E-005F;)
        {
            Context context = (Context)genvector.add(new Context());
            context.setParent(_fld0119);
            if(flag)
            {
                String s = (new Integer((int)f4)).toString();
                context.setValue("label", s);
            } else
            {
                String s1 = MakeFloatLabel(f4);
                context.setValue("label", s1);
            }
            Script script1 = (Script)genvector.add(script.copyScript());
            flashenvironment.processScript(script1, context);
            setLabel(f4, script1);
            f4 += f;
            genvector.release(context);
            genvector.release(script1);
        }

    }

    public void addHorizontalLabelScript(int i, Script script)
    {
        int j = 0;
        if(script != null)
            j = script.getPeer();
        ChartPeer.addHorizontalLabelScript(peer, i, j);
    }

    public void addStackValueScript(int i, int j, Script script)
    {
        int k = 0;
        if(script != null)
            k = script.getPeer();
        ChartPeer.addStackValueScript(peer, i, j, k);
    }

    public void addValueScript(int i, Script script)
    {
        int j = 0;
        if(script != null)
            j = script.getPeer();
        ChartPeer.addValueScript(peer, i, j);
    }

    public void computeChartSize()
    {
        ChartPeer.computeChartSize(peer);
    }

    public void drawScatterLines(boolean flag)
    {
        ChartPeer.drawScatterLines(peer, flag);
    }

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

    public float getChartMax()
    {
        return ChartPeer.getChartMax(peer);
    }

    public float getChartMin()
    {
        return ChartPeer.getChartMin(peer);
    }

    public Script getLabelScript(Script script, PropertyParser propertyparser)
    {
        if(script == null || propertyparser == null)
            return null;
        String s = "chartLabel1";
        String s1 = propertyparser.GetStringParam("labelformat");
        if(s1 != null)
            if(s1.equalsIgnoreCase(GetResourceString("Arial")))
                s = "chartLabel1";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Times")))
                s = "chartLabel2";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Courier")))
                s = "chartLabel3";
        Script script1 = script.findScript(s);
        if(script1 == null)
        {
            script1 = script.findScript("chartLabel1");
            if(script1 == null)
            {
                script1 = script.findScript("chartLabel2");
                if(script1 == null)
                    script1 = script.findScript("chartLabel3");
            }
        }
        return script1;
    }

    public float getMajorInterval()
    {
        return ChartPeer.getMajorInterval(peer);
    }

    public Script getScatterValueScript(Script script, PropertyParser propertyparser)
    {
        if(script == null || propertyparser == null)
            return null;
        String s = "scatterValue1";
        String s1 = propertyparser.GetStringParam("valueformat");
        if(s1 != null)
            if(s1.equalsIgnoreCase(GetResourceString("Arial")))
                s = "scatterValue1";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Times")))
                s = "scatterValue2";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Courier")))
                s = "scatterValue3";
        Script script1 = script.findScript(s);
        return script1;
    }

    public Script getSymbolScript(String s)
    {
        Object obj = null;
        Script script = null;
        if(s != null && s != "")
        {
            Mac mac = Mac.getMac();
            File file;
            if(mac != null)
            {
                String s1 = mac.makeJavaPretty(s);
                file = new File(s1);
                if(!file.exists() || !file.isFile())
                    file = new File(s1.substring(1));
            } else
            {
                file = new File(s);
            }
            if(!file.isAbsolute())
                file = new File(_fld0115.getDirectory(), file.getPath());
            if(!file.exists() || !file.isFile())
            {
                script = null;
            } else
            {
                script = new Script();
                boolean flag = _fld0115.getPreviewMode();
                try
                {
                    script.setFile(file.getPath(), flag ^ true);
                }
                catch(GeneratorApiException _ex)
                {
                    script = null;
                }
            }
            if(script != null)
                try
                {
                    CacheManager cachemanager = _fld0115.getCacheManager();
                    if(cachemanager != null)
                        cachemanager.loadExternalFonts(_fld0115, script);
                }
                catch(GeneratorApiException _ex) { }
        }
        if(script == null)
        {
            _fld0115.loadDefaultSymbols();
            script = _fld0115.getDefaultSymbolScript();
        }
        return script;
    }

    public Script getValueScript(Script script, PropertyParser propertyparser)
    {
        if(script == null || propertyparser == null)
            return null;
        String s = "chartValue1";
        String s1 = propertyparser.GetStringParam("valueformat");
        if(s1 != null)
            if(s1.equalsIgnoreCase(GetResourceString("Arial")))
                s = "chartValue1";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Times")))
                s = "chartValue2";
            else
            if(s1.equalsIgnoreCase(GetResourceString("Courier")))
                s = "chartValue3";
        Script script1 = script.findScript(s);
        if(script1 == null)
        {
            script1 = script.findScript("chartValue1");
            if(script1 == null)
            {
                script1 = script.findScript("chartValue2");
                if(script1 == null)
                    script1 = script.findScript("chartValue3");
            }
        }
        return script1;
    }

    public void process()
        throws GeneratorApiException
    {
        int i = ChartPeer.process(peer);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void processLines()
        throws GeneratorApiException
    {
        int i = ChartPeer.processLines(peer);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void processPie()
        throws GeneratorApiException
    {
        int i = ChartPeer.processPie(peer);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void processStock(int i)
        throws GeneratorApiException
    {
        int j = ChartPeer.processStock(peer, i);
        if(j == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void pushDataSet()
    {
        ChartPeer.pushDataSet(peer);
    }

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

    public void set2DData(int i, float f, float f1, Script script)
    {
        int j = 0;
        if(script != null)
            j = script.getPeer();
        ChartPeer.set2DData(peer, i, f, f1, j);
    }

    public void setAnimateFrameCount(int i, int j)
    {
        ChartPeer.setAnimateFrameCount(peer, i, j);
    }

    public void setAreaFill(boolean flag)
        throws GeneratorApiException
    {
        int i = ChartPeer.setAreaFill(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void setAutoScale(boolean flag)
        throws GeneratorApiException
    {
        int i = ChartPeer.setAutoScale(peer, flag);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart");
        else
            return;
    }

    public void setBorder(boolean flag)
    {
        int i = ChartPeer.setBorder(peer, flag);
    }

    public void setChartDataSize(float f, float f1)
        throws GeneratorApiException
    {
        int i = ChartPeer.setChartDataSize(peer, f, f1);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart data limits");
        else
            return;
    }

    public void setChartLineThickness(int i)
    {
        ChartPeer.setChartLineThickness(peer, i);
    }

    public void setChartRect(Rect rect)
    {
        if(rect == null)
        {
            return;
        } else
        {
            ChartPeer.setChartRect(peer, rect.getPeer());
            return;
        }
    }

    public void setClip(Script script, int i)
    {
        int j = 0;
        if(script != null)
            j = script.getPeer();
        ChartPeer.setClip(peer, j, i);
    }

    public void setDataColor(int i, int j)
    {
        ChartPeer.setDataColor(peer, i, j);
    }

    public void setDataCount(int i)
    {
        ChartPeer.setDataCount(peer, i);
    }

    public void setDataValue(int i, float f)
    {
        ChartPeer.setDataValue(peer, i, f);
    }

    public void setDataValue(int i, float f, int j)
    {
        ChartPeer.setDataValue(peer, i, f, j);
    }

    public void setDepth3D(float f)
    {
        ChartPeer.setDepth3D(peer, f);
    }

    public void setDivisions(int i, int j)
        throws GeneratorApiException
    {
        int k = ChartPeer.setDivisions(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("Invalid chart divisions");
        else
            return;
    }

    public void setEffect3D(boolean flag)
    {
        ChartPeer.setEffect3D(peer, flag);
    }

    public void setFrameCount(int i)
    {
        ChartPeer.setFrameCount(peer, i);
    }

    public void setGoTo(int i, int j, String s)
        throws GeneratorApiException
    {
        int k = ChartPeer.setGoTo(peer, i, j, s);
        if(k == 0)
            throw new GeneratorApiException("Invalid GoTo");
        else
            return;
    }

    public void setGoToLabel(int i, String s, String s1)
        throws GeneratorApiException
    {
        int j = ChartPeer.setGoToLabel(peer, i, s, s1);
        if(j == 0)
            throw new GeneratorApiException("Invalid GoTo");
        else
            return;
    }

    public void setGridLines(int i)
    {
        int j = ChartPeer.setGridLines(peer, i);
    }

    public void setHorizontalLabelDisplay(int i, int j, float f)
        throws GeneratorApiException
    {
        if(i != 0 && i != 1)
            return;
        int k = ChartPeer.setHorizontalLabelDisplay(peer, i, j, f);
        if(k == 0)
            throw new GeneratorApiException("Invalid horizontal label");
        else
            return;
    }

    public void setLabel(float f, Script script)
    {
        int i = 0;
        if(script != null)
            i = script.getPeer();
        ChartPeer.setLabel(peer, f, i);
    }

    public void setLabels(boolean flag)
    {
        int i = ChartPeer.setLabels(peer, flag);
    }

    public void setLineStyle(int i, int j, int k, int l)
    {
        ChartPeer.setLineStyle(peer, i, j, k, l);
    }

    public void setMaxDataEntries(int i)
    {
        ChartPeer.setMaxDataEntries(peer, i);
    }

    public void setMultiDimenDataCount(int i, int j)
    {
        ChartPeer.setMultiDimenDataCount(peer, i, j);
    }

    public void setMultiDimenValue(int i, float af[], int j)
    {
        ChartPeer.setMultiDimenValue(peer, i, af, j);
    }

    public void setOrigin(float f)
        throws GeneratorApiException
    {
        int i = ChartPeer.setOrigin(peer, f);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart origin");
        else
            return;
    }

    public void setPieLabelPosition(int i)
    {
        int j = ChartPeer.setPieLabelPosition(peer, i);
    }

    public void setSpacing(int i, int j)
    {
        int k = ChartPeer.setSpacing(peer, i, j);
    }

    public void setStackColor(int i, int j)
    {
        ChartPeer.setStackColor(peer, i, j);
    }

    public void setStackCount(int i, int j)
    {
        ChartPeer.setStackCount(peer, i, j);
    }

    public void setStackGoTo(int i, int j, int k, String s)
        throws GeneratorApiException
    {
        int l = ChartPeer.setStackGoTo(peer, i, j, k, s);
        if(l == 0)
            throw new GeneratorApiException("Invalid GoTo");
        else
            return;
    }

    public void setStackGoToLabel(int i, int j, String s, String s1)
        throws GeneratorApiException
    {
        int k = ChartPeer.setStackGoToLabel(peer, i, j, s, s1);
        if(k == 0)
            throw new GeneratorApiException("Invalid GoTo");
        else
            return;
    }

    public void setStackURL(int i, int j, String s, String s1)
        throws GeneratorApiException
    {
        int k = ChartPeer.setStackURL(peer, i, j, s, s1);
        if(k == 0)
            throw new GeneratorApiException("Invalid URL");
        else
            return;
    }

    public void setStackValue(int i, int j, float f)
    {
        ChartPeer.setStackValue(peer, i, j, f);
    }

    public void setURL(int i, String s, String s1)
        throws GeneratorApiException
    {
        int j = ChartPeer.setURL(peer, i, s, s1);
        if(j == 0)
            throw new GeneratorApiException("Invalid URL");
        else
            return;
    }

    public void setUserLimits(float f, boolean flag, float f1, boolean flag1)
        throws GeneratorApiException
    {
        int i = ChartPeer.setUserLimits(peer, f, flag, f1, flag1);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart user limits");
        else
            return;
    }

    public void setUserXLimits(float f, boolean flag, float f1, boolean flag1)
        throws GeneratorApiException
    {
        int i = ChartPeer.setUserXLimits(peer, f, flag, f1, flag1);
        if(i == 0)
            throw new GeneratorApiException("Invalid chart user limits");
        else
            return;
    }

    public void setValueDisplay(int i, int j, float f)
        throws GeneratorApiException
    {
        if(i != 0 && i != 1 && i != 2)
            return;
        int k = ChartPeer.setValueDisplay(peer, i, j, f);
        if(k == 0)
            throw new GeneratorApiException("Invalid chart origin");
        else
            return;
    }

    public void setValuePlacement(int i)
        throws GeneratorApiException
    {
        int j = ChartPeer.setValuePlacement(peer, i);
        if(j == 0)
            throw new GeneratorApiException("Invalid chart origin");
        else
            return;
    }

    Context _fld0119;
    FlashEnvironment _fld0115;
    String _fld0276;
    public static final int VALUE_NEVER = 0;
    public static final int VALUE_ALWAYS = 1;
    public static final int VALUE_ROLLOVER = 2;
    public static final int VALUE_PLACE_ON_BAR = 0;
    public static final int VALUE_PLACE_OVER_BAR = 1;
    public static final int VALUE_PLACE_OVER_CHART = 2;
    public static final int VALUE_PLACE_UNDER_CHART = 3;
    public static final int VALUE_SCALE_UNDEF = -1;
    public static final int VALUE_SCALE_FIT = 1;
    public static final int VALUE_SCALE_FIXED = 2;
    public static final int VALUE_SCALE_SCALE = 3;
    public static final int VALUE_SCALE_ABS = 4;
    public static final int HORIZONTAL_LABEL_VERTICAL = 0;
    public static final int HORIZONTAL_LABEL_HORIZONTAL = 1;
    public static final int HORIZONTAL_LABEL_FIT = 1;
    public static final int HORIZONTAL_LABEL_FIXED = 2;
    public static final int HORIZONTAL_LABEL_SCALE = 3;
    public static final int HORIZONTAL_LABEL_ABS = 4;
    public static final int ANIMATE_SEQUENTIAL = 0;
    public static final int ANIMATE_CONSTANT_TIME = 1;
    public static final int ANIMATE_CONSTANT_SPEED = 2;
    public static final float EPSILON = 1E-005F;
}