Search in sources :

Example 1 with AttributeMapKey

use of com.cburch.draw.model.AttributeMapKey in project logisim-evolution by reds-heig.

the class AttrTableSelectionModel method setValueRequested.

@Override
public void setValueRequested(Attribute<Object> attr, Object value) throws AttrTableSetException {
    SelectionAttributes attrs = (SelectionAttributes) getAttributeSet();
    Map<AttributeMapKey, Object> oldVals;
    oldVals = new HashMap<AttributeMapKey, Object>();
    Map<AttributeMapKey, Object> newVals;
    newVals = new HashMap<AttributeMapKey, Object>();
    for (Map.Entry<AttributeSet, CanvasObject> ent : attrs.entries()) {
        AttributeMapKey key = new AttributeMapKey(attr, ent.getValue());
        oldVals.put(key, ent.getKey().getValue(attr));
        newVals.put(key, value);
    }
    CanvasModel model = canvas.getModel();
    canvas.doAction(new ModelChangeAttributeAction(model, oldVals, newVals));
    fireTitleChanged();
}
Also used : AttributeMapKey(com.cburch.draw.model.AttributeMapKey) CanvasObject(com.cburch.draw.model.CanvasObject) AttributeSet(com.cburch.logisim.data.AttributeSet) CanvasObject(com.cburch.draw.model.CanvasObject) CanvasModel(com.cburch.draw.model.CanvasModel) ModelChangeAttributeAction(com.cburch.draw.actions.ModelChangeAttributeAction) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with AttributeMapKey

use of com.cburch.draw.model.AttributeMapKey in project logisim-evolution by reds-heig.

the class ModelChangeAttributeAction method getName.

@Override
public String getName() {
    Attribute<?> a = attr;
    if (a == null) {
        boolean found = false;
        for (AttributeMapKey key : newValues.keySet()) {
            Attribute<?> at = key.getAttribute();
            if (found) {
                if (a == null ? at != null : !a.equals(at)) {
                    a = null;
                    break;
                }
            } else {
                found = true;
                a = at;
            }
        }
        attr = a;
    }
    if (a == null) {
        return Strings.get("actionChangeAttributes");
    } else {
        return Strings.get("actionChangeAttribute", a.getDisplayName());
    }
}
Also used : AttributeMapKey(com.cburch.draw.model.AttributeMapKey)

Aggregations

AttributeMapKey (com.cburch.draw.model.AttributeMapKey)2 ModelChangeAttributeAction (com.cburch.draw.actions.ModelChangeAttributeAction)1 CanvasModel (com.cburch.draw.model.CanvasModel)1 CanvasObject (com.cburch.draw.model.CanvasObject)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1