Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit


      return Strings.get("deleteSelectionAction");
    }

    @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


      return Strings.get("duplicateSelectionAction");
    }

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

  public void circuitChanged(CircuitEvent event) {
    int action = event.getAction();
    if (action == CircuitEvent.ACTION_CLEAR
        || action == CircuitEvent.ACTION_REMOVE) {
      Circuit circ = event.getCircuit();
      Component circComp = null;
      if (circ == model.getCircuitState().getCircuit()) {
        circComp = path != null && path.length > 0 ? path[0] : comp;
      } else if (path != null) {
        for (int i = 0; i < path.length; i++) {
View Full Code Here

      if (w > 2 && h > 2) {
        gBase.setColor(BACKGROUND_RECT_SELECT);
        gBase.fillRect(left + 1, top + 1, w - 1, h - 1);
      }
     
      Circuit circ = canvas.getCircuit();
      Bounds bds = Bounds.create(left, top, right - left, bot - top);
      for (Component c : circ.getAllWithin(bds)) {
        Location cloc = c.getLocation();
        Graphics gDup = gBase.create();
        context.setGraphics(gDup);
        c.getFactory().drawGhost(context, COLOR_RECT_SELECT,
            cloc.getX(), cloc.getY(), c.getAttributeSet());
View Full Code Here

  @Override
  public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
    Project proj = canvas.getProject();
    Selection sel = proj.getSelection();
    Circuit circuit = canvas.getCircuit();
    start = Location.create(e.getX(), e.getY());
    curDx = 0;
    curDy = 0;
    moveGesture = null;

    // if the user clicks into the selection,
    // selection is being modified
    Collection<Component> in_sel = sel.getComponentsContaining(start, g);
    if (!in_sel.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        setState(proj, MOVING);
        proj.repaintCanvas();
        return;
      } else {
        Action act = SelectionActions.drop(sel, in_sel);
        if (act != null) {
          proj.doAction(act);
        }
      }
    }

    // if the user clicks into a component outside selection, user
    // wants to add/reset selection
    Collection<Component> clicked = circuit.getAllContaining(start, g);
    if (!clicked.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        if (sel.getComponentsContaining(start).isEmpty()) {
          Action act = SelectionActions.dropAll(sel);
          if (act != null) {
View Full Code Here

      moveGesture = null;
      proj.repaintCanvas();
    } else if (state == RECT_SELECT) {
      Bounds bds = Bounds.create(start).add(start.getX() + curDx,
        start.getY() + curDy);
      Circuit circuit = canvas.getCircuit();
      Selection sel = proj.getSelection();
      Collection<Component> in_sel = sel.getComponentsWithin(bds, g);
      for (Component comp : circuit.getAllWithin(bds, g)) {
        if (!in_sel.contains(comp)) sel.add(comp);
      }
      Action act = SelectionActions.drop(sel, in_sel);
      if (act != null) {
        proj.doAction(act);
View Full Code Here

    }

    private void performAction(Project dest, String name, boolean replace,
            final boolean twoInputs, final boolean useNands) {
        if (replace) {
            final Circuit circuit = dest.getLogisimFile().getCircuit(name);
            if (circuit == null) {
                JOptionPane.showMessageDialog(parent,
                        "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

                project.setEnabled(false);
            } else if (initialSelection != null) {
                project.setSelectedItem(initialSelection);
            }

            Circuit defaultCircuit = model.getCurrentCircuit();
            if (defaultCircuit != null) {
                name.setText(defaultCircuit.getName());
                name.selectAll();
            }

            VariableList outputs = model.getOutputs();
            boolean enableNands = true;
View Full Code Here

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

TOP

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

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.