Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit$MyComponentListener


  }
 
  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(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


        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

  }
 
  @Override
  public void computeEnabled() {
    Project proj = canvas.getProject();
    Circuit circ = canvas.getCircuit();
    Selection sel = canvas.getSelection();
    boolean selEmpty = sel.isEmpty();
    boolean canChange = proj.getLogisimFile().contains(circ);
    boolean clipExists = !Clipboard.isEmpty();
    boolean selHasRemovable = false;
View Full Code Here

  @Override
  public void setValueRequested(Attribute<Object> attr, Object value)
      throws AttrTableSetException {
    Selection selection = frame.getCanvas().getSelection();
    Circuit circuit = frame.getCanvas().getCircuit();
    if (selection.isEmpty() && circuit != null) {
      AttrTableCircuitModel circuitModel = new AttrTableCircuitModel(project, circuit);
      circuitModel.setValueRequested(attr, value);
    } else {
      SetAttributeAction act = new SetAttributeAction(circuit,
View Full Code Here

    private CircuitState circuitState;

    public CircuitStateMenuItem(CircuitState circuitState) {
      this.circuitState = circuitState;

      Circuit circuit = circuitState.getCircuit();
      circuit.addCircuitListener(this);
      this.setText(circuit.getName());
      addActionListener(this);
    }
View Full Code Here

      this.setText(circuit.getName());
      addActionListener(this);
    }
   
    void unregister() {
      Circuit circuit = circuitState.getCircuit();
      circuit.removeCircuitListener(this);
    }
View Full Code Here

  public String getDisplayName() {
    return Strings.get("pokeTool");
  }
 
  private void removeCaret(boolean normal) {
    Circuit circ = pokedCircuit;
    Caret caret = pokeCaret;
    if (caret != null) {
      if (normal) caret.stopEditing(); else caret.cancelEditing();
      circ.removeCircuitListener(listener);
      pokedCircuit = null;
      pokedComponent = null;
      pokeCaret = null;
    }
  }
View Full Code Here

      dirty = true;
      removeCaret(true);
    }
    if (pokeCaret == null) {
      ComponentUserEvent event = new ComponentUserEvent(canvas, x, y);
      Circuit circ = canvas.getCircuit();
      for (Component c : circ.getAllContaining(loc, g)) {
        if (pokeCaret != null) break;

        if (c instanceof Wire) {
          Caret caret = new WireCaret(canvas, (Wire) c, x, y,
            canvas.getProject().getOptions().getAttributeSet());
          setPokedComponent(circ, c, caret);
          canvas.setHighlightedWires(circ.getWireSet((Wire) c));
        } else {
          Pokable p = (Pokable) c.getFeature(Pokable.class);
          if (p != null) {
            Caret caret = p.getPokeCaret(event);
            setPokedComponent(circ, c, caret);
View Full Code Here

          : Strings.get("dropComponentsAction");
    }

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

    }
  }
 
  private class Listener implements CircuitListener {
    public void circuitChanged(CircuitEvent event) {
      Circuit circ = pokedCircuit;
      if (event.getCircuit() == circ && circ != null
          && (event.getAction() == CircuitEvent.ACTION_REMOVE
              || event.getAction() == CircuitEvent.ACTION_CLEAR)
          && !circ.contains(pokedComponent)) {
        removeCaret(false);
      }
    }
View Full Code Here

TOP

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

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.