Search in sources :

Example 61 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class FileStatistics method doSimpleCount.

private static Map<ComponentFactory, Count> doSimpleCount(Circuit circuit) {
    Map<ComponentFactory, Count> counts;
    counts = new HashMap<ComponentFactory, Count>();
    for (Component comp : circuit.getNonWires()) {
        ComponentFactory factory = comp.getFactory();
        Count count = counts.get(factory);
        if (count == null) {
            count = new Count(factory);
            counts.put(factory, count);
        }
        count.simpleCount++;
    }
    return counts;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) Component(com.cburch.logisim.comp.Component)

Example 62 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class ReplacementMap method append.

void append(ReplacementMap next) {
    for (Map.Entry<Component, HashSet<Component>> e : next.map.entrySet()) {
        Component b = e.getKey();
        // what b is replaced by
        HashSet<Component> cs = e.getValue();
        // what was replaced
        HashSet<Component> as = this.inverse.remove(b);
        // to get b
        if (as == null) {
            // b pre-existed replacements so
            // we say it replaces itself.
            as = new HashSet<Component>(3);
            as.add(b);
        }
        for (Component a : as) {
            HashSet<Component> aDst = this.map.get(a);
            if (aDst == null) {
                // should happen when b pre-existed only
                aDst = new HashSet<Component>(cs.size());
                this.map.put(a, aDst);
            }
            aDst.remove(b);
            aDst.addAll(cs);
        }
        for (Component c : cs) {
            // should always
            HashSet<Component> cSrc = this.inverse.get(c);
            // be null
            if (cSrc == null) {
                cSrc = new HashSet<Component>(as.size());
                this.inverse.put(c, cSrc);
            }
            cSrc.addAll(as);
        }
    }
    for (Map.Entry<Component, HashSet<Component>> e : next.inverse.entrySet()) {
        Component c = e.getKey();
        if (!inverse.containsKey(c)) {
            HashSet<Component> bs = e.getValue();
            if (!bs.isEmpty()) {
                logger.error("Internal error: component replaced but not represented");
            }
            inverse.put(c, new HashSet<Component>(3));
        }
    }
}
Also used : Component(com.cburch.logisim.comp.Component) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 63 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class ReplacementMap method put.

public void put(Component prev, Collection<? extends Component> next) {
    if (frozen) {
        throw new IllegalStateException("cannot change map after frozen");
    }
    HashSet<Component> repl = map.get(prev);
    if (repl == null) {
        repl = new HashSet<Component>(next.size());
        map.put(prev, repl);
    }
    repl.addAll(next);
    for (Component n : next) {
        repl = inverse.get(n);
        if (repl == null) {
            repl = new HashSet<Component>(3);
            inverse.put(n, repl);
        }
        repl.add(prev);
    }
}
Also used : Component(com.cburch.logisim.comp.Component)

Example 64 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class CircuitMutatorImpl method clear.

public void clear(Circuit circuit) {
    HashSet<Component> comps = new HashSet<Component>(circuit.getNonWires());
    comps.addAll(circuit.getWires());
    if (!comps.isEmpty())
        modified.add(circuit);
    log.add(CircuitChange.clear(circuit, comps));
    ReplacementMap repl = new ReplacementMap();
    for (Component comp : comps) repl.remove(comp);
    getMap(circuit).append(repl);
    circuit.mutatorClear();
}
Also used : Component(com.cburch.logisim.comp.Component) HashSet(java.util.HashSet)

Example 65 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class CircuitState method tick.

boolean tick(int ticks) {
    boolean ret = false;
    for (Component clock : circuit.getClocks()) {
        ret |= Clock.tick(this, ticks, clock);
    }
    CircuitState[] subs = new CircuitState[substates.size()];
    for (CircuitState substate : substates.toArray(subs)) {
        ret |= substate.tick(ticks);
    }
    return ret;
}
Also used : Component(com.cburch.logisim.comp.Component)

Aggregations

Component (com.cburch.logisim.comp.Component)97 Location (com.cburch.logisim.data.Location)26 ArrayList (java.util.ArrayList)20 Circuit (com.cburch.logisim.circuit.Circuit)19 AttributeSet (com.cburch.logisim.data.AttributeSet)13 Wire (com.cburch.logisim.circuit.Wire)12 Bounds (com.cburch.logisim.data.Bounds)11 HashMap (java.util.HashMap)11 HashSet (java.util.HashSet)11 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 EndData (com.cburch.logisim.comp.EndData)8 InstanceComponent (com.cburch.logisim.instance.InstanceComponent)8 Project (com.cburch.logisim.proj.Project)7 Pin (com.cburch.logisim.std.wiring.Pin)7 Graphics (java.awt.Graphics)7 CircuitState (com.cburch.logisim.circuit.CircuitState)6 Splitter (com.cburch.logisim.circuit.Splitter)6 Selection (com.cburch.logisim.gui.main.Selection)6 InstanceState (com.cburch.logisim.instance.InstanceState)5