package com.uvigo.mhp.ui;

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

public class HorizontalAlignmentEditor 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.HALIGN_LEFT:
                return "LEFT";
            case HVisible.HALIGN_CENTER:
                return "CENTER";
            default: // RIGHT
                return "RIGHT";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("LEFT"))
            position = HVisible.HALIGN_LEFT;
        else if (s.equalsIgnoreCase("CENTER"))
            position = HVisible.HALIGN_CENTER;
        else
            position = HVisible.HALIGN_RIGHT;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"LEFT", "CENTER", "RIGHT"};
    }
    
    public String getJavaInitializationString()
    {
        return "org.havi.ui.HVisible.HALIGN_"+getAsText();
    }
}
