Search in sources :

Example 1 with AddTool

use of com.cburch.logisim.tools.AddTool in project logisim-evolution by reds-heig.

the class LogisimFile method moveCircuit.

public void moveCircuit(AddTool tool, int index) {
    int oldIndex = tools.indexOf(tool);
    if (oldIndex < 0) {
        tools.add(index, tool);
        fireEvent(LibraryEvent.ADD_TOOL, tool);
    } else {
        AddTool value = tools.remove(oldIndex);
        tools.add(index, value);
        fireEvent(LibraryEvent.MOVE_TOOL, tool);
    }
}
Also used : AddTool(com.cburch.logisim.tools.AddTool)

Example 2 with AddTool

use of com.cburch.logisim.tools.AddTool 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 3 with AddTool

use of com.cburch.logisim.tools.AddTool in project logisim-evolution by reds-heig.

the class LogisimFile method addCircuit.

public void addCircuit(Circuit circuit, int index) {
    circuit.addCircuitListener(this);
    AddTool tool = new AddTool(circuit.getSubcircuitFactory());
    tools.add(index, tool);
    if (tools.size() == 1)
        setMainCircuit(circuit);
    fireEvent(LibraryEvent.ADD_TOOL, tool);
}
Also used : AddTool(com.cburch.logisim.tools.AddTool)

Example 4 with AddTool

use of com.cburch.logisim.tools.AddTool 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 5 with AddTool

use of com.cburch.logisim.tools.AddTool 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)

Aggregations

AddTool (com.cburch.logisim.tools.AddTool)16 Tool (com.cburch.logisim.tools.Tool)10 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)9 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)7 Library (com.cburch.logisim.tools.Library)6 Circuit (com.cburch.logisim.circuit.Circuit)5 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 CircuitException (com.cburch.logisim.circuit.CircuitException)1 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)1 Component (com.cburch.logisim.comp.Component)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 Location (com.cburch.logisim.data.Location)1 AttrTableModel (com.cburch.logisim.gui.generic.AttrTableModel)1 Action (com.cburch.logisim.proj.Action)1 SelectTool (com.cburch.logisim.tools.SelectTool)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1