Package com.cburch.logisim.comp

Examples of com.cburch.logisim.comp.Component


  public void circuitChanged(CircuitEvent event) {
    int action = event.getAction();
    if (action == CircuitEvent.ACTION_CLEAR
        || action == CircuitEvent.ACTION_REMOVE) {
      Circuit circ = event.getCircuit();
      Component circComp = null;
      if (circ == model.getCircuitState().getCircuit()) {
        circComp = path != null && path.length > 0 ? path[0] : comp;
      } else if (path != null) {
        for (int i = 0; i < path.length; i++) {
          SubcircuitFactory circFact = (SubcircuitFactory) path[i].getFactory();
View Full Code Here


    if (!handlers.isEmpty()) {
      boolean consume = false;
      ArrayList<KeyConfigurationResult> results;
      results = new ArrayList<KeyConfigurationResult>();
      for (Map.Entry<Component, KeyConfigurator> entry : handlers.entrySet()) {
        Component comp = entry.getKey();
        KeyConfigurator handler = entry.getValue();
        KeyConfigurationEvent event = new KeyConfigurationEvent(type,
            comp.getAttributeSet(), e, comp);
        KeyConfigurationResult result = handler.keyEventReceived(event);
        consume |= event.isConsumed();
        if (result != null) {
          results.add(result);
        }
      }
      if (consume) {
        e.consume();
      }
      if (!results.isEmpty()) {
        SetAttributeAction act = new SetAttributeAction(canvas.getCircuit(),
            Strings.getter("changeComponentAttributesAction"));
        for (KeyConfigurationResult result : results) {
          Component comp = (Component) result.getEvent().getData();
          Map<Attribute<?>,Object> newValues = result.getAttributeValues();
          for (Map.Entry<Attribute<?>,Object> entry : newValues.entrySet()) {
            act.set(comp, entry.getKey(), entry.getValue());
          }
        }
View Full Code Here

    HashSet<Wire> wires = new HashSet<Wire>();
    for (Location loc : points.getSplitLocations()) {
      Collection<? extends Component> at = points.getComponents(loc);
      if (at.size() == 2) {
        Iterator<? extends Component> atIt = at.iterator();
        Component o0 = atIt.next();
        Component o1 = atIt.next();
        if (o0 instanceof Wire && o1 instanceof Wire) {
          Wire w0 = (Wire) o0;
          Wire w1 = (Wire) o1;
          if (w0.is_x_equal == w1.is_x_equal) {
            wires.add(w0);
View Full Code Here

        Iterator<Component> it = comps.iterator();
        if (!it.hasNext()) {
            return wireBounds;
        }

        Component first = it.next();
        Bounds firstBounds = first.getBounds();
        int xMin = firstBounds.getX();
        int yMin = firstBounds.getY();
        int xMax = xMin + firstBounds.getWidth();
        int yMax = yMin + firstBounds.getHeight();
        while (it.hasNext()) {
            Component c = it.next();
            Bounds bds = c.getBounds();
            int x0 = bds.getX(); int x1 = x0 + bds.getWidth();
            int y0 = bds.getY(); int y1 = y0 + bds.getHeight();
            if (x0 < xMin) {
                xMin = x0;
            }
View Full Code Here

        for (Element sub_elt : XmlIterator.forChildElements(elt)) {
            String sub_elt_name = sub_elt.getTagName();
            if (sub_elt_name.equals("comp")) {
                try {
                    Component comp = knownComponents.get(sub_elt);
                    if (comp == null) {
                        comp = getComponent(sub_elt, reader);
                    }
                    mutator.add(dest, comp);
                } catch (XmlReaderException e) {
View Full Code Here

    private class MyComponentListener implements ComponentListener {
        @Override
        public void endChanged(ComponentEvent e) {
            locker.checkForWritePermission("ends changed");
            Component comp = e.getSource();
            HashMap<Location,EndData> toRemove = toMap(e.getOldData());
            HashMap<Location,EndData> toAdd = toMap(e.getData());
            EndChangedTransaction xn = new EndChangedTransaction(comp, toRemove, toAdd);
            locker.execute(xn);
            fireEvent(CircuitEvent.ACTION_INVALIDATE, comp);
View Full Code Here

                        continue;
                    }

                    Expression old = expressionMap.get(p2);
                    if (old != null) {
                        Component eCause = expressionMap.currentCause;
                        Component oldCause = expressionMap.causes.get(p2);
                        if (eCause != oldCause && !old.equals(e)) {
                            throw new AnalyzeException.Conflict();
                        }
                    }
                    expressionMap.put(p2, e);
View Full Code Here

            }
        }

        @Override
        public void circuitChanged(CircuitEvent e) {
            Component comp;
            switch (e.getAction()) {
            case CircuitEvent.ACTION_ADD:
                comp = (Component) e.getData();
                if (comp.getFactory() instanceof SubcircuitFactory) {
                    SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                    depends.addEdge(e.getCircuit(), factory.getSubcircuit());
                }
                break;
            case CircuitEvent.ACTION_REMOVE:
                comp = (Component) e.getData();
                if (comp.getFactory() instanceof SubcircuitFactory) {
                    SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
                    boolean found = false;
                    for (Component o : e.getCircuit().getNonWires()) {
                        if (o.getFactory() == factory) {
                            found = true;
                            break;
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

                }
            }
            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

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.