Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.CircuitMutation


    }

    @Override
    public void doIt(Project proj) {
      Circuit circuit = proj.getCurrentCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);
      for (Component comp : drops) {
        sel.remove(xn, comp);
      }
      CircuitTransactionResult result = xn.execute();
      xnReverse = result.getReverseTransaction();
    }
View Full Code Here


    }

    @Override
    public void doIt(Project proj) {
      Circuit circuit = proj.getCurrentCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);
      sel.deleteAllHelper(xn);
      CircuitTransactionResult result = xn.execute();
      xnReverse = result.getReverseTransaction();
    }
View Full Code Here

    }

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

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

    @Override
    public void doIt(Project proj) {
      Clipboard clip = Clipboard.get();
      Circuit circuit = proj.getCurrentCircuit();
      CircuitMutation xn = new CircuitMutation(circuit);
      Collection<Component> comps = clip.getComponents();
      Collection<Component> toAdd = computeAdditions(comps);
      if (toAdd.size() > 0) {
        sel.pasteHelper(xn, toAdd);
        CircuitTransactionResult result = xn.execute();
        xnReverse = result.getReverseTransaction();
        after = SelectionSave.create(sel);
      } else {
        xnReverse = null;
      }
View Full Code Here

        w1 = checkForRepairs(canvas, w1, cur);
        if (w0.getLength() > 0) ws.add(w0);
        if (w1.getLength() > 0) ws.add(w1);
      }
      if (ws.size() > 0) {
        CircuitMutation mutation = new CircuitMutation(canvas.getCircuit());
        mutation.addAll(ws);
        StringGetter desc;
        if (ws.size() == 1) desc = Strings.getter("addWireAction");
        else desc = Strings.getter("addWiresAction");
        Action act = mutation.toAction(desc);
        canvas.getProject().doAction(act);
        lastAction = act;
      }
    }
  }
View Full Code Here

public class CircuitBuilder {
  private CircuitBuilder() { }
 
  public static CircuitMutation build(Circuit destCirc, AnalyzerModel model,
      boolean twoInputs, boolean useNands) {
    CircuitMutation result = new CircuitMutation(destCirc);
    result.clear();
   
    Layout[] layouts = new Layout[model.getOutputs().size()];
    int maxWidth = 0;
    for (int i = 0; i < layouts.length; i++) {
      String output = model.getOutputs().get(i);
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(getFromLocale("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

                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

                    ws.add(w1);
                }

            }
            if (ws.size() > 0) {
                CircuitMutation mutation = new CircuitMutation(canvas.getCircuit());
                mutation.addAll(ws);
                String desc;
                if (ws.size() == 1) {
                    desc = getFromLocale("addWireAction");
                }

                else {
                    desc = getFromLocale("addWiresAction");
                }

                Action act = mutation.toAction(desc);
                canvas.getProject().doAction(act);
                lastAction = act;
            }
        }
    }
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());
            String actName;
            Wire result = getShortenResult(shorten, drag0, drag1);
            if (result == null) {
                xn.remove(shorten);
                actName = getFromLocale("removeComponentAction", shorten.getFactory().getDisplayGetter());
            } else {
                xn.replace(shorten, result);
                actName = getFromLocale("shortenWireAction");
            }
            canvas.getProject().doAction(xn.toAction(actName));
            return true;
        }
    }
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.