Package com.cburch.logisim.circuit

Examples of com.cburch.logisim.circuit.SubcircuitFactory


  }

  public Circuit getCircuit(String name) {
    if (name == null) return null;
    for (AddTool tool : tools) {
      SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
      if (name.equals(factory.getName())) return factory.getSubcircuit();
    }
    return null;
  }
View Full Code Here


    return null;
  }
 
  public boolean contains(Circuit circ) {
    for (AddTool tool : tools) {
      SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
      if (factory.getSubcircuit() == circ) return true;
    }
    return false;
  }
View Full Code Here

  }
 
  public List<Circuit> getCircuits() {
    List<Circuit> ret = new ArrayList<Circuit>(tools.size());
    for (AddTool tool : tools) {
      SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
      ret.add(factory.getSubcircuit());
    }
    return ret;
  }
View Full Code Here

    return ret;
  }
 
  public AddTool getAddTool(Circuit circ) {
    for (AddTool tool : tools) {
      SubcircuitFactory factory = (SubcircuitFactory) tool.getFactory();
      if (factory.getSubcircuit() == circ) {
        return tool;
      }
    }
    return null;
  }
View Full Code Here

    if (index >= 0) {
      Tool circuitTool = tools.remove(index);

      if (main == circuit) {
        AddTool dflt_tool = tools.get(0);
        SubcircuitFactory factory = (SubcircuitFactory) dflt_tool.getFactory();
        setMainCircuit(factory.getSubcircuit());
      }
      fireEvent(LibraryEvent.REMOVE_TOOL, circuitTool);
    }
  }
View Full Code Here

      }
    }
    Collections.sort(newChildren, new CompareByName());
    Collections.sort(subcircs, this);
    for (Component comp : subcircs) {
      SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
      CircuitState state = factory.getSubstate(circuitState, comp);
      SimulationTreeCircuitNode toAdd = null;
      for (TreeNode o : children) {
        if (o instanceof SimulationTreeCircuitNode) {
          SimulationTreeCircuitNode n = (SimulationTreeCircuitNode) o;
          if (n.circuitState == state) { toAdd = n; break; }
View Full Code Here

      int act = event.getAction();
      if (act == LibraryEvent.ADD_TOOL) {
        if (event.getData() instanceof AddTool) {
          AddTool tool = (AddTool) event.getData();
          if (tool.getFactory() instanceof SubcircuitFactory) {
            SubcircuitFactory fact = (SubcircuitFactory) tool.getFactory();
            fact.getSubcircuit().addCircuitListener(this);
          }
        }
      } else if (act == LibraryEvent.REMOVE_TOOL) {
        if (event.getData() instanceof AddTool) {
          AddTool tool = (AddTool) event.getData();
          if (tool.getFactory() instanceof SubcircuitFactory) {
            SubcircuitFactory fact = (SubcircuitFactory) tool.getFactory();
            fact.getSubcircuit().removeCircuitListener(this);
          }
        }
      } else if (act == LibraryEvent.ADD_LIBRARY) {
        if (event.getData() instanceof LibraryEventSource) {
          ((LibraryEventSource) event.getData()).addLibraryListener(subListener);
View Full Code Here

    if (!canvas.getProject().getLogisimFile().contains(circ)) {
      canvas.setErrorMessage(Strings.getter("cannotModifyError"));
      return;
    }
    if (factory instanceof SubcircuitFactory) {
      SubcircuitFactory circFact = (SubcircuitFactory) factory;
      Dependencies depends = canvas.getProject().getDependencies();
      if (!depends.canAdd(circ, circFact.getSubcircuit())) {
        canvas.setErrorMessage(Strings.getter("circularError"));
        return;
      }
    }
View Full Code Here

      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());
      }
      replaceAll(proj.getLogisimFile(), compMap, toolMap);
    }
    for (LogisimFile file : LibraryManager.instance.getLogisimLibraries()) {
      replaceAll(file, compMap, toolMap);
View Full Code Here

        }
      }
      Collections.sort(newChildren, new CompareByName());
      Collections.sort(subcircs, this);
      for (Component comp : subcircs) {
        SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
        CircuitState state = factory.getSubstate(circuitState, comp);
        CircuitNode toAdd = null;
        for (TreeNode o : children) {
          if (o instanceof CircuitNode) {
            CircuitNode n = (CircuitNode) o;
            if (n.circuitState == state) { toAdd = n; break; }
View Full Code Here

TOP

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

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.