Search in sources :

Example 21 with Circuit

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

the class LoadedLibrary method replaceAll.

private static void replaceAll(LogisimFile file, Map<ComponentFactory, ComponentFactory> compMap, Map<Tool, Tool> toolMap) {
    file.getOptions().getToolbarData().replaceAll(toolMap);
    file.getOptions().getMouseMappings().replaceAll(toolMap);
    for (Circuit circuit : file.getCircuits()) {
        replaceAll(circuit, compMap);
    }
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit)

Example 22 with Circuit

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

the class LogisimFile method createNew.

// 
// creation methods
// 
public static LogisimFile createNew(Loader loader, Project proj) {
    LogisimFile ret = new LogisimFile(loader);
    ret.main = new Circuit("main", ret, proj);
    // The name will be changed in LogisimPreferences
    ret.tools.add(new AddTool(ret.main.getSubcircuitFactory()));
    return ret;
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool)

Example 23 with Circuit

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

the class LogisimFile method getUnloadLibraryMessage.

public String getUnloadLibraryMessage(Library lib) {
    HashSet<ComponentFactory> factories = new HashSet<ComponentFactory>();
    for (Tool tool : lib.getTools()) {
        if (tool instanceof AddTool) {
            factories.add(((AddTool) tool).getFactory());
        }
    }
    for (Circuit circuit : getCircuits()) {
        for (Component comp : circuit.getNonWires()) {
            if (factories.contains(comp.getFactory())) {
                return StringUtil.format(Strings.get("unloadUsedError"), circuit.getName());
            }
        }
    }
    ToolbarData tb = options.getToolbarData();
    MouseMappings mm = options.getMouseMappings();
    for (Tool t : lib.getTools()) {
        if (tb.usesToolFromSource(t)) {
            return Strings.get("unloadToolbarError");
        }
        if (mm.usesToolFromSource(t)) {
            return Strings.get("unloadMappingError");
        }
    }
    return null;
}
Also used : ComponentFactory(com.cburch.logisim.comp.ComponentFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) Component(com.cburch.logisim.comp.Component) HashSet(java.util.HashSet) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 24 with Circuit

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

the class LogisimFile method getCircuits.

public List<Circuit> getCircuits() {
    List<Circuit> ret = new ArrayList<Circuit>(tools.size());
    for (AddTool tool : tools) {
        SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
        ret.add(factory.getSubcircuit());
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool)

Example 25 with Circuit

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

the class Project method addCircuitListener.

public void addCircuitListener(CircuitListener value) {
    circuitListeners.add(value);
    Circuit current = getCurrentCircuit();
    if (current != null)
        current.addCircuitListener(value);
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit)

Aggregations

Circuit (com.cburch.logisim.circuit.Circuit)62 Component (com.cburch.logisim.comp.Component)19 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)12 Project (com.cburch.logisim.proj.Project)11 ArrayList (java.util.ArrayList)9 Wire (com.cburch.logisim.circuit.Wire)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 Location (com.cburch.logisim.data.Location)8 Bounds (com.cburch.logisim.data.Bounds)6 LogisimFile (com.cburch.logisim.file.LogisimFile)6 AddTool (com.cburch.logisim.tools.AddTool)6 Tool (com.cburch.logisim.tools.Tool)6 CircuitState (com.cburch.logisim.circuit.CircuitState)5 AttributeSet (com.cburch.logisim.data.AttributeSet)5 Selection (com.cburch.logisim.gui.main.Selection)5 Action (com.cburch.logisim.proj.Action)4 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)3 ComponentDrawContext (com.cburch.logisim.comp.ComponentDrawContext)3 Graphics (java.awt.Graphics)3 CanvasObject (com.cburch.draw.model.CanvasObject)2