Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.Circuit


    Object clicked = event.getTarget();
    if (clicked instanceof AddTool) {
      AddTool tool = (AddTool) clicked;
      ComponentFactory source = tool.getFactory();
      if (source instanceof SubcircuitFactory) {
        Circuit circ = ((SubcircuitFactory) source).getSubcircuit();
        return Popups.forCircuit(proj, tool, circ);
      } else {
        return null;
      }
    } else if (clicked instanceof Tool) {
View Full Code Here


      proj.addProjectListener(this);
      proj.addLibraryListener(this);
      frame.addPropertyChangeListener(Frame.EDITOR_VIEW, this);
      frame.addPropertyChangeListener(Frame.EXPLORER_VIEW, this);
      Circuit circ = proj.getCurrentCircuit();
      if (circ != null) {
        circ.getAppearance().addCanvasModelListener(this);
      }
     
      menubar.addActionListener(LogisimMenuBar.ADD_CIRCUIT, this);
      menubar.addActionListener(LogisimMenuBar.MOVE_CIRCUIT_UP, this);
      menubar.addActionListener(LogisimMenuBar.MOVE_CIRCUIT_DOWN, this);
View Full Code Here

    }

    public void projectChanged(ProjectEvent event) {
      int action = event.getAction();
      if (action == ProjectEvent.ACTION_SET_CURRENT) {
        Circuit old = (Circuit) event.getOldData();
        if (old != null) {
          old.getAppearance().removeCanvasModelListener(this);
        }
        Circuit circ = (Circuit) event.getData();
        if (circ != null) {
          circ.getAppearance().addCanvasModelListener(this);
        }
        computeEnabled();
      } else if (action == ProjectEvent.ACTION_SET_FILE) {
        computeEnabled();
      }
View Full Code Here

    }
   
    public void actionPerformed(ActionEvent event) {
      Object src = event.getSource();
      Project proj = frame.getProject();
      Circuit cur = proj == null ? null : proj.getCurrentCircuit();
      if (src == LogisimMenuBar.ADD_CIRCUIT) {
        ProjectCircuitActions.doAddCircuit(proj);
      } else if (src == LogisimMenuBar.MOVE_CIRCUIT_UP) {
        ProjectCircuitActions.doMoveCircuit(proj, cur, -1);
      } else if (src == LogisimMenuBar.MOVE_CIRCUIT_DOWN) {
View Full Code Here

    }
   
    private void computeEnabled() {
      Project proj = frame.getProject();
      LogisimFile file = proj.getLogisimFile();
      Circuit cur = proj.getCurrentCircuit();
      int curIndex = file.getCircuits().indexOf(cur);
      boolean isProjectCircuit = curIndex >= 0;
      String editorView = frame.getEditorView();
      String explorerView = frame.getExplorerView();
      boolean canSetMain = false;
      boolean canMoveUp = false;
      boolean canMoveDown = false;
      boolean canRemove = false;
      boolean canRevert = false;
      boolean viewAppearance = editorView.equals(Frame.EDIT_APPEARANCE);
      boolean viewLayout = editorView.equals(Frame.EDIT_LAYOUT);
      boolean viewToolbox = explorerView.equals(Frame.VIEW_TOOLBOX);
      boolean viewSimulation = explorerView.equals(Frame.VIEW_SIMULATION);
      if (isProjectCircuit) {
        List<?> tools = proj.getLogisimFile().getTools();

        canSetMain = proj.getLogisimFile().getMainCircuit() != cur;
        canMoveUp = curIndex > 0;
        canMoveDown = curIndex < tools.size() - 1;
        canRemove = tools.size() > 1;
        canRevert = viewAppearance
          && !cur.getAppearance().isDefaultAppearance();
      }
     
      menubar.setEnabled(LogisimMenuBar.ADD_CIRCUIT, true);
      menubar.setEnabled(LogisimMenuBar.MOVE_CIRCUIT_UP, canMoveUp);
      menubar.setEnabled(LogisimMenuBar.MOVE_CIRCUIT_DOWN, canMoveDown);
View Full Code Here

   
    private void computeRevertEnabled() {
      // do this separately since it can happen rather often
      Project proj = frame.getProject();
      LogisimFile file = proj.getLogisimFile();
      Circuit cur = proj.getCurrentCircuit();
      boolean isProjectCircuit = file.contains(cur);
      boolean viewAppearance = frame.getEditorView().equals(Frame.EDIT_APPEARANCE);
      boolean canRevert = isProjectCircuit && viewAppearance
        && !cur.getAppearance().isDefaultAppearance();
      boolean oldValue = menubar.isEnabled(LogisimMenuBar.REVERT_APPEARANCE);
      if (canRevert != oldValue) {
        menubar.setEnabled(LogisimMenuBar.REVERT_APPEARANCE, canRevert);
        fireEnableChanged();
      }
View Full Code Here

 
  private static Count getTotal(List<Count> counts, Set<Circuit> exclude) {
    Count ret = new Count(null);
    for (Count count : counts) {
      ComponentFactory factory = count.getFactory();
      Circuit factoryCirc = null;
      if (factory instanceof SubcircuitFactory) {
        factoryCirc = ((SubcircuitFactory) factory).getSubcircuit();
      }
      if (exclude == null || !exclude.contains(factoryCirc)) {
        ret.simpleCount += count.simpleCount;
View Full Code Here

      case LibraryEvent.REMOVE_TOOL:
        if (e.getData() instanceof AddTool) {
          ComponentFactory factory = ((AddTool) e.getData()).getFactory();
          if (factory instanceof SubcircuitFactory) {
            SubcircuitFactory circFact = (SubcircuitFactory) factory;
            Circuit circ = circFact.getSubcircuit();
            depends.removeNode(circ);
            circ.removeCircuitListener(this);
          }
        }
        break;
      }
    }
View Full Code Here

    if (file != null) file.removeLibraryListener(value);
  }
 
  public void addCircuitListener(CircuitListener value) {
    circuitListeners.add(value);
    Circuit current = getCurrentCircuit();
    if (current != null) current.addCircuitListener(value);
  }
View Full Code Here

    if (current != null) current.addCircuitListener(value);
  }
 
  public void removeCircuitListener(CircuitListener value) {
    circuitListeners.remove(value);
    Circuit current = getCurrentCircuit();
    if (current != null) current.removeCircuitListener(value);
  }
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.