Search in sources :

Example 1 with InstanceComponent

use of com.cburch.logisim.instance.InstanceComponent in project logisim-evolution by reds-heig.

the class Netlist method circuitChanged.

@Override
public void circuitChanged(CircuitEvent event) {
    int ev = event.getAction();
    if (event.getData() instanceof InstanceComponent) {
        InstanceComponent inst = (InstanceComponent) event.getData();
        if (event.getCircuit().equals(MyCircuit)) {
            switch(ev) {
                case CircuitEvent.ACTION_ADD:
                    DRCStatus = DRC_REQUIRED;
                    if (inst.getFactory() instanceof SubcircuitFactory) {
                        SubcircuitFactory fac = (SubcircuitFactory) inst.getFactory();
                        Circuit sub = fac.getSubcircuit();
                        if (MySubCircuitMap.containsKey(sub)) {
                            MySubCircuitMap.put(sub, MySubCircuitMap.get(sub) + 1);
                        } else {
                            MySubCircuitMap.put(sub, 1);
                            sub.addCircuitListener(this);
                        }
                    }
                    break;
                case CircuitEvent.ACTION_REMOVE:
                    DRCStatus = DRC_REQUIRED;
                    if (inst.getFactory() instanceof SubcircuitFactory) {
                        SubcircuitFactory fac = (SubcircuitFactory) inst.getFactory();
                        Circuit sub = fac.getSubcircuit();
                        if (MySubCircuitMap.containsKey(sub)) {
                            if (MySubCircuitMap.get(sub) == 1) {
                                MySubCircuitMap.remove(sub);
                                sub.removeCircuitListener(this);
                            } else {
                                MySubCircuitMap.put(sub, MySubCircuitMap.get(sub) - 1);
                            }
                        }
                    }
                    break;
                case CircuitEvent.ACTION_CHANGE:
                case CircuitEvent.ACTION_CLEAR:
                case CircuitEvent.ACTION_INVALIDATE:
                    DRCStatus = DRC_REQUIRED;
                    break;
            }
        } else {
            if (inst.getFactory() instanceof Pin) {
                DRCStatus = DRC_REQUIRED;
            }
        }
    }
}
Also used : Pin(com.cburch.logisim.std.wiring.Pin) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) InstanceComponent(com.cburch.logisim.instance.InstanceComponent)

Example 2 with InstanceComponent

use of com.cburch.logisim.instance.InstanceComponent in project logisim-evolution by reds-heig.

the class SimpleDRCContainer method ClearMarks.

public void ClearMarks() {
    if (!DRCInfoPresent())
        return;
    for (Object obj : DRCComponents) {
        if (obj instanceof Wire) {
            Wire wire = (Wire) obj;
            if ((MarkType & MARK_WIRE) != 0) {
                wire.SetMarked(false);
            }
        } else if (obj instanceof Splitter) {
            Splitter split = (Splitter) obj;
            if ((MarkType & MARK_INSTANCE) != 0) {
                split.SetMarked(false);
            }
        } else if (obj instanceof InstanceComponent) {
            InstanceComponent comp = (InstanceComponent) obj;
            comp.clearMarks();
        }
    }
}
Also used : Splitter(com.cburch.logisim.circuit.Splitter) Wire(com.cburch.logisim.circuit.Wire) InstanceComponent(com.cburch.logisim.instance.InstanceComponent)

Aggregations

InstanceComponent (com.cburch.logisim.instance.InstanceComponent)2 Circuit (com.cburch.logisim.circuit.Circuit)1 Splitter (com.cburch.logisim.circuit.Splitter)1 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)1 Wire (com.cburch.logisim.circuit.Wire)1 Pin (com.cburch.logisim.std.wiring.Pin)1