Search in sources :

Example 1 with TextValueItem

use of com.scriptographer.adm.TextValueItem in project scriptographer by scriptographer.

the class AdmComponentProxy method getValue.

public Object getValue() {
    if (item == null)
        return component.getDefaultValue();
    switch(component.getType()) {
        case STRING:
        case TEXT:
            return ((TextValueItem) item).getText();
        case BUTTON:
            return ((Button) item).getText();
        case NUMBER:
            return ((ValueItem) item).getValue();
        case SLIDER:
            double value = ((ValueItem) item).getValue() / factor;
            Double inc = component.getIncrement();
            if (inc != null) {
                double pre = value;
                value = Math.round(value / inc) * inc;
                if (pre != value)
                    ((ValueItem) item).setValue((float) (value * factor));
            }
            return value;
        case BOOLEAN:
            return ((ToggleItem) item).isChecked();
        case LIST:
            ListEntry selected = ((PopupList) item).getSelectedEntry();
            if (selected != null)
                return component.getOption(selected.getIndex());
            break;
        case COLOR:
            return ((ColorButton) item).getColor();
        case FONT:
            return ((FontPopupList) item).getFontWeight();
    }
    return null;
}
Also used : FontPopupList(com.scriptographer.adm.FontPopupList) ColorButton(com.scriptographer.adm.ColorButton) ColorButton(com.scriptographer.adm.ColorButton) Button(com.scriptographer.adm.Button) ToggleItem(com.scriptographer.adm.ToggleItem) TextValueItem(com.scriptographer.adm.TextValueItem) ValueItem(com.scriptographer.adm.ValueItem) PopupList(com.scriptographer.adm.PopupList) FontPopupList(com.scriptographer.adm.FontPopupList) TextValueItem(com.scriptographer.adm.TextValueItem) ListEntry(com.scriptographer.adm.ListEntry)

Aggregations

Button (com.scriptographer.adm.Button)1 ColorButton (com.scriptographer.adm.ColorButton)1 FontPopupList (com.scriptographer.adm.FontPopupList)1 ListEntry (com.scriptographer.adm.ListEntry)1 PopupList (com.scriptographer.adm.PopupList)1 TextValueItem (com.scriptographer.adm.TextValueItem)1 ToggleItem (com.scriptographer.adm.ToggleItem)1 ValueItem (com.scriptographer.adm.ValueItem)1