package sayi.topla.mobile;

import oracle.adfmf.java.beans.PropertyChangeListener;
import oracle.adfmf.java.beans.PropertyChangeSupport;

public class CellValue {
    private int value = 0;
    private String styleClass;
    private String height = "50px";
    private String width = "50px";
    private final String bck_0 = "bck_0";
    private final String bck_2 = "bck_2";
    private final String bck_4 = "bck_4";
    private final String bck_8 = "bck_8";
    private final String bck_16 = "bck_16";
    private final String bck_32 = "bck_32";
    private final String bck_64 = "bck_64";
    private final String bck_128 = "bck_128";
    private final String bck_256 = "bck_256";
    private final String bck_512 = "bck_512";
    private final String bck_1024 = "bck_1024";
    private final String bck_2048 = "bck_2048";
    private final String bck_4096 = "bck_4096";
    private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);


    public CellValue() {

    }

    public CellValue(int value, String height, String width) {
        setHeight(height);
        setWidth(width);
        setValue(value);
    }

    private void setOtherValue(int value) {
        switch (value) {
        case 0:
            setStyleClass(bck_0);
            break;
        case 2:
            setStyleClass(bck_2);
            break;
        case 4:
            setStyleClass(bck_4);
            break;
        case 8:
            setStyleClass(bck_8);
            break;
        case 16:
            setStyleClass(bck_16);
            break;
        case 32:
            setStyleClass(bck_32);
            break;
        case 64:
            setStyleClass(bck_64);
            break;
        case 128:
            setStyleClass(bck_128);
            break;
        case 256:
            setStyleClass(bck_256);
            break;
        case 512:
            setStyleClass(bck_512);
            break;
        case 1024:
            setStyleClass(bck_1024);
            break;
        case 2048:
            setStyleClass(bck_2048);
            break;
        case 4096:
            setStyleClass(bck_4096);
            break;
        default:
            setStyleClass("bck_other");

        }
    }

    public void setValue(int value) {
        setOtherValue(value);
        int oldvalue = this.value;
        this.value = value;
        propertyChangeSupport.firePropertyChange("value", oldvalue, value);
    }

    public int getValue() {
        return value;
    }

    public void setStyleClass(String styleClass) {
        String oldstyleClass = this.styleClass;
        this.styleClass = styleClass;
        propertyChangeSupport.firePropertyChange("styleClass", oldstyleClass, styleClass);
    }

    public String getStyleClass() {
        return styleClass;
    }

    public void setHeight(String height) {
        String oldheight = this.height;
        this.height = height;
        propertyChangeSupport.firePropertyChange("height", oldheight, height);
    }

    public String getHeight() {
        return height;
    }

    public void setWidth(String width) {
        String oldwidth = this.width;
        this.width = width;
        propertyChangeSupport.firePropertyChange("width", oldwidth, width);
    }

    public String getWidth() {
        return width;
    }

    public void setPropertyChangeSupport(PropertyChangeSupport propertyChangeSupport) {
        PropertyChangeSupport oldPropertyChangeSupport = this.propertyChangeSupport;
        this.propertyChangeSupport = propertyChangeSupport;
        propertyChangeSupport.firePropertyChange("propertyChangeSupport", oldPropertyChangeSupport,
                                                 propertyChangeSupport);
    }

    public PropertyChangeSupport getPropertyChangeSupport() {
        return propertyChangeSupport;
    }

    public void addPropertyChangeListener(PropertyChangeListener l) {
        propertyChangeSupport.addPropertyChangeListener(l);
    }

    public void removePropertyChangeListener(PropertyChangeListener l) {
        propertyChangeSupport.removePropertyChangeListener(l);
    }
}
