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