use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class Startup method doPrintFile.
private void doPrintFile(File file) {
if (initialized) {
Project toPrint = ProjectActions.doOpen(null, null, file);
Print.doPrint(toPrint);
toPrint.getFrame().dispose();
} else {
filesToPrint.add(file);
}
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class TtyInterface method run.
public static void run(Startup args) {
File fileToOpen = args.getFilesToOpen().get(0);
Loader loader = new Loader(null);
LogisimFile file;
try {
file = loader.openLogisimFile(fileToOpen, args.getSubstitutions());
} catch (LoadFailedException e) {
logger.error("{}", Strings.get("ttyLoadError", fileToOpen.getName()));
System.exit(-1);
return;
}
int format = args.getTtyFormat();
if ((format & FORMAT_STATISTICS) != 0) {
format &= ~FORMAT_STATISTICS;
displayStatistics(file);
}
if (format == 0) {
// no simulation remaining to perform, so just exit
System.exit(0);
}
Project proj = new Project(file);
Circuit circuit = file.getMainCircuit();
Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
ArrayList<Instance> outputPins = new ArrayList<Instance>();
Instance haltPin = null;
for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
Instance pin = entry.getKey();
String pinName = entry.getValue();
if (!Pin.FACTORY.isInputPin(pin)) {
outputPins.add(pin);
if (pinName.equals("halt")) {
haltPin = pin;
}
}
}
CircuitState circState = new CircuitState(proj, circuit);
// we have to do our initial propagation before the simulation starts -
// it's necessary to populate the circuit with substates.
circState.getPropagator().propagate();
if (args.getLoadFile() != null) {
try {
boolean loaded = loadRam(circState, args.getLoadFile());
if (!loaded) {
logger.error("{}", Strings.get("loadNoRamError"));
System.exit(-1);
}
} catch (IOException e) {
logger.error("{}: {}", Strings.get("loadIoError"), e.toString());
System.exit(-1);
}
}
int ttyFormat = args.getTtyFormat();
int simCode = runSimulation(circState, outputPins, haltPin, ttyFormat);
System.exit(simCode);
}
use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.
the class WindowManagers method computeListeners.
private static void computeListeners() {
List<Project> nowOpen = Projects.getOpenProjects();
HashSet<Project> closed = new HashSet<Project>(projectMap.keySet());
closed.removeAll(nowOpen);
for (Project proj : closed) {
ProjectManager manager = projectMap.get(proj);
manager.frameClosed(manager.getJFrame(false));
projectMap.remove(proj);
}
HashSet<Project> opened = new LinkedHashSet<Project>(nowOpen);
opened.removeAll(projectMap.keySet());
for (Project proj : opened) {
ProjectManager manager = new ProjectManager(proj);
projectMap.put(proj, manager);
}
}
use of com.cburch.logisim.proj.Project 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.proj.Project in project logisim-evolution by reds-heig.
the class LayoutEditHandler method computeEnabled.
@Override
public void computeEnabled() {
Project proj = frame.getProject();
Selection sel = proj == null ? null : proj.getSelection();
boolean selEmpty = (sel == null ? true : sel.isEmpty());
boolean canChange = proj != null && proj.getLogisimFile().contains(proj.getCurrentCircuit());
boolean selectAvailable = false;
for (Library lib : proj.getLogisimFile().getLibraries()) {
if (lib instanceof Base)
selectAvailable = true;
}
setEnabled(LogisimMenuBar.CUT, !selEmpty && selectAvailable && canChange);
setEnabled(LogisimMenuBar.COPY, !selEmpty && selectAvailable);
setEnabled(LogisimMenuBar.PASTE, selectAvailable && canChange && !Clipboard.isEmpty());
setEnabled(LogisimMenuBar.DELETE, !selEmpty && selectAvailable && canChange);
setEnabled(LogisimMenuBar.DUPLICATE, !selEmpty && selectAvailable && canChange);
setEnabled(LogisimMenuBar.SELECT_ALL, selectAvailable);
setEnabled(LogisimMenuBar.RAISE, false);
setEnabled(LogisimMenuBar.LOWER, false);
setEnabled(LogisimMenuBar.RAISE_TOP, false);
setEnabled(LogisimMenuBar.LOWER_BOTTOM, false);
setEnabled(LogisimMenuBar.ADD_CONTROL, false);
setEnabled(LogisimMenuBar.REMOVE_CONTROL, false);
}
Aggregations