// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Shape.java

package com.symantec.itools.awt.shape;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;

import com.symantec.itools.awt.BevelStyle;
import com.symantec.itools.awt.util.ColorUtils;
import com.symantec.itools.util.GeneralUtils;


public abstract class Shape extends Component
    implements BevelStyle
{

    protected Shape()
    {
        fillColor = Color.black;
        vetos = new com.symantec.itools.beans.VetoableChangeSupport(this);
        changes = new com.symantec.itools.beans.PropertyChangeSupport(this);
        style = 2;
        cachedBackground = getBackground();
    }

    public void setBevelStyle(int i)
        throws PropertyVetoException
    {
        if(style != i)
        {
            Integer integer = new Integer(style);
            Integer integer1 = new Integer(i);
            vetos.fireVetoableChange("BevelStyle", integer, integer1);
            style = i;
            repaint();
            changes.firePropertyChange("BevelStyle", integer, integer1);
        }
    }

    public int getBevelStyle()
    {
        return style;
    }

    public void setFillMode(boolean flag)
        throws PropertyVetoException
    {
        if(fill != flag)
        {
            Boolean boolean1 = new Boolean(fill);
            Boolean boolean2 = new Boolean(flag);
            vetos.fireVetoableChange("FillMode", boolean1, boolean2);
            fill = flag;
            repaint();
            changes.firePropertyChange("FillMode", boolean1, boolean2);
        }
    }

    public boolean isFillMode()
    {
        return fill;
    }

    public boolean getFillMode()
    {
        return isFillMode();
    }

    public void setFillColor(Color color)
        throws PropertyVetoException
    {
        if(!GeneralUtils.objectsEqual(fillColor, color))
        {
            Boolean boolean1 = new Boolean(fill);
            vetos.fireVetoableChange("FillColor", boolean1, color);
            fillColor = color;
            repaint();
            changes.firePropertyChange("FillColor", boolean1, color);
        }
    }

    public Color getFillColor()
    {
        return fillColor;
    }

    public void reshape(int i, int j, int k, int l)
    {
        width = k;
        height = l;
        super.reshape(i, j, k, l);
    }

    public Dimension getMinimumSize()
    {
        return new Dimension(10, 10);
    }

    public Dimension getPreferredSize()
    {
        Dimension dimension = getSize();
        Dimension dimension1 = getMinimumSize();
        return new Dimension(Math.max(dimension.width, dimension1.width), Math.max(dimension.height, dimension1.height));
    }

    public Dimension preferredSize()
    {
        return getPreferredSize();
    }

    public synchronized void paint(Graphics g)
    {
        Color color = getBackground();
        if(!GeneralUtils.objectsEqual(color, cachedBackground))
        {
            cachedBackground = color;
            updateBevelColors(color);
        }
    }

    public synchronized void addPropertyChangeListener(PropertyChangeListener propertychangelistener)
    {
        changes.addPropertyChangeListener(propertychangelistener);
    }

    public synchronized void removePropertyChangeListener(PropertyChangeListener propertychangelistener)
    {
        changes.removePropertyChangeListener(propertychangelistener);
    }

    public synchronized void addVetoableChangeListener(VetoableChangeListener vetoablechangelistener)
    {
        vetos.addVetoableChangeListener(vetoablechangelistener);
    }

    public synchronized void removeVetoableChangeListener(VetoableChangeListener vetoablechangelistener)
    {
        vetos.removeVetoableChangeListener(vetoablechangelistener);
    }

    protected void updateBevelColors(Color color)
    {
        bevelDarkerColor = ColorUtils.calculateShadowColor(color);
        bevelLighterColor = ColorUtils.calculateHilightColor(color);
    }

    protected int width;
    protected int height;
    protected int style;
    protected boolean fill;
    protected Color fillColor;
    protected Color bevelLighterColor;
    protected Color bevelDarkerColor;
    protected Color cachedBackground;
    protected com.symantec.itools.beans.VetoableChangeSupport vetos;
    protected com.symantec.itools.beans.PropertyChangeSupport changes;
}
