Package com.cburch.logisim.proj

Examples of com.cburch.logisim.proj.Project


    }
  }

  private void doPrintFile(File file) {
    if (initialized) {
      Project toPrint = ProjectActions.doOpen(null, null, file);
      Print.doPrint(toPrint);
      toPrint.getFrame().dispose();
    } else {
      filesToPrint.add(file);
    }
  }
View Full Code Here


        computeTitle();
      }
    }

    private void enableSave() {
      Project proj = getProject();
      boolean ok = proj.isFileDirty();
      getRootPane().putClientProperty("windowModified", Boolean.valueOf(ok));
    }
View Full Code Here

    }
  }

  @Override
  public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
    Project proj = canvas.getProject();
    Circuit circ = canvas.getCircuit();

    if (!proj.getLogisimFile().contains(circ)) {
      if (caret != null) caret.cancelEditing();
      canvas.setErrorMessage(Strings.getter("cannotModifyError"));
      return;
    }

    // Maybe user is clicking within the current caret.
    if (caret != null) {
      if (caret.getBounds(g).contains(e.getX(), e.getY())) { // Yes
        caret.mousePressed(e);
        proj.repaintCanvas();
        return;
      } else { // No. End the current caret.
        caret.stopEditing();
      }
    }
    // caret will be null at this point

    // Otherwise search for a new caret.
    int x = e.getX();
    int y = e.getY();
    Location loc = Location.create(x, y);
    ComponentUserEvent event = new ComponentUserEvent(canvas, x, y);

    // First search in selection.
    for (Component comp : proj.getSelection().getComponentsContaining(loc, g)) {
      TextEditable editable = (TextEditable) comp.getFeature(TextEditable.class);
      if (editable != null) {
        caret = editable.getTextCaret(event);
        if (caret != null) {
          proj.getFrame().viewComponentAttributes(circ, comp);
          caretComponent = comp;
          caretCreatingText = false;
          break;
        }
      }
    }

    // Then search in circuit
    if (caret == null) {
      for (Component comp : circ.getAllContaining(loc, g)) {
        TextEditable editable = (TextEditable) comp.getFeature(TextEditable.class);
        if (editable != null) {
          caret = editable.getTextCaret(event);
          if (caret != null) {
            proj.getFrame().viewComponentAttributes(circ, comp);
            caretComponent = comp;
            caretCreatingText = false;
            break;
          }
        }
      }
    }

    // if nothing found, create a new label
    if (caret == null) {
      if (loc.getX() < 0 || loc.getY() < 0) return;
      AttributeSet copy = (AttributeSet) attrs.clone();
      caretComponent = Text.FACTORY.createComponent(loc, copy);
      caretCreatingText = true;
      TextEditable editable = (TextEditable) caretComponent.getFeature(TextEditable.class);
      if (editable != null) {
        caret = editable.getTextCaret(event);
        proj.getFrame().viewComponentAttributes(circ, caretComponent);
      }
    }

    if (caret != null) {
      caretCanvas = canvas;
      caretCircuit = canvas.getCircuit();
      caret.addCaretListener(listener);
      caretCircuit.addCircuitListener(listener);
    }
    proj.repaintCanvas();
  }
View Full Code Here

      caretCircuit.removeCircuitListener(this);
     
      String val = caret.getText();
      boolean isEmpty = (val == null || val.equals(""));
      Action a;
      Project proj = caretCanvas.getProject();
      if (caretCreatingText) {
        if (!isEmpty) {
          CircuitMutation xn = new CircuitMutation(caretCircuit);
          xn.add(caretComponent);
          a = xn.toAction(Strings.getter("addComponentAction",
              Text.FACTORY.getDisplayGetter()));
        } else {
          a = null; // don't add the blank text field
        }
      } else {
        if (isEmpty && caretComponent.getFactory() instanceof Text) {
          CircuitMutation xn = new CircuitMutation(caretCircuit);
          xn.add(caretComponent);
          a = xn.toAction(Strings.getter("removeComponentAction",
              Text.FACTORY.getDisplayGetter()));
        } else {
          Object obj = caretComponent.getFeature(TextEditable.class);
          if (obj == null) { // should never happen
            a = null;
          } else {
            TextEditable editable = (TextEditable) obj;
            a = editable.getCommitAction(caretCircuit, e.getOldText(), e.getText());
          }
        }
      }

      caretCircuit = null;
      caretComponent = null;
      caretCreatingText = false;
      caret = null;
     
      if (a != null) proj.doAction(a);
    }
View Full Code Here

    }
    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()) {
View Full Code Here

      setState(canvas, SHOW_GHOST);
    } else if (state == SHOW_ADD_NO) {
      setState(canvas, SHOW_NONE);
    }
   
    Project proj = canvas.getProject();
    Tool next = determineNext(proj);
    if (next != null) {
      proj.setTool(next);
      Action act = SelectionActions.dropAll(canvas.getSelection());
      if (act != null) {
        proj.doAction(act);
      }
      if (added != null) canvas.getSelection().add(added);
    }
  }
View Full Code Here

  private Frame frame;
 
  LayoutEditHandler(Frame frame) {
    this.frame = frame;

    Project proj = frame.getProject();
    Clipboard.addPropertyChangeListener(Clipboard.contentsProperty, this);
    proj.addProjectListener(this);
    proj.addLibraryListener(this);
  }
View Full Code Here

    proj.addLibraryListener(this);
  }

  @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);
View Full Code Here

    setEnabled(LogisimMenuBar.REMOVE_CONTROL, false);
  }
 
  @Override
  public void cut() {
    Project proj = frame.getProject();
    Selection sel = frame.getCanvas().getSelection();
    proj.doAction(SelectionActions.cut(sel));
  }
View Full Code Here

    proj.doAction(SelectionActions.cut(sel));
  }
 
  @Override
  public void copy() {
    Project proj = frame.getProject();
    Selection sel = frame.getCanvas().getSelection();
    proj.doAction(SelectionActions.copy(sel));
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.proj.Project

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.