package com.uvigo.mhp.looks;

import java.beans.*;
import javax.swing.*;

public class HGraphicLook2ImagePositionEditor extends PropertyEditorSupport
{
    private int position;
    
    public void setValue(Object o)
    {
        position = ((Integer)o).intValue();
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(position);
    }
    
    public String getAsText()
    {
        switch (position)
        {
            case HGraphicLook2.IMAGE_LEFT:
                return "LEFT";
            case HGraphicLook2.IMAGE_RIGHT:
                return "RIGHT";
            case HGraphicLook2.IMAGE_TOP:
                return "TOP";
            default: // BOTTOM
                return "BOTTOM";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("LEFT"))
            position = HGraphicLook2.IMAGE_LEFT;
        else if (s.equalsIgnoreCase("RIGHT"))
            position = HGraphicLook2.IMAGE_RIGHT;
        else if (s.equalsIgnoreCase("TOP"))
            position = HGraphicLook2.IMAGE_TOP;
        else
            position = HGraphicLook2.IMAGE_BOTTOM;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"LEFT", "RIGHT", "TOP", "BOTTOM"};
    }
    
    public String getJavaInitializationString()
    {
        return new Integer(position).toString();
    }
}
