Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Simulator


  public void clear() {
    queueSize = 0;
  }
 
  public void propagationCompleted(SimulatorEvent e) {
    Simulator sim = e.getSource();
    if (!sim.isTicking()) {
      queueSize = 0;
    }
  }
View Full Code Here


  public void simulatorStateChanged(SimulatorEvent e) {
    propagationCompleted(e);
  }

  public void tickCompleted(SimulatorEvent e) {
    Simulator sim = e.getSource();
    if (!sim.isTicking()) {
      queueSize = 0;
    } else {
      double freq = sim.getTickFrequency();
      if (freq != tickFrequency) {
        queueSize = 0;
        tickFrequency = freq;
      }
     
View Full Code Here

  //
  // ChangeListener methods
  //
  public void stateChanged(ChangeEvent e) {
    Simulator sim = project.getSimulator();
    boolean running = sim != null && sim.isRunning();
    boolean ticking = sim != null && sim.isTicking();
    simEnable.setIcon(running ? "simstop.png" : "simplay.png");
    simEnable.setToolTip(running ? Strings.getter("simulateDisableStepsTip")
        : Strings.getter("simulateEnableStepsTip"));
    tickEnable.setIcon(ticking ? "simtstop.png" : "simtplay.png");
    tickEnable.setToolTip(ticking ? Strings.getter("simulateDisableTicksTip")
View Full Code Here

  // ProjectListener methods
  //
  public void projectChanged(ProjectEvent event) {
    int action = event.getAction();
    if (action == ProjectEvent.ACTION_SET_STATE) {
      Simulator sim = project.getSimulator();
      CircuitState root = sim.getCircuitState();
      if (model.getRootState() != root) {
        model = new SimulationTreeModel(root);
        tree.setModel(model);
      }
      model.setCurrentView(project.getCircuitState());
View Full Code Here

    log.setText(Strings.get("simulateLogItem"));
  }
 
  public void setCurrentState(Simulator sim, CircuitState value) {
    if (currentState == value) return;
    Simulator oldSim = currentSim;
    CircuitState oldState = currentState;
    currentSim = sim;
    currentState = value;
    if (bottomState == null) {
      bottomState = currentState;
    } else if (currentState == null) {
      bottomState = null;
    } else {
      CircuitState cur = bottomState;
      while (cur != null && cur != currentState) {
        cur = cur.getParentState();
      }
      if (cur == null) bottomState = currentState;
    }
   
    boolean oldPresent = oldState != null;
    boolean present = currentState != null;
    if (oldPresent != present) {
      computeEnabled();
    }

    if (currentSim != oldSim) {
      double freq = currentSim == null ? 1.0 : currentSim.getTickFrequency();
      for (int i = 0; i < tickFreqs.length; i++) {
        tickFreqs[i].setSelected(Math.abs(tickFreqs[i].freq - freq) < 0.001);
      }

      if (oldSim != null) oldSim.removeSimulatorListener(myListener);
      if (currentSim != null) currentSim.addSimulatorListener(myListener);
      myListener.simulatorStateChanged(new SimulatorEvent(sim));
    }

    clearItems(downStateItems);
View Full Code Here

  }

  @Override
  void computeEnabled() {
    boolean present = currentState != null;
    Simulator sim = this.currentSim;
    boolean simRunning = sim != null && sim.isRunning();
    setEnabled(present);
    run.setEnabled(present);
    reset.setEnabled(present);
    step.setEnabled(present && !simRunning);
    upStateMenu.setEnabled(present);
View Full Code Here

  private class MyListener implements ActionListener, SimulatorListener,
      ChangeListener {
    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      Project proj = menubar.getProject();
      Simulator sim = proj == null ? null : proj.getSimulator();
      if (src == run || src == LogisimMenuBar.SIMULATE_ENABLE) {
        if (sim != null) {
          sim.setIsRunning(!sim.isRunning());
          proj.repaintCanvas();
        }
      } else if (src == reset) {
        if (sim != null) sim.requestReset();
      } else if (src == step || src == LogisimMenuBar.SIMULATE_STEP) {
        if (sim != null) sim.step();
      } else if (src == tickOnce || src == LogisimMenuBar.TICK_STEP) {
        if (sim != null) sim.tick();
      } else if (src == ticksEnabled || src == LogisimMenuBar.TICK_ENABLE) {
        if (sim != null) sim.setIsTicking(!sim.isTicking());
      } else if (src == log) {
        LogFrame frame = menubar.getProject().getLogFrame(true);
        frame.setVisible(true);
      }
    }
View Full Code Here

    }

    public void propagationCompleted(SimulatorEvent e) { }
    public void tickCompleted(SimulatorEvent e) { }
    public void simulatorStateChanged(SimulatorEvent e) {
      Simulator sim = e.getSource();
      if (sim != currentSim) return;
      computeEnabled();
      run.setSelected(sim.isRunning());
      ticksEnabled.setSelected(sim.isTicking());
      double freq = sim.getTickFrequency();
      for (int i = 0; i < tickFreqs.length; i++) {
        TickFrequencyChoice item = tickFreqs[i];
        item.setSelected(freq == item.freq);
      }
    }
View Full Code Here

        queueSize = 0;
    }

    @Override
    public void propagationCompleted(SimulatorEvent e) {
        Simulator sim = e.getSource();
        if (!sim.isTicking()) {
            queueSize = 0;
        }
    }
View Full Code Here

        propagationCompleted(e);
    }

    @Override
    public void tickCompleted(SimulatorEvent e) {
        Simulator sim = e.getSource();
        if (!sim.isTicking()) {
            queueSize = 0;
        } else {
            double freq = sim.getTickFrequency();
            if (freq != tickFrequency) {
                queueSize = 0;
                tickFrequency = freq;
            }
View Full Code Here

TOP

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

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.