Search in sources :

Example 1 with LinkedList

use of org.apache.pivot.collections.LinkedList in project pivot by apache.

the class Component method setSkin.

/**
 * Sets the skin, replacing any previous skin.
 *
 * @param skin The new skin.
 */
@SuppressWarnings("unchecked")
protected void setSkin(Skin skin) {
    Utils.checkNull(skin, "skin");
    if (this.skin != null) {
        throw new IllegalStateException("Skin is already installed.");
    }
    this.skin = skin;
    styles = new BeanAdapter(skin);
    skin.install(this);
    // Apply any defined type styles
    LinkedList<Class<?>> styleTypes = new LinkedList<>();
    Class<?> type = getClass();
    while (type != Object.class) {
        styleTypes.insert(type, 0);
        type = type.getSuperclass();
    }
    for (Class<?> styleType : styleTypes) {
        Map<String, ?> stylesMap = typedStyles.get((Class<? extends Component>) styleType);
        if (stylesMap != null) {
            setStyles(stylesMap);
        }
    }
    invalidate();
    repaint();
}
Also used : BeanAdapter(org.apache.pivot.beans.BeanAdapter) LinkedList(org.apache.pivot.collections.LinkedList)

Aggregations

BeanAdapter (org.apache.pivot.beans.BeanAdapter)1 LinkedList (org.apache.pivot.collections.LinkedList)1