Search in sources :

Example 36 with AttributeSet

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

the class SelectionAttributes method computeAttributes.

private static LinkedHashMap<Attribute<Object>, Object> computeAttributes(Collection<Component> newSel) {
    LinkedHashMap<Attribute<Object>, Object> attrMap;
    attrMap = new LinkedHashMap<Attribute<Object>, Object>();
    Iterator<Component> sit = newSel.iterator();
    if (sit.hasNext()) {
        AttributeSet first = sit.next().getAttributeSet();
        for (Attribute<?> attr : first.getAttributes()) {
            @SuppressWarnings("unchecked") Attribute<Object> attrObj = (Attribute<Object>) attr;
            attrMap.put(attrObj, first.getValue(attr));
        }
        while (sit.hasNext()) {
            AttributeSet next = sit.next().getAttributeSet();
            Iterator<Attribute<Object>> ait = attrMap.keySet().iterator();
            while (ait.hasNext()) {
                Attribute<Object> attr = ait.next();
                if (next.containsAttribute(attr)) {
                    Object v = attrMap.get(attr);
                    if (v != null && !v.equals(next.getValue(attr))) {
                        attrMap.put(attr, null);
                    }
                } else {
                    ait.remove();
                }
            }
        }
    }
    return attrMap;
}
Also used : Attribute(com.cburch.logisim.data.Attribute) AbstractAttributeSet(com.cburch.logisim.data.AbstractAttributeSet) AttributeSet(com.cburch.logisim.data.AttributeSet) Component(com.cburch.logisim.comp.Component)

Example 37 with AttributeSet

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

the class InstanceFactory method createAttributeSet.

@Override
public AttributeSet createAttributeSet() {
    Attribute<?>[] as = attrs;
    AttributeSet ret = as == null ? AttributeSets.EMPTY : AttributeSets.fixedSet(as, defaults);
    return ret;
}
Also used : Attribute(com.cburch.logisim.data.Attribute) AttributeSet(com.cburch.logisim.data.AttributeSet)

Example 38 with AttributeSet

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

the class AbstractComponentFactory method getDefaultAttributeValue.

public Object getDefaultAttributeValue(Attribute<?> attr, LogisimVersion ver) {
    AttributeSet dfltSet = defaultSet;
    if (dfltSet == null) {
        dfltSet = (AttributeSet) createAttributeSet().clone();
        defaultSet = dfltSet;
    }
    return dfltSet.getValue(attr);
}
Also used : AttributeSet(com.cburch.logisim.data.AttributeSet)

Example 39 with AttributeSet

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

the class CircuitMutatorImpl method set.

public void set(Circuit circuit, Component comp, Attribute<?> attr, Object newValue) {
    if (circuit.contains(comp)) {
        modified.add(circuit);
        @SuppressWarnings("unchecked") Attribute<Object> a = (Attribute<Object>) attr;
        AttributeSet attrs = comp.getAttributeSet();
        Object oldValue = attrs.getValue(a);
        log.add(CircuitChange.set(circuit, comp, attr, oldValue, newValue));
        attrs.setValue(a, newValue);
    }
}
Also used : Attribute(com.cburch.logisim.data.Attribute) AttributeSet(com.cburch.logisim.data.AttributeSet)

Example 40 with AttributeSet

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

the class CircuitAttributes method createBaseAttrs.

static AttributeSet createBaseAttrs(Circuit source, String name) {
    AttributeSet ret = AttributeSets.fixedSet(STATIC_ATTRS, STATIC_DEFAULTS);
    ret.setValue(CircuitAttributes.NAME_ATTR, name);
    ret.addAttributeListener(new StaticListener(source));
    return ret;
}
Also used : AbstractAttributeSet(com.cburch.logisim.data.AbstractAttributeSet) AttributeSet(com.cburch.logisim.data.AttributeSet)

Aggregations

AttributeSet (com.cburch.logisim.data.AttributeSet)65 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)16 Component (com.cburch.logisim.comp.Component)13 TreeMap (java.util.TreeMap)13 Attribute (com.cburch.logisim.data.Attribute)12 Location (com.cburch.logisim.data.Location)9 HashMap (java.util.HashMap)7 Value (com.cburch.logisim.data.Value)6 Circuit (com.cburch.logisim.circuit.Circuit)5 Direction (com.cburch.logisim.data.Direction)4 Graphics (java.awt.Graphics)4 Map (java.util.Map)4 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)3 Wire (com.cburch.logisim.circuit.Wire)3 AbstractAttributeSet (com.cburch.logisim.data.AbstractAttributeSet)3 BitWidth (com.cburch.logisim.data.BitWidth)3 Bounds (com.cburch.logisim.data.Bounds)3 ToolAttributeAction (com.cburch.logisim.gui.main.ToolAttributeAction)3 Action (com.cburch.logisim.proj.Action)3 Project (com.cburch.logisim.proj.Project)3