Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.Component


  public Bounds getBounds(Graphics g) {
    Iterator<Component> it = unionSet.iterator();
    if (it.hasNext()) {
      bounds = it.next().getBounds(g);
      while (it.hasNext()) {
        Component comp = it.next();
        Bounds bds = comp.getBounds(g);
        bounds = bounds.add(bds);
      }
    } else {
      bounds = Bounds.EMPTY_BOUNDS;
    }
View Full Code Here


    for (Component comp : components) {
      if (!(comp instanceof Wire)) {
        for (EndData endData : comp.getEnds()) {
          if (endData != null && endData.isExclusive()) {
            Location endLoc = endData.getLocation().translate(dx, dy);
            Component conflict = circuit.getExclusive(endLoc);
            if (conflict != null) {
              if (selfConflicts || !components.contains(conflict)) return true;
            }
          }
        }
View Full Code Here

      return Bounds.EMPTY_BOUNDS;
    } else {
      Iterator<Component> it = components.iterator();
      Bounds ret = it.next().getBounds();
      while (it.hasNext()) {
        Component comp = it.next();
        Bounds bds = comp.getBounds();
        ret = ret.add(bds);
      }
      return ret;
    }
  }
View Full Code Here

        newX = Canvas.snapXToGrid(newX);
        newY = Canvas.snapYToGrid(newY);
      }
      Location newLoc = Location.create(newX, newY);
     
      Component copy = comp.getFactory().createComponent(newLoc, attrs);
      ret.put(comp, copy);
    }
    return ret;
  }
View Full Code Here

        }
      }
      dirtyComponents.clear();
      for (Object compObj : toProcess) {
        if (compObj instanceof Component) {
          Component comp = (Component) compObj;
          comp.propagate(this);
          if (comp.getFactory() instanceof Pin && parentState != null) {
            // should be propagated in superstate
            parentComp.propagate(parentState);
          }
        }
      }
View Full Code Here

  }
 
  void reset() {
    wireData = null;
    for (Iterator<Component> it = componentData.keySet().iterator(); it.hasNext(); ) {
      Component comp = it.next();
      if (!(comp.getFactory() instanceof SubcircuitFactory)) it.remove();
    }
    values.clear();
    dirtyComponents.clear();
    dirtyPoints.clear();
    causes.clear();
View Full Code Here

public class CircuitState implements InstanceData {
  private class MyCircuitListener implements CircuitListener {
    public void circuitChanged(CircuitEvent event) {
      int action = event.getAction();
      if (action == CircuitEvent.ACTION_ADD) {
        Component comp = (Component) event.getData();
        if (comp instanceof Wire) {
          Wire w = (Wire) comp;
          markPointAsDirty(w.getEnd0());
          markPointAsDirty(w.getEnd1());
        } else {
          markComponentAsDirty(comp);
        }
      } else if (action == CircuitEvent.ACTION_REMOVE) {
        Component comp = (Component) event.getData();
        if (comp.getFactory() instanceof SubcircuitFactory) {
          // disconnect from tree
          CircuitState substate = (CircuitState) getData(comp);
          if (substate != null && substate.parentComp == comp) {
            substates.remove(substate);
            substate.parentState = null;
            substate.parentComp = null;
          }
        }

        if (comp instanceof Wire) {
          Wire w = (Wire) comp;
          markPointAsDirty(w.getEnd0());
          markPointAsDirty(w.getEnd1());
        } else {
          if (base != null) base.checkComponentEnds(CircuitState.this, comp);
          dirtyComponents.remove(comp);
        }
      } else if (action == CircuitEvent.ACTION_CLEAR) {
        substates.clear();
        wireData = null;
        componentData.clear();
        values.clear();
        dirtyComponents.clear();
        dirtyPoints.clear();
        causes.clear();
      } else if (action == CircuitEvent.ACTION_CHANGE) {
        Object data = event.getData();
        if (data instanceof Collection) {
          @SuppressWarnings("unchecked")
          Collection<Component> comps = (Collection<Component>) data;
          markComponentsDirty(comps);
          if (base != null) {
            for (Component comp : comps) {
              base.checkComponentEnds(CircuitState.this, comp);
            }
          }
        } else {
          Component comp = (Component) event.getData();
          markComponentAsDirty(comp);
          if (base != null) base.checkComponentEnds(CircuitState.this, comp);
        }
      } else if (action == CircuitEvent.ACTION_INVALIDATE) {
        Component comp = (Component) event.getData();
        markComponentAsDirty(comp);
        // TODO detemine if this should really be missing if (base != null) base.checkComponentEnds(CircuitState.this, comp);
      } else if (action == CircuitEvent.TRANSACTION_DONE) {
        ReplacementMap map = event.getResult().getReplacementMap(circuit);
        if (map != null) {
          for (Component comp : map.getReplacedComponents()) {
            Object compState = componentData.remove(comp);
            if (compState != null) {
              Class<?> compFactory = comp.getFactory().getClass();
              boolean found = false;
              for (Component repl : map.get(comp)) {
                if (repl.getFactory().getClass() == compFactory) {
                  found = true;
                  setData(repl, compState);
View Full Code Here

   
    // first see how many elements we have; we can handle some simple
    // cases without creating any new lists
    ArrayList<Component> list = locData.components;
    int retSize = 0;
    Component retValue = null;
    for (Component o : list) {
      if ((o instanceof Wire) == isWire) { retValue = o; retSize++; }
    }
    if (retSize == list.size()) return list;
    if (retSize == 0) return Collections.emptySet();
View Full Code Here

      if (e.state == state) {
        Location p = e.loc;
        g.drawOval(p.getX() - 4, p.getY() - 4, 8, 8);
      } else if (stateMap.containsKey(e.state)) {
        CircuitState substate = stateMap.get(e.state);
        Component subcirc = substate.getSubcircuit();
        Bounds b = subcirc.getBounds();
        g.drawRect(b.getX(), b.getY(), b.getWidth(), b.getHeight());
      }
    }
    GraphicsUtil.switchToWidth(g, 1);
  }
View Full Code Here

      toolbox.setHaloedTool(null);
      layoutToolbarModel.setHaloedTool(null);
    }
    if (value instanceof AttrTableComponentModel) {
      Circuit circ = ((AttrTableComponentModel) value).getCircuit();
      Component comp = ((AttrTableComponentModel) value).getComponent();
      layoutCanvas.setHaloedComponent(circ, comp);
    } else {
      layoutCanvas.setHaloedComponent(null, null);
    }
  }
View Full Code Here

TOP

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

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.