Package com.cburch.logisim.tools

Examples of com.cburch.logisim.tools.AddTool


  public void addCircuit(Circuit circuit) {
    addCircuit(circuit, tools.size());
  }
 
  public void addCircuit(Circuit circuit, int index) {
    AddTool tool = new AddTool(circuit.getSubcircuitFactory());
    tools.add(index, tool);
    if (tools.size() == 1) setMainCircuit(circuit);
    fireEvent(LibraryEvent.ADD_TOOL, tool);
  }
View Full Code Here


    int index = getCircuits().indexOf(circuit);
    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

    int oldIndex = tools.indexOf(tool);
    if (oldIndex < 0) {
      tools.add(index, tool);
      fireEvent(LibraryEvent.ADD_TOOL, tool);
    } else {
      AddTool value = tools.remove(oldIndex);
      tools.add(index, value);
      fireEvent(LibraryEvent.MOVE_TOOL, tool);
    }
  }
View Full Code Here

  //
  public static LogisimFile createNew(Loader loader) {
    LogisimFile ret = new LogisimFile(loader);
    ret.main = new Circuit("main");
    // The name will be changed in LogisimPreferences
    ret.tools.add(new AddTool(ret.main.getSubcircuitFactory()));
    return ret;
  }
View Full Code Here

      new EditTool(select, wiring),
      select,
      wiring,
      new TextTool(),
      new MenuTool(),
      new AddTool(Text.FACTORY),
    });
  }
View Full Code Here

    private boolean canMove(Object draggedNode, Object targetNode) {
      if (listener == null) return false;
      if (!(draggedNode instanceof AddTool) || !(targetNode instanceof AddTool)) return false;
      LogisimFile file = proj.getLogisimFile();
      AddTool dragged = (AddTool) draggedNode;
      AddTool target = (AddTool) targetNode;
      int draggedIndex = file.getTools().indexOf(dragged);
      int targetIndex = file.getTools().indexOf(target);
      if (targetIndex < 0 || draggedIndex < 0) return false;
      return true;
    }
View Full Code Here

    public void libraryChanged(LibraryEvent event) {
      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) {
View Full Code Here

      }
    }
  }

  public static void doMoveCircuit(Project proj, Circuit cur, int delta) {
    AddTool tool = proj.getLogisimFile().getAddTool(cur);
    if (tool != null) {
      int oldPos = proj.getLogisimFile().getCircuits().indexOf(cur);
      int newPos = oldPos + delta;
      int toolsCount = proj.getLogisimFile().getTools().size();
      if (newPos >= 0 && newPos < toolsCount) {
View Full Code Here

public class Gates extends Library {
  private List<Tool> tools = null;

  public Gates() {
    tools = Arrays.asList(new Tool[] {
      new AddTool(NotGate.FACTORY),
      new AddTool(Buffer.FACTORY),
      new AddTool(AndGate.FACTORY),
      new AddTool(OrGate.FACTORY),
      new AddTool(NandGate.FACTORY),
      new AddTool(NorGate.FACTORY),
      new AddTool(XorGate.FACTORY),
      new AddTool(XnorGate.FACTORY),
      new AddTool(OddParityGate.FACTORY),
      new AddTool(EvenParityGate.FACTORY),
      new AddTool(ControlledBuffer.FACTORY_BUFFER),
      new AddTool(ControlledBuffer.FACTORY_INVERTER),
    });
  }
View Full Code Here

   * Logisim accesses first when it opens the JAR file: It looks for
   * a no-arguments constructor method of the user-designated class.
   */
  public Components() {
    tools = Arrays.asList(new AddTool[] {
        new AddTool(new GrayIncrementer()),
        new AddTool(new SimpleGrayCounter()),
        new AddTool(new GrayCounter()),
    });
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.tools.AddTool

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.