Package com.cburch.logisim.instance

Examples of com.cburch.logisim.instance.Instance


    } else if (name.equals("circ-port")) {
      Location loc = getLocation(elt);
      String[] pinStr = elt.getAttribute("pin").split(",");
      Location pinLoc = Location.create(Integer.parseInt(pinStr[0].trim()),
          Integer.parseInt(pinStr[1].trim()));
      Instance pin = pins.get(pinLoc);
      if (pin == null) {
        return null;
      } else {
        return new AppearancePort(loc, pin);
      }
View Full Code Here


    // which instances facing the same way in layout
    Set<Location> usedLocs = new HashSet<Location>();
    List<Instance> sameWay = new ArrayList<Instance>();
    Direction facing = pin.getAttributeValue(StdAttr.FACING);
    for (Map.Entry<Instance, AppearancePort> entry : others.entrySet()) {
      Instance pin2 = entry.getKey();
      Location loc = entry.getValue().getLocation();
      usedLocs.add(loc);
      if (pin2.getAttributeValue(StdAttr.FACING) == facing) {
        sameWay.add(pin2);
      }
    }
   
    // if at least one faces the same way, place pin relative to that
    if (sameWay.size() > 0) {
      sameWay.add(pin);
      DefaultAppearance.sortPinList(sameWay, facing);
      boolean isFirst = false;
      Instance neighbor = null; // (preferably previous in map)
      for (Instance p : sameWay) {
        if (p == pin) {
          break;
        } else {
          neighbor = p;
View Full Code Here

  void setPin(Instance value) {
    pin = value;
  }
 
  private boolean isInput() {
    Instance p = pin;
    return p == null || Pin.FACTORY.isInputPin(p);
  }
View Full Code Here

    Set<Instance> adds = new HashSet<Instance>();
    Set<Instance> removes = new HashSet<Instance>();
    Map<Instance, Instance> replaces = new HashMap<Instance, Instance>();
    for (Component comp : repl.getAdditions()) {
      if (comp.getFactory() instanceof Pin) {
        Instance in = Instance.getInstanceFor(comp);
        boolean added = pins.add(in);
        if (added) {
          comp.addComponentListener(myComponentListener);
          in.getAttributeSet().addAttributeListener(myComponentListener);
          adds.add(in);
        }
      }
    }
    for (Component comp : repl.getRemovals()) {
      if (comp.getFactory() instanceof Pin) {
        Instance in = Instance.getInstanceFor(comp);
        boolean removed = pins.remove(in);
        if (removed) {
          comp.removeComponentListener(myComponentListener);
          in.getAttributeSet().removeAttributeListener(myComponentListener);
          Collection<Component> rs = repl.getComponentsReplacing(comp);
          if (rs.isEmpty()) {
            removes.add(in);
          } else {
            Component r = rs.iterator().next();
            Instance rin = Instance.getInstanceFor(r);
            adds.remove(rin);
            replaces.put(in, rin);
          }
        }
      }
View Full Code Here

      Rectangle bdsOut = GraphicsUtil.getTextBounds(g, textTrim, 0, 0,
          halign, valign);
      newBds = Bounds.create(bdsOut).expand(4);
    }
    if (attrs.setOffsetBounds(newBds)) {
      Instance instance = painter.getInstance();
      if (instance != null) instance.recomputeBounds();
    }
       
    g.setFont(old);
  }
View Full Code Here

   
    Project proj = new Project(file);
    Circuit circuit = file.getMainCircuit();
    Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
    ArrayList<Instance> outputPins = new ArrayList<Instance>();
    Instance haltPin = null;
    for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
      Instance pin = entry.getKey();
      String pinName = entry.getValue();
      if (!Pin.FACTORY.isInputPin(pin)) {
        outputPins.add(pin);
        if (pinName.equals("halt")) {
          haltPin = pin;
View Full Code Here

    private void loadAppearance(Element appearElt, CircuitData circData,
        String context) {
      Map<Location, Instance> pins = new HashMap<Location, Instance>();
      for (Component comp : circData.knownComponents.values()) {
        if (comp.getFactory() == Pin.FACTORY) {
          Instance instance = Instance.getInstanceFor(comp);
          pins.put(comp.getLocation(), instance);
        }
      }
     
      List<AbstractCanvasObject> shapes = new ArrayList<AbstractCanvasObject>();
View Full Code Here

  public static void doAnalyze(Project proj, Circuit circuit) {
    Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
    ArrayList<String> inputNames = new ArrayList<String>();
    ArrayList<String> outputNames = new ArrayList<String>();
    for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
      Instance pin = entry.getKey();
      boolean isInput = Pin.FACTORY.isInputPin(pin);
      if (isInput) {
        inputNames.add(entry.getValue());
      } else {
        outputNames.add(entry.getValue());
      }
      if (pin.getAttributeValue(StdAttr.WIDTH).getWidth() > 1) {
        if (isInput) {
          analyzeError(proj, Strings.get("analyzeMultibitInputError"));
        } else {
          analyzeError(proj, Strings.get("analyzeMultibitOutputError"));
        }
View Full Code Here

    Instance[] pins = new Instance[portLocs.size()];
    int i = -1;
    for (Map.Entry<Location, Instance> portLoc : portLocs.entrySet()) {
      i++;
      Location loc = portLoc.getKey();
      Instance pin = portLoc.getValue();
      String type = Pin.FACTORY.isInputPin(pin) ? Port.INPUT : Port.OUTPUT;
      BitWidth width = pin.getAttributeValue(StdAttr.WIDTH);
      ports[i] = new Port(loc.getX(), loc.getY(), type, width);
      pins[i] = pin;
     
      String label = pin.getAttributeValue(StdAttr.LABEL);
      if (label != null && label.length() > 0) {
        ports[i].setToolTip(StringUtil.constantGetter(label));
      }
    }
   
View Full Code Here

    CircuitState subState = getSubstate(superState);

    CircuitAttributes attrs = (CircuitAttributes) superState.getAttributeSet();
    Instance[] pins = attrs.getPinInstances();
    for (int i = 0; i < pins.length; i++) {
      Instance pin = pins[i];
      InstanceState pinState = subState.getInstanceState(pin);
      if (Pin.FACTORY.isInputPin(pin)) {
        Value newVal = superState.getPort(i);
        Value oldVal = Pin.FACTORY.getValue(pinState);
        if (!newVal.equals(oldVal)) {
View Full Code Here

TOP

Related Classes of com.cburch.logisim.instance.Instance

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.