Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.CircuitMutation


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


        canvas.setErrorMessage(Strings.getter("negativeCoordError"));
        return;
      }

      try {
        CircuitMutation mutation = new CircuitMutation(circ);
        mutation.add(c);
        Action action = mutation.toAction(Strings.getter("addComponentAction", factory.getDisplayGetter()));
        canvas.getProject().doAction(action);
        lastAddition = action;
        added = c;
      } catch (CircuitException ex) {
        JOptionPane.showMessageDialog(canvas.getProject().getFrame(),
View Full Code Here

        if (toReplace == null) toReplace = new ArrayList<Component>();
        toReplace.add(comp);
      }
    }
    if (toReplace != null) {
      CircuitMutation xn = new CircuitMutation(circuit);
      for (Component comp : toReplace) {
        xn.remove(comp);
        ComponentFactory factory = compMap.get(comp.getFactory());
        if (factory != null) {
          AttributeSet newAttrs = createAttributes(factory, comp.getAttributeSet());
          xn.add(factory.createComponent(comp.getLocation(), newAttrs));
        }
      }
      xn.execute();
    }
  }
View Full Code Here

    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      if (src == del) {
        Circuit circ = proj.getCurrentCircuit();
        CircuitMutation xn = new CircuitMutation(circ);
        xn.remove(comp);
        proj.doAction(xn.toAction(Strings.getter("removeComponentAction", comp.getFactory().getDisplayGetter())));
      } else if (src == attrs) {
        proj.getFrame().viewComponentAttributes(circ, comp);
      }
    }
View Full Code Here

    return nameGetter.get();
  }
 
  @Override
  public void doIt(Project proj) {
    CircuitMutation xn = new CircuitMutation(circuit);
    int len = values.size();
    oldValues.clear();
    for (int i = 0; i < len; i++) {
      Component comp = comps.get(i);
      Attribute<Object> attr = attrs.get(i);
      Object value = values.get(i);
      if (circuit.contains(comp)) {
        oldValues.add(null);
        xn.set(comp, attr, value);
      } else {
        AttributeSet compAttrs = comp.getAttributeSet();
        oldValues.add(compAttrs.getValue(attr));
        compAttrs.setValue(attr, value);   
      }
    }
   
    if (!xn.isEmpty()) {
      CircuitTransactionResult result = xn.execute();
      xnReverse = result.getReverseTransaction();
    }
  }
View Full Code Here

    Canvas canvas = frame.getCanvas();
    if (old != null) old.deselect(canvas);
    Selection selection = canvas.getSelection();
    if (selection != null && !selection.isEmpty()) {
      Circuit circuit = canvas.getCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);
      if (value == null) {
        Action act = SelectionActions.dropAll(selection);
        if (act != null) {
          doAction(act);
        }
      } else if (!getOptions().getMouseMappings().containsSelectTool()) {
        Action act = SelectionActions.dropAll(selection);
        if (act != null) {
          doAction(act);
        }
      }
      if (!xn.isEmpty()) doAction(xn.toAction(null));
    }
    startupScreen = false;
    tool = value;
    if (tool != null) tool.select(frame.getCanvas());
    fireEvent(ProjectEvent.ACTION_SET_TOOL, old, tool);
View Full Code Here

  private boolean performShortening(Canvas canvas, Location drag0, Location drag1) {
    Wire shorten = willShorten(drag0, drag1);
    if (shorten == null) {
      return false;
    } else {
      CircuitMutation xn = new CircuitMutation(canvas.getCircuit());
      StringGetter actName;
      Wire result = getShortenResult(shorten, drag0, drag1);
      if (result == null) {
        xn.remove(shorten);
        actName = Strings.getter("removeComponentAction",
            shorten.getFactory().getDisplayGetter());
      } else {
        xn.replace(shorten, result);
        actName = Strings.getter("shortenWireAction");
      }
      canvas.getProject().doAction(xn.toAction(actName));
      return true;
    }
  }
View Full Code Here

    }

    @Override
    public void doIt(Project proj) {
      Circuit circuit = proj.getCurrentCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);

      sel.translateHelper(xn, dx, dy);
      if (replacements != null) {
        xn.replace(replacements);
      }

      CircuitTransactionResult result = xn.execute();
      xnReverse = result.getReverseTransaction();
    }
View Full Code Here

            "Internal error prevents replacing circuit.",
            "Internal Error", JOptionPane.ERROR_MESSAGE);
        return;
      }

      CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs,
          useNands);
      dest.doAction(xn.toAction(Strings.getter("replaceCircuitAction")));
    } else {
      // add the circuit
      Circuit circuit = new Circuit(name);
      CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs,
          useNands);
      xn.execute();
      dest.doAction(LogisimFileActions.addCircuit(circuit));
      dest.setCurrentCircuit(circuit);
    }
  }
View Full Code Here

      throws AttrTableSetException {
    if (!proj.getLogisimFile().contains(circ)) {
      String msg = Strings.get("cannotModifyCircuitError");
      throw new AttrTableSetException(msg);
    } else {
      CircuitMutation xn = new CircuitMutation(circ);
      xn.setForCircuit(attr, value);
      proj.doAction(xn.toAction(Strings.getter("changeCircuitAttrAction")));
    }
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.circuit.CircuitMutation

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.