Search in sources :

Example 1 with AttributeListener

use of com.cburch.logisim.data.AttributeListener in project logisim-evolution by reds-heig.

the class AbstractCanvasObject method setValue.

public final <V> void setValue(Attribute<V> attr, V value) {
    Object old = getValue(attr);
    boolean same = old == null ? value == null : old.equals(value);
    if (!same) {
        updateValue(attr, value);
        AttributeEvent e = new AttributeEvent(this, attr, value, old);
        for (AttributeListener listener : listeners) {
            listener.attributeValueChanged(e);
        }
    }
}
Also used : AttributeListener(com.cburch.logisim.data.AttributeListener) AttributeEvent(com.cburch.logisim.data.AttributeEvent)

Example 2 with AttributeListener

use of com.cburch.logisim.data.AttributeListener in project logisim-evolution by reds-heig.

the class DrawingAttributeSet method setValue.

public <V> void setValue(Attribute<V> attr, V value) {
    Iterator<Attribute<?>> ait = attrs.iterator();
    ListIterator<Object> vit = values.listIterator();
    while (ait.hasNext()) {
        Object a = ait.next();
        vit.next();
        if (a.equals(attr)) {
            vit.set(value);
            AttributeEvent e = new AttributeEvent(this, attr, value, null);
            for (AttributeListener listener : listeners) {
                listener.attributeValueChanged(e);
            }
            if (attr == DrawAttr.PAINT_TYPE) {
                e = new AttributeEvent(this);
                for (AttributeListener listener : listeners) {
                    listener.attributeListChanged(e);
                }
            }
            return;
        }
    }
    throw new IllegalArgumentException(attr.toString());
}
Also used : Attribute(com.cburch.logisim.data.Attribute) AbstractCanvasObject(com.cburch.draw.model.AbstractCanvasObject) CanvasObject(com.cburch.draw.model.CanvasObject) AttributeListener(com.cburch.logisim.data.AttributeListener) AttributeEvent(com.cburch.logisim.data.AttributeEvent)

Aggregations

AttributeEvent (com.cburch.logisim.data.AttributeEvent)2 AttributeListener (com.cburch.logisim.data.AttributeListener)2 AbstractCanvasObject (com.cburch.draw.model.AbstractCanvasObject)1 CanvasObject (com.cburch.draw.model.CanvasObject)1 Attribute (com.cburch.logisim.data.Attribute)1