Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.ComponentFactory


    }
    if (toReplace != null) {
      CircuitMutation xn = new CircuitMutation(circuit);
      for (Component comp : toReplace) {
        xn.remove(comp);
        ComponentFactory factory = compMap.get(comp.getFactory());
        if (factory != null) {
          AttributeSet newAttrs = createAttributes(factory, comp.getAttributeSet());
          xn.add(factory.createComponent(comp.getLocation(), newAttrs));
        }
      }
      xn.execute();
    }
  }
View Full Code Here


        throw new XmlReaderException(Strings.get("compUnknownError", name));
      } else {
        throw new XmlReaderException(Strings.get("compAbsentError", name, libName));
      }
    }
    ComponentFactory source = ((AddTool) tool).getFactory();

    // Determine attributes
    String loc_str = elt.getAttribute("loc");
    AttributeSet attrs = source.createAttributeSet();
    reader.initAttributeSet(elt, attrs, source);

    // Create component if location known
    if (loc_str == null || loc_str.equals("")) {
      throw new XmlReaderException(Strings.get("compLocMissingError", source.getName()));
    } else {
      try {
        Location loc = Location.parse(loc_str);
        return source.createComponent(loc, attrs);
      } catch (NumberFormatException e) {
        throw new XmlReaderException(Strings.get("compLocInvalidError",
          source.getName(), loc_str));
      }
    }
  }
View Full Code Here

      if (inputs.size() <= 2) {
        for (CircuitDetermination a : inputs) {
          a.convertToTwoInputs();
        }
      } else {
        ComponentFactory subFactory;
        if (factory == NorGate.FACTORY) subFactory = OrGate.FACTORY;
        else if (factory == NandGate.FACTORY) subFactory = AndGate.FACTORY;
        else subFactory = factory;
         
        int split = (inputs.size() + 1) / 2;
View Full Code Here

      if (num > GateAttributes.MAX_INPUTS) {
        int newNum = (num + GateAttributes.MAX_INPUTS - 1) / GateAttributes.MAX_INPUTS;
        ArrayList<CircuitDetermination> oldInputs = inputs;
        inputs = new ArrayList<CircuitDetermination>();
       
        ComponentFactory subFactory = factory;
        if (subFactory == NandGate.FACTORY) subFactory = AndGate.FACTORY;
        if (subFactory == NorGate.FACTORY) subFactory = OrGate.FACTORY;
       
        int per = num / newNum;
        int numExtra = num - per * newNum;
 
View Full Code Here

      // add it into the circuit
      boolean added = comps.add(c);
      if (!added) return;

      wires.add(c);
      ComponentFactory factory = c.getFactory();
      if (factory instanceof Clock) {
        clocks.add(c);
      } else if (factory instanceof SubcircuitFactory) {
        SubcircuitFactory subcirc = (SubcircuitFactory) factory;
        subcirc.getSubcircuit().circuitsUsingThis.put(c, this);
View Full Code Here

    if (c instanceof Wire) {
      wires.remove(c);
    } else {
      wires.remove(c);
      comps.remove(c);
      ComponentFactory factory = c.getFactory();
      if (factory instanceof Clock) {
        clocks.remove(c);
      } else if (factory instanceof SubcircuitFactory) {
        SubcircuitFactory subcirc = (SubcircuitFactory) factory;
        subcirc.getSubcircuit().circuitsUsingThis.remove(c);
View Full Code Here

  public void selectionChanged(ProjectExplorer.Event event) {
    Object selected = event.getTarget();
    if (selected instanceof Tool) {
      if (selected instanceof AddTool) {
        AddTool addTool = (AddTool) selected;
        ComponentFactory source = addTool.getFactory();
        if (source instanceof SubcircuitFactory) {
          SubcircuitFactory circFact = (SubcircuitFactory) source;
          Circuit circ = circFact.getSubcircuit();
          if (proj.getCurrentCircuit() == circ) {
            AttrTableModel m = new AttrTableCircuitModel(proj, circ);
View Full Code Here

  public void doubleClicked(ProjectExplorer.Event event) {
    Object clicked = event.getTarget();
    if (clicked instanceof AddTool) {
      AddTool tool = (AddTool) clicked;
      ComponentFactory source = tool.getFactory();
      if (source instanceof SubcircuitFactory) {
        SubcircuitFactory circFact = (SubcircuitFactory) source;
        proj.setCurrentCircuit(circFact.getSubcircuit());
        proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
        if (lastSelected != null) proj.setTool(lastSelected);
View Full Code Here

  public void deleteRequested(ProjectExplorer.Event event) {
    Object request = event.getTarget();
    if (request instanceof Library) {
      ProjectLibraryActions.doUnloadLibrary(proj, (Library) request);
    } else if (request instanceof AddTool) {
      ComponentFactory factory = ((AddTool) request).getFactory();
      if (factory instanceof SubcircuitFactory) {
        SubcircuitFactory circFact = (SubcircuitFactory) factory;
        ProjectCircuitActions.doRemoveCircuit(proj, circFact.getSubcircuit());
      }
    }
View Full Code Here

  public JPopupMenu menuRequested(ProjectExplorer.Event event) {
    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;
View Full Code Here

TOP

Related Classes of com.cburch.logisim.comp.ComponentFactory

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.