Package com.cburch.logisim.file

Examples of com.cburch.logisim.file.LogisimFile


import com.cburch.logisim.file.LogisimFile;
import com.cburch.logisim.proj.Project;

class CircuitJList extends JList {
  public CircuitJList(Project proj, boolean includeEmpty) {
    LogisimFile file = proj.getLogisimFile();
    Circuit current = proj.getCurrentCircuit();
    Vector<Circuit> options = new Vector<Circuit>();
    boolean currentFound = false;
    for (Circuit circ : file.getCircuits()) {
      if (!includeEmpty || circ.getBounds() != Bounds.EMPTY_BOUNDS) {
        if (circ == current) currentFound = true;
        options.add(circ);
      }
    }
View Full Code Here


        viewport.setErrorMessage(null, null);
        if (painter.getHaloedComponent() != null) {
          proj.getFrame().viewComponentAttributes(null, null);
        }
      } else if (act == ProjectEvent.ACTION_SET_FILE) {
        LogisimFile old = (LogisimFile) event.getOldData();
        if (old != null) old.getOptions().getAttributeSet().removeAttributeListener(this);
        LogisimFile file = (LogisimFile) event.getData();
        if (file != null) {
          AttributeSet attrs = file.getOptions().getAttributeSet();
          attrs.addAttributeListener(this);
          loadOptions(attrs);
          mappings = file.getOptions().getMouseMappings();
        }
      } else if (act == ProjectEvent.ACTION_SET_TOOL) {
        viewport.setErrorMessage(null, null);
       
        Tool t = event.getTool();
View Full Code Here

    }

    private boolean canMove(Object draggedNode, Object targetNode) {
      if (listener == null) return false;
      if (!(draggedNode instanceof AddTool) || !(targetNode instanceof AddTool)) return false;
      LogisimFile file = proj.getLogisimFile();
      AddTool dragged = (AddTool) draggedNode;
      AddTool target = (AddTool) targetNode;
      int draggedIndex = file.getTools().indexOf(dragged);
      int targetIndex = file.getTools().indexOf(target);
      if (targetIndex < 0 || draggedIndex < 0) return false;
      return true;
    }
View Full Code Here

  }
 
  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) {
      System.err.println(Strings.get("ttyLoadError", fileToOpen.getName())); //OK
      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();
View Full Code Here

    public void projectChanged(ProjectEvent e) {
      int act = e.getAction();
      if (act == ProjectEvent.ACTION_SET_TOOL) {
        fireToolbarAppearanceChanged();
      } else if (act == ProjectEvent.ACTION_SET_FILE) {
        LogisimFile old = (LogisimFile) e.getOldData();
        if (old != null) {
          ToolbarData data = old.getOptions().getToolbarData();
          data.removeToolbarListener(this);
          data.removeToolAttributeListener(this);
        }
        LogisimFile file = (LogisimFile) e.getData();
        if (file != null) {
          ToolbarData data = file.getOptions().getToolbarData();
          data.addToolbarListener(this);
          data.addToolAttributeListener(this);
        }
        buildContents();
      }
View Full Code Here

  public static Project doNew(SplashScreen monitor, boolean isStartupScreen) {
    if (monitor != null) monitor.setProgress(SplashScreen.FILE_CREATE);
    Loader loader = new Loader(monitor);
    InputStream templReader = AppPreferences.getTemplate().createStream();
    LogisimFile file = null;
    try {
      file = loader.openLogisimFile(templReader);
    } catch (IOException ex) {
      displayException(monitor, ex);
    } catch (LoadFailedException ex) {
View Full Code Here

    JOptionPane.showMessageDialog(parent, msg, ttl, JOptionPane.ERROR_MESSAGE);
  }
 
  private static LogisimFile createEmptyFile(Loader loader) {
    InputStream templReader = AppPreferences.getEmptyTemplate().createStream();
    LogisimFile file;
    try {
      file = loader.openLogisimFile(templReader);
    } catch (Throwable t) {
      file = LogisimFile.createNew(loader);
      file.addCircuit(new Circuit("main"));
    } finally {
      try { templReader.close(); } catch (IOException e) { }
    }
    return file;
  }
View Full Code Here

  }

  public static LogisimFile createNewFile(Project baseProject) {
    Loader loader = new Loader(baseProject == null ? null : baseProject.getFrame());
    InputStream templReader = AppPreferences.getTemplate().createStream();
    LogisimFile file;
    try {
      file = loader.openLogisimFile(templReader);
    } catch (IOException ex) {
      displayException(baseProject.getFrame(), ex);
      file = createEmptyFile(loader);
View Full Code Here

    newProject.setFrame(newFrame);
    return newFrame;
  }
 
  public static Project doNew(Project baseProject) {
    LogisimFile file = createNewFile(baseProject);
    Project newProj = new Project(file);
    Frame frame = createFrame(baseProject, newProj);
    frame.setVisible(true);
    frame.getCanvas().requestFocus();
    newProj.getLogisimFile().getLoader().setParent(frame);
View Full Code Here

 
  public static Project doOpen(SplashScreen monitor, File source,
      Map<File,File> substitutions) throws LoadFailedException {
    if (monitor != null) monitor.setProgress(SplashScreen.FILE_LOAD);
    Loader loader = new Loader(monitor);
    LogisimFile file = loader.openLogisimFile(source, substitutions);
    AppPreferences.updateRecentFile(source);
   
    return completeProject(monitor, loader, file, false);
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.file.LogisimFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.