package com.uvigo.mhp.activeImage;

import java.beans.*;

public class hAlignmentEditor 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.H_LEFT:
                return ActiveImage.LEFT_STR;
            case ActiveImage.H_RIGHT:
                return ActiveImage.RIGHT_STR;
            default:
                return ActiveImage.CENTER_STR;
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase(ActiveImage.LEFT_STR))
            position = ActiveImage.H_LEFT;
        else if (s.equalsIgnoreCase(ActiveImage.RIGHT_STR))
            position = ActiveImage.H_RIGHT;
        else
            position = ActiveImage.H_CENTER;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {ActiveImage.LEFT_STR, ActiveImage.RIGHT_STR, ActiveImage.CENTER_STR};
    }
    
    public String getJavaInitializationString()
    {
        return ((Integer) getValue()).toString();
    }
}