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;
}
}
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());
}
}
}
}
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);
}
}
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);
}
}
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;
}
Aggregations