package com.uvigo.mhp.activeImage;

import java.beans.*;

public class vAlignmentEditor 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 ActiveImage.V_TOP:
                return ActiveImage.TOP_STR;
            case ActiveImage.V_BOTTOM:
                return ActiveImage.BOTTOM_STR;
            default:
                return ActiveImage.CENTER_STR;
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase(ActiveImage.TOP_STR))
            position = ActiveImage.V_TOP;
        else if (s.equalsIgnoreCase(ActiveImage.BOTTOM_STR))
            position = ActiveImage.V_BOTTOM;
        else
            position = ActiveImage.V_CENTER;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {ActiveImage.TOP_STR, ActiveImage.BOTTOM_STR, ActiveImage.CENTER_STR};
    }
    
    public String getJavaInitializationString()
    {
        return ((Integer) getValue()).toString();
    }
}
