package com.uvigo.mhp.ui;

import java.beans.*;
import org.havi.ui.*;

public class VerticalAlignmentEditor 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 HVisible.VALIGN_TOP:
                return "TOP";
            case HVisible.VALIGN_CENTER:
                return "CENTER";
            default: // BOTTOM
                return "BOTTOM";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("TOP"))
            position = HVisible.VALIGN_TOP;
        else if (s.equalsIgnoreCase("CENTER"))
            position = HVisible.VALIGN_CENTER;
        else
            position = HVisible.VALIGN_BOTTOM;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"TOP", "CENTER", "BOTTOM"};
    }
    
    public String getJavaInitializationString()
    {
        return "org.havi.ui.HVisible.VALIGN_"+getAsText();
    }
}
