package com.uvigo.mhp.looks;

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

public class HGraphicLook2AlignmentEditor extends PropertyEditorSupport
{
    private int alignment;
    
    public void setValue(Object o)
    {
        alignment = ((Integer)o).intValue();
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(alignment);
    }
    
    public String getAsText()
    {
        switch (alignment)
        {
            case HGraphicLook2.ALIGN_LEFT:
                return "LEFT";
            case HGraphicLook2.ALIGN_RIGHT:
                return "RIGHT";
            default: // ALIGN_CENTER
                return "CENTER";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("LEFT"))
            alignment = HGraphicLook2.ALIGN_LEFT;
        else if (s.equalsIgnoreCase("RIGHT"))
            alignment = HGraphicLook2.ALIGN_RIGHT;
        else
            alignment = HGraphicLook2.ALIGN_CENTER;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"LEFT", "RIGHT", "CENTER"};
    }
    
    public String getJavaInitializationString()
    {
        return new Integer(alignment).toString();
    }
}
