Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.SubcircuitFactory


      Component circComp = null;
      if (circ == model.getCircuitState().getCircuit()) {
        circComp = path != null && path.length > 0 ? path[0] : comp;
      } else if (path != null) {
        for (int i = 0; i < path.length; i++) {
          SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
          if (circ == circFact.getSubcircuit()) {
            circComp = i + 1 < path.length ? path[i + 1] : comp;
          }
        }
      }
      if (circComp == null) return;
View Full Code Here


            Tool oldTool = proj.getTool();
            Circuit oldCircuit = proj.getCurrentCircuit();
            if (toolMap.containsKey(oldTool)) {
                proj.setTool(toolMap.get(oldTool));
            }
            SubcircuitFactory oldFactory = oldCircuit.getSubcircuitFactory();
            if (compMap.containsKey(oldFactory)) {
                SubcircuitFactory newFactory;
                newFactory = (SubcircuitFactory) compMap.get(oldFactory);
                proj.setCurrentCircuit(newFactory.getSubcircuit());
            }
            replaceAll(proj.getLogisimFile(), compMap, toolMap);
        }
        for (LogisimFile file : LibraryManager.instance.getLogisimLibraries()) {
            replaceAll(file, compMap, toolMap);
View Full Code Here

        for (Count count : counts.values()) {
            count.uniqueCount = count.simpleCount;
            count.recursiveCount = count.simpleCount;
        }
        for (Circuit sub : include) {
            SubcircuitFactory subFactory = sub.getSubcircuitFactory();
            if (counts.containsKey(subFactory)) {
                int multiplier = counts.get(subFactory).simpleCount;
                Map<ComponentFactory,Count> subCount;
                subCount = doRecursiveCount(sub, include, countMap);
                for (Count subcount : subCount.values()) {
View Full Code Here

    private void processCircuit(Circuit circ) {
        circ.addCircuitListener(myListener);
        for (Component comp : circ.getNonWires()) {
            if (comp.getFactory() instanceof SubcircuitFactory) {
                SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                depends.addEdge(circ, factory.getSubcircuit());
            }
        }
    }
View Full Code Here

            switch (e.getAction()) {
            case LibraryEvent.ADD_TOOL:
                if (e.getData() instanceof AddTool) {
                    ComponentFactory factory = ((AddTool) e.getData()).getFactory();
                    if (factory instanceof SubcircuitFactory) {
                        SubcircuitFactory circFact = (SubcircuitFactory) factory;
                        processCircuit(circFact.getSubcircuit());
                    }
                }
                break;
            case LibraryEvent.REMOVE_TOOL:
                if (e.getData() instanceof AddTool) {
                    ComponentFactory factory = ((AddTool) e.getData()).getFactory();
                    if (factory instanceof SubcircuitFactory) {
                        SubcircuitFactory circFact = (SubcircuitFactory) factory;
                        Circuit circ = circFact.getSubcircuit();
                        depends.removeNode(circ);
                        circ.removeCircuitListener(this);
                    }
                }
                break;
View Full Code Here

            Component comp;
            switch (e.getAction()) {
            case CircuitEvent.ACTION_ADD:
                comp = (Component) e.getData();
                if (comp.getFactory() instanceof SubcircuitFactory) {
                    SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                    depends.addEdge(e.getCircuit(), factory.getSubcircuit());
                }
                break;
            case CircuitEvent.ACTION_REMOVE:
                comp = (Component) e.getData();
                if (comp.getFactory() instanceof SubcircuitFactory) {
                    SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                    boolean found = false;
                    for (Component o : e.getCircuit().getNonWires()) {
                        if (o.getFactory() == factory) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        depends.removeEdge(e.getCircuit(), factory.getSubcircuit());
                    }

                }
                break;
            case CircuitEvent.ACTION_CLEAR:
View Full Code Here

            } else if (action == LibraryEvent.REMOVE_TOOL) {
                Object data = event.getData();
                if (data instanceof AddTool) {
                    Object factory = ((AddTool) data).getFactory();
                    if (factory instanceof SubcircuitFactory) {
                        SubcircuitFactory fact = (SubcircuitFactory) factory;
                        if (fact.getSubcircuit() == getCurrentCircuit()) {
                            setCurrentCircuit(file.getMainCircuit());
                        }
                    }
                }
            }
View Full Code Here

            }
        }
        Collections.sort(newChildren, new CompareByName());
        Collections.sort(subcircs, this);
        for (Component comp : subcircs) {
            SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
            CircuitState state = factory.getSubstate(circuitState, comp);
            SimulationTreeCircuitNode toAdd = null;
            for (TreeNode o : children) {
                if (o instanceof SimulationTreeCircuitNode) {
                    SimulationTreeCircuitNode n = (SimulationTreeCircuitNode) o;
                    if (n.circuitState == state) {
View Full Code Here

        if (!canvas.getProject().getLogisimFile().contains(circ)) {
            canvas.setErrorMessage(getFromLocale("cannotModifyError"), 0, 0);
            return;
        }
        if (factory instanceof SubcircuitFactory) {
            SubcircuitFactory circFact = (SubcircuitFactory) factory;
            Dependencies depends = canvas.getProject().getDependencies();
            if (!depends.canAdd(circ, circFact.getSubcircuit())) {
                canvas.setErrorMessage(getFromLocale("circularError"), 0, 0);
                return;
            }
        }
View Full Code Here

        if (name == null) {
            return null;
        }

        for (AddTool tool : tools) {
            SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
            if (name.equals(factory.getName())) {
                return factory.getSubcircuit();
            }

        }
        return null;
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.circuit.SubcircuitFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.