Search in sources :

Example 16 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method menuRequested.

public JPopupMenu menuRequested(ProjectExplorerEvent event) {
    Object clicked = event.getTarget();
    if (clicked instanceof ProjectExplorerToolNode) {
        Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
        if (baseTool instanceof AddTool) {
            AddTool tool = (AddTool) baseTool;
            ComponentFactory source = tool.getFactory();
            if (source instanceof SubcircuitFactory) {
                Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
                return Popups.forCircuit(proj, tool, circ);
            } else {
                return null;
            }
        } else {
            return null;
        }
    } else if (clicked instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) clicked).getValue();
        if (lib == proj.getLogisimFile()) {
            return Popups.forProject(proj);
        } else {
            boolean is_top = event.getTreePath().getPathCount() <= 2;
            return Popups.forLibrary(proj, lib, is_top);
        }
    } else {
        return null;
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 17 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method deleteRequested.

public void deleteRequested(ProjectExplorerEvent event) {
    Object request = event.getTarget();
    if (request instanceof ProjectExplorerLibraryNode) {
        Library lib = ((ProjectExplorerLibraryNode) request).getValue();
        ProjectLibraryActions.doUnloadLibrary(proj, lib);
    } else if (request instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) request).getValue();
        if (tool instanceof AddTool) {
            ComponentFactory factory = ((AddTool) tool).getFactory();
            if (factory instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) factory;
                ProjectCircuitActions.doRemoveCircuit(proj, circFact.getSubcircuit());
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) ProjectExplorerLibraryNode(com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode) Library(com.cburch.logisim.tools.Library) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 18 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class LoadedLibrary method replaceAll.

private static void replaceAll(Map<ComponentFactory, ComponentFactory> compMap, Map<Tool, Tool> toolMap) {
    for (Project proj : Projects.getOpenProjects()) {
        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);
    }
}
Also used : Project(com.cburch.logisim.proj.Project) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 19 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class LogisimFile method removeCircuit.

public void removeCircuit(Circuit circuit) {
    if (tools.size() <= 1) {
        throw new RuntimeException("Cannot remove last circuit");
    }
    int index = getCircuits().indexOf(circuit);
    if (index >= 0) {
        Tool circuitTool = tools.remove(index);
        if (main == circuit) {
            AddTool dflt_tool = tools.get(0);
            SubcircuitFactory factory = (SubcircuitFactory) dflt_tool.getFactory();
            setMainCircuit(factory.getSubcircuit());
        }
        fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
    }
}
Also used : SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 20 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class FileStatistics method getTotal.

private static Count getTotal(List<Count> counts, Set<Circuit> exclude) {
    Count ret = new Count(null);
    for (Count count : counts) {
        ComponentFactory factory = count.getFactory();
        Circuit factoryCirc = null;
        if (factory instanceof SubcircuitFactory) {
            factoryCirc = ((SubcircuitFactory) factory).getSubcircuit();
        }
        if (exclude == null || !exclude.contains(factoryCirc)) {
            ret.simpleCount += count.simpleCount;
            ret.uniqueCount += count.uniqueCount;
            ret.recursiveCount += count.recursiveCount;
        }
    }
    return ret;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit)

Aggregations

SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)32 ArrayList (java.util.ArrayList)13 Circuit (com.cburch.logisim.circuit.Circuit)12 Component (com.cburch.logisim.comp.Component)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 AddTool (com.cburch.logisim.tools.AddTool)8 Tool (com.cburch.logisim.tools.Tool)6 InstanceComponent (com.cburch.logisim.instance.InstanceComponent)5 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Wire (com.cburch.logisim.circuit.Wire)3 Pin (com.cburch.logisim.std.wiring.Pin)3 Library (com.cburch.logisim.tools.Library)3 NetlistComponent (com.bfh.logisim.designrulecheck.NetlistComponent)2 CircuitException (com.cburch.logisim.circuit.CircuitException)2 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)2 CircuitState (com.cburch.logisim.circuit.CircuitState)2 EndData (com.cburch.logisim.comp.EndData)2 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2